aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Buttons.hx21
-rw-r--r--src/client/ClientSettings.hx31
-rw-r--r--src/client/Main.hx23
3 files changed, 54 insertions, 21 deletions
diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx
index 11b8f7c..78b1c5a 100644
--- a/src/client/Buttons.hx
+++ b/src/client/Buttons.hx
@@ -222,6 +222,7 @@ class Buttons {
}
final mediaUrl:InputElement = getEl("#mediaurl");
+ final checkboxCache:InputElement = getEl("#cache-on-server");
mediaUrl.oninput = () -> {
final url = mediaUrl.value;
final playerType = main.getLinkPlayerType(url);
@@ -230,8 +231,13 @@ class Buttons {
getEl("#mediatitleblock").style.display = isSingleRawVideo ? "" : "none";
getEl("#subsurlblock").style.display = isSingleRawVideo ? "" : "none";
getEl("#voiceoverblock").style.display = (url.length > 0 && isSingle) ? "" : "none";
- final showCache = isSingle && main.playersCacheSupport.contains(playerType);
- getEl("#cache-on-server").parentElement.style.display = showCache ? "" : "none";
+
+ final isExternal = main.isExternalVideoUrl(url);
+ final showCache = isSingle && isExternal
+ && main.playersCacheSupport.contains(playerType);
+ checkboxCache.parentElement.style.display = showCache ? "" : "none";
+ checkboxCache.checked = settings.checkedCache.contains(playerType);
+
final panel = getEl("#addfromurl");
final oldH = panel.style.height; // save for animation
panel.style.height = ""; // to calculate height from content
@@ -241,6 +247,16 @@ class Buttons {
}
mediaUrl.onfocus = mediaUrl.oninput;
+ checkboxCache.addEventListener("change", () -> {
+ final url = mediaUrl.value;
+ final playerType = main.getLinkPlayerType(url);
+ final checked = checkboxCache.checked;
+
+ settings.checkedCache.remove(playerType);
+ if (checked) settings.checkedCache.push(playerType);
+ Settings.write(settings);
+ });
+
getEl("#insert_template").onclick = e -> {
mediaUrl.value = main.getTemplateUrl();
mediaUrl.focus();
@@ -518,7 +534,6 @@ class Buttons {
});
final checkboxes:Array<InputElement> = [
getEl("#add-temp"),
- getEl("#cache-on-server"),
];
for (checkbox in checkboxes) {
checkbox.addEventListener("change", () -> {
diff --git a/src/client/ClientSettings.hx b/src/client/ClientSettings.hx
index cb5f99f..1bca427 100644
--- a/src/client/ClientSettings.hx
+++ b/src/client/ClientSettings.hx
@@ -1,19 +1,20 @@
package client;
+import Types.PlayerType;
+
typedef ClientSettings = {
- version:Int,
- uuid:Null<String>,
- name:String,
- hash:String,
- isExtendedPlayer:Bool,
- playerSize:Float,
- chatSize:Float,
- synchThreshold:Int,
- isSwapped:Bool,
- isUserListHidden:Bool,
- latestLinks:Array<String>,
- latestSubs:Array<String>,
- hotkeysEnabled:Bool,
- showHintList:Bool,
- checkboxes:Array<{id:String, checked:Null<Bool>}>,
+ var version:Int;
+ var uuid:Null<String>;
+ var name:String;
+ var hash:String;
+ var chatSize:Float;
+ var synchThreshold:Int;
+ var isSwapped:Bool;
+ var isUserListHidden:Bool;
+ var latestLinks:Array<String>;
+ var latestSubs:Array<String>;
+ var hotkeysEnabled:Bool;
+ var showHintList:Bool;
+ var checkboxes:Array<{id:String, checked:Null<Bool>}>;
+ var checkedCache:Array<PlayerType>;
}
diff --git a/src/client/Main.hx b/src/client/Main.hx
index e7f8f30..abc39f6 100644
--- a/src/client/Main.hx
+++ b/src/client/Main.hx
@@ -27,7 +27,7 @@ import js.html.WebSocket;
class Main {
public static var instance(default, null):Main;
- static inline var SETTINGS_VERSION = 5;
+ static inline var SETTINGS_VERSION = 6;
static inline var MAX_CHAT_MESSAGES = 200;
public final settings:ClientSettings;
@@ -81,8 +81,6 @@ class Main {
uuid: null,
name: "",
hash: "",
- isExtendedPlayer: false,
- playerSize: 1,
chatSize: 300,
synchThreshold: 2,
isSwapped: false,
@@ -92,6 +90,7 @@ class Main {
hotkeysEnabled: true,
showHintList: true,
checkboxes: [],
+ checkedCache: [],
}
Settings.init(defaults, settingsPatcher);
settings = Settings.read();
@@ -139,6 +138,16 @@ class Main {
case 4:
final data:ClientSettings = data;
data.checkboxes = [];
+ case 5:
+ final data:ClientSettings = data;
+ data.checkedCache = [];
+ Reflect.deleteField(data, "playerSize");
+ Reflect.deleteField(data, "isExtendedPlayer");
+ final oldCheck = data.checkboxes.find(item -> item.id == "cache-on-server");
+ if (oldCheck != null) {
+ data.checkboxes.remove(oldCheck);
+ data.checkedCache.push(YoutubeType);
+ }
case SETTINGS_VERSION, _:
throw 'skipped version $version';
}
@@ -307,6 +316,14 @@ class Main {
return player.isSingleVideoUrl(url);
}
+ public function isExternalVideoUrl(url:String):Bool {
+ url = url.ltrim();
+ if (url.startsWith("/")) return false;
+ final host = Browser.location.hostname;
+ if (url.contains(host)) return false;
+ return true;
+ }
+
public function sortItemsForQueueNext<T>(items:Array<T>):Void {
if (items.length == 0) return;
// except first item when list empty
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage