aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/Buttons.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2025-01-16 03:07:31 +0300
committerRblSb <msrblsb@gmail.com>2025-01-17 01:00:09 +0300
commitd9ca7beaa9494cf34590853901cf8be44e243775 (patch)
treef09ce979460bdf28363a922298283dfee0c506fb /src/client/Buttons.hx
parentf84fdc40ba817b6a2d907484b1e1500197ceeafe (diff)
Cache on server feature
Server will download video from supported players and add as raw video to playlist (only youtube is supported for now). Cache for YT player is available after installing optional dependencies, see readme. For cache size see `cacheStorageLimitGiB ` in config. There is also minor ux improvement, latest checkbox states will be keeped in local storage now.
Diffstat (limited to 'src/client/Buttons.hx')
-rw-r--r--src/client/Buttons.hx34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx
index c3581e2..f5f26e8 100644
--- a/src/client/Buttons.hx
+++ b/src/client/Buttons.hx
@@ -22,6 +22,12 @@ class Buttons {
setSplitSize(settings.chatSize);
initChatInput(main);
+ for (item in settings.checkboxes) {
+ if (item.checked == null) continue;
+ final checkbox:InputElement = ge('#${item.id}') ?? continue;
+ checkbox.checked = item.checked;
+ }
+
final passIcon = ge("#guestpass_icon");
passIcon.onclick = e -> {
final icon = passIcon.firstElementChild;
@@ -213,12 +219,15 @@ class Buttons {
final mediaUrl:InputElement = cast ge("#mediaurl");
mediaUrl.oninput = () -> {
- final value = mediaUrl.value;
- final isRawSingleVideo = value != "" && main.isRawPlayerLink(value)
- && main.isSingleVideoLink(value);
- ge("#mediatitleblock").style.display = isRawSingleVideo ? "" : "none";
- ge("#subsurlblock").style.display = isRawSingleVideo ? "" : "none";
- ge("#voiceoverblock").style.display = value.length > 0 ? "" : "none";
+ final url = mediaUrl.value;
+ final playerType = main.getLinkPlayerType(url);
+ final isSingle = main.isSingleVideoUrl(url);
+ final isSingleRawVideo = url != "" && playerType == RawType && isSingle;
+ ge("#mediatitleblock").style.display = isSingleRawVideo ? "" : "none";
+ ge("#subsurlblock").style.display = isSingleRawVideo ? "" : "none";
+ ge("#voiceoverblock").style.display = (url.length > 0 && isSingle) ? "" : "none";
+ final showCache = isSingle && main.playersCacheSupport.contains(playerType);
+ ge("#cache-on-server").parentElement.style.display = showCache ? "" : "none";
final panel = ge("#addfromurl");
final oldH = panel.style.height; // save for animation
panel.style.height = ""; // to calculate height from content
@@ -482,6 +491,19 @@ class Buttons {
if (Utils.isTouch()) chatline.blur();
return true;
});
+ final checkboxes:Array<InputElement> = [
+ ge("#add-temp"),
+ ge("#cache-on-server"),
+ ];
+ for (checkbox in checkboxes) {
+ checkbox.addEventListener("change", () -> {
+ final checked = checkbox.checked;
+ final item = settings.checkboxes.find(item -> item.id == checkbox.id);
+ settings.checkboxes.remove(item);
+ settings.checkboxes.push({id: checkbox.id, checked: checked});
+ Settings.write(settings);
+ });
+ }
}
static inline function getVisualViewport():Null<VisualViewport> {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage