From 382f9b2ebedca905028341825350a0fa69d88673 Mon Sep 17 00:00:00 2001 From: RblSb Date: Wed, 29 Jan 2025 20:37:50 +0300 Subject: Cleanup - PWA support (needs https) - Optimize websocket responses - Support `/ad` for youtube cache - New icon! --- res/client.js | 74 ++++++++++++++++++++++++++++++---------------------- res/css/des.css | 6 +++++ res/img/favicon.png | Bin 171 -> 0 bytes res/img/favicon.svg | 17 ++++++++++++ res/index.html | 5 +++- res/manifest.json | 12 +++++++++ 6 files changed, 82 insertions(+), 32 deletions(-) delete mode 100755 res/img/favicon.png create mode 100644 res/img/favicon.svg create mode 100644 res/manifest.json (limited to 'res') diff --git a/res/client.js b/res/client.js index ac32132..9629980 100644 --- a/res/client.js +++ b/res/client.js @@ -556,8 +556,12 @@ client_Buttons.init = function(main) { if(client_Buttons.settings.isSwapped) { client_Buttons.swapPlayerAndChat(); } - client_Buttons.initSplit(); - client_Buttons.setSplitSize(client_Buttons.settings.chatSize); + var tmp = client_Buttons.split; + if(tmp != null) { + tmp.destroy(); + } + client_Buttons.split = new client_Split(client_Buttons.settings); + client_Buttons.split.setSize(client_Buttons.settings.chatSize); client_Buttons.initChatInputs(main); var _g = 0; var _g1 = client_Buttons.settings.checkboxes; @@ -801,14 +805,14 @@ client_Buttons.init = function(main) { var request = window.fetch("/upload",{ method : "POST", headers : { "content-name" : haxe_io_Path.withoutExtension(name), "client-name" : main.personal.name}, body : buffer}); request.then(function(e) { return e.json().then(function(data) { - haxe_Log.trace(data.info,{ fileName : "src/client/Buttons.hx", lineNumber : 274, className : "client.Buttons", methodName : "init"}); + haxe_Log.trace(data.info,{ fileName : "src/client/Buttons.hx", lineNumber : 276, className : "client.Buttons", methodName : "init"}); if(data.errorId == null) { return; } main.serverMessage(data.info,true,false); }); }).catch(function(err) { - haxe_Log.trace(err,{ fileName : "src/client/Buttons.hx", lineNumber : 279, className : "client.Buttons", methodName : "init"}); + haxe_Log.trace(err,{ fileName : "src/client/Buttons.hx", lineNumber : 281, className : "client.Buttons", methodName : "init"}); return haxe_Timer.delay(function() { main.hideDynamicChin(); },500); @@ -897,29 +901,6 @@ client_Buttons.swapPlayerAndChat = function() { sizes.reverse(); window.document.body.style.gridTemplateColumns = sizes.join(" "); }; -client_Buttons.initSplit = function() { - if(client_Buttons.split != null) { - client_Buttons.split.destroy(); - } - client_Buttons.split = new Split({ columnGutters : [{ element : window.document.querySelector(".gutter"), track : 1}], minSize : 200, snapOffset : 0, onDragEnd : client_Buttons.saveSplitSize}); -}; -client_Buttons.setSplitSize = function(chatSize) { - if(chatSize < 200) { - return; - } - var sizes = window.document.body.style.gridTemplateColumns.split(" "); - sizes[client_Buttons.settings.isSwapped ? 0 : sizes.length - 1] = "" + chatSize + "px"; - window.document.body.style.gridTemplateColumns = sizes.join(" "); -}; -client_Buttons.saveSplitSize = function() { - var sizes = window.document.body.style.gridTemplateColumns.split(" "); - if(client_Buttons.settings.isSwapped) { - sizes.reverse(); - } - var tmp = parseFloat(sizes[sizes.length - 1]); - client_Buttons.settings.chatSize = tmp; - client_Settings.write(client_Buttons.settings); -}; client_Buttons.initTextButtons = function(main) { window.document.querySelector("#synchThresholdBtn").onclick = function(e) { var secs = client_Buttons.settings.synchThreshold + 1; @@ -3321,10 +3302,14 @@ client_Player.prototype = { if(tmp == null) { return; } - if(!this.youtube.isSupportedLink(tmp.url)) { - return; + var itemUrl = tmp.url; + if(!this.youtube.isSupportedLink(itemUrl)) { + itemUrl = StringTools.replace(itemUrl,"/cache/","youtu.be/"); + if(!this.youtube.isSupportedLink(itemUrl)) { + return; + } } - var http = new haxe_http_HttpJs("https://sponsor.ajay.app/api/skipSegments?videoID=" + this.youtube.extractVideoId(tmp.url)); + var http = new haxe_http_HttpJs("https://sponsor.ajay.app/api/skipSegments?videoID=" + this.youtube.extractVideoId(itemUrl)); http.onData = function(text) { var json; try { @@ -3345,7 +3330,7 @@ client_Player.prototype = { } }; http.onError = function(msg) { - haxe_Log.trace(msg,{ fileName : "src/client/Player.hx", lineNumber : 652, className : "client.Player", methodName : "skipAd"}); + haxe_Log.trace(msg,{ fileName : "src/client/Player.hx", lineNumber : 656, className : "client.Player", methodName : "skipAd"}); }; http.request(); } @@ -3443,6 +3428,33 @@ client_Settings.write = function(data) { } client_Settings.storage.setItem("data",JSON.stringify(data)); }; +var client_Split = function(settings) { + this.settings = settings; + this.split = new Split({ columnGutters : [{ element : window.document.querySelector(".gutter"), track : 1}], minSize : 200, snapOffset : 0, onDragEnd : $bind(this,this.saveSize)}); +}; +client_Split.__name__ = true; +client_Split.prototype = { + setSize: function(chatSize) { + if(chatSize < 200) { + return; + } + var sizes = window.document.body.style.gridTemplateColumns.split(" "); + sizes[this.settings.isSwapped ? 0 : sizes.length - 1] = "" + chatSize + "px"; + window.document.body.style.gridTemplateColumns = sizes.join(" "); + } + ,saveSize: function() { + var sizes = window.document.body.style.gridTemplateColumns.split(" "); + if(this.settings.isSwapped) { + sizes.reverse(); + } + var tmp = parseFloat(sizes[sizes.length - 1]); + this.settings.chatSize = tmp; + client_Settings.write(this.settings); + } + ,destroy: function() { + this.split.destroy(); + } +}; var client_Utils = function() { }; client_Utils.__name__ = true; client_Utils.nativeTrace = function(msg,infos) { diff --git a/res/css/des.css b/res/css/des.css index d6cd5ed..f047714 100644 --- a/res/css/des.css +++ b/res/css/des.css @@ -761,6 +761,12 @@ footer#footer { background-color: var(--background-chat); } +@media only screen and (orientation: portrait) { + #swapLayoutBtn { + display: none !important; + } +} + /* Message buffer */ #messagebuffer { diff --git a/res/img/favicon.png b/res/img/favicon.png deleted file mode 100755 index 5d46d1c..0000000 Binary files a/res/img/favicon.png and /dev/null differ diff --git a/res/img/favicon.svg b/res/img/favicon.svg new file mode 100644 index 0000000..ffed1d5 --- /dev/null +++ b/res/img/favicon.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/res/index.html b/res/index.html index 4c06632..dfcbcd8 100644 --- a/res/index.html +++ b/res/index.html @@ -5,8 +5,11 @@ + + + SyncTube - + diff --git a/res/manifest.json b/res/manifest.json new file mode 100644 index 0000000..1bdb671 --- /dev/null +++ b/res/manifest.json @@ -0,0 +1,12 @@ +{ + "name": "SyncTube", + "display": "standalone", + "start_url": "/", + "icons": [ + { + "src": "img/favicon.svg", + "type": "image/svg+xml", + "sizes": "any" + } + ] +} -- cgit v1.2.3