diff options
| -rw-r--r-- | res/client.js | 42 | ||||
| -rw-r--r-- | src/client/Buttons.hx | 22 | ||||
| -rw-r--r-- | src/client/Main.hx | 16 |
3 files changed, 52 insertions, 28 deletions
diff --git a/res/client.js b/res/client.js index 93639f4..949959d 100644 --- a/res/client.js +++ b/res/client.js @@ -717,20 +717,8 @@ client_Buttons.initNavBar = function(main) { client_Buttons.hideMenus(); return; }; - var synchThresholdBtn = window.document.querySelector("#synchThresholdBtn"); - synchThresholdBtn.onclick = function(e4) { - var secs = main.settings.synchThreshold + 1; - if(secs > 5) { - secs = 1; - } - main.setSynchThreshold(secs); - client_Buttons.updateSynchThresholdBtn(main); - synchThresholdBtn.blur(); - return; - }; - synchThresholdBtn.innerText += ": " + main.settings.synchThreshold + "s"; var swapLayoutBtn = window.document.querySelector("#swapLayoutBtn"); - swapLayoutBtn.onclick = function(e5) { + swapLayoutBtn.onclick = function(e4) { var p = window.document.querySelector("#main"); if(window.document.querySelector("#main").firstElementChild == window.document.querySelector("#chatwrap")) { p.appendChild(p.removeChild(p.children[1])); @@ -758,7 +746,7 @@ client_Buttons.initNavBar = function(main) { swapLayoutBtn.onclick(); } var removeBtn = window.document.querySelector("#removeVideoBtn"); - removeBtn.onclick = function(e6) { + removeBtn.onclick = function(e5) { if(main.toggleVideoElement() || main.isListEmpty()) { removeBtn.innerText = Lang.get("removeVideo"); } else { @@ -769,6 +757,20 @@ client_Buttons.initNavBar = function(main) { return; }; }; +client_Buttons.initTextButtons = function(main) { + var synchThresholdBtn = window.document.querySelector("#synchThresholdBtn"); + synchThresholdBtn.onclick = function(e) { + var secs = main.settings.synchThreshold + 1; + if(secs > 5) { + secs = 1; + } + main.setSynchThreshold(secs); + client_Buttons.updateSynchThresholdBtn(main); + synchThresholdBtn.blur(); + return; + }; + client_Buttons.updateSynchThresholdBtn(main); +}; client_Buttons.hideMenus = function() { var menus = window.document.querySelectorAll(".dropdown-menu"); var _g = 0; @@ -940,7 +942,7 @@ var client_Main = function(host,port) { if(port == "") { port = "80"; } - client_Settings.init({ version : 1, name : "", hash : "", isExtendedPlayer : false, chatSize : 40, playerSize : 60, synchThreshold : 2, isSwapped : false, isUserListHidden : false, latestLinks : []}); + client_Settings.init({ version : 1, name : "", hash : "", isExtendedPlayer : false, chatSize : 40, playerSize : 60, synchThreshold : 2, isSwapped : false, isUserListHidden : false, latestLinks : []},$bind(this,this.settingsPatcher)); this.settings = client_Settings.read(); this.initListeners(); this.onTimeGet = new haxe_Timer(this.settings.synchThreshold * 1000); @@ -954,6 +956,7 @@ var client_Main = function(host,port) { return; }; Lang.init("langs",function() { + client_Buttons.initTextButtons(_gthis); _gthis.openWebSocket(host,port); return; }); @@ -963,7 +966,14 @@ client_Main.main = function() { new client_Main(); }; client_Main.prototype = { - requestTime: function() { + settingsPatcher: function(data,version) { + if(version == 1) { + throw new js__$Boot_HaxeError("skipped version " + version); + } else { + throw new js__$Boot_HaxeError("skipped version " + version); + } + } + ,requestTime: function() { if(!this.isSyncActive) { return; } diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx index d4533bf..a04b444 100644 --- a/src/client/Buttons.hx +++ b/src/client/Buttons.hx @@ -249,16 +249,6 @@ class Buttons { exitBtn.blur(); hideMenus(); } - final synchThresholdBtn = ge("#synchThresholdBtn"); - synchThresholdBtn.onclick = e -> { - var secs = main.synchThreshold + 1; - if (secs > 5) secs = 1; - main.setSynchThreshold(secs); - updateSynchThresholdBtn(main); - synchThresholdBtn.blur(); - } - final secs = main.synchThreshold; - synchThresholdBtn.innerText += ': ${secs}s'; final swapLayoutBtn = ge("#swapLayoutBtn"); swapLayoutBtn.onclick = e -> { @@ -295,6 +285,18 @@ class Buttons { } } + public static function initTextButtons(main:Main):Void { + final synchThresholdBtn = ge("#synchThresholdBtn"); + synchThresholdBtn.onclick = e -> { + var secs = main.synchThreshold + 1; + if (secs > 5) secs = 1; + main.setSynchThreshold(secs); + updateSynchThresholdBtn(main); + synchThresholdBtn.blur(); + } + updateSynchThresholdBtn(main); + } + static function hideMenus():Void { final menus:Array<Element> = cast document.querySelectorAll(".dropdown-menu"); for (menu in menus) menu.style.display = ""; diff --git a/src/client/Main.hx b/src/client/Main.hx index 93a1618..3400595 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -22,6 +22,7 @@ using ClientTools; class Main { + static inline var SETTINGS_VERSION = 1; public final settings:ClientSettings; public var isSyncActive = true; public var synchThreshold(get, never):Int; @@ -49,7 +50,7 @@ class Main { if (port == "") port = "80"; final defaults:ClientSettings = { - version: 1, + version: SETTINGS_VERSION, name: "", hash: "", isExtendedPlayer: false, @@ -60,7 +61,7 @@ class Main { isUserListHidden: false, latestLinks: [] } - Settings.init(defaults); + Settings.init(defaults, settingsPatcher); settings = Settings.read(); initListeners(); @@ -74,6 +75,7 @@ class Main { } } Lang.init("langs", () -> { + Buttons.initTextButtons(this); openWebSocket(host, port); }); } @@ -82,6 +84,16 @@ class Main { return settings.synchThreshold; } + function settingsPatcher(data:Any, version:Int):Any { + switch (version) { + // case 1: + // final data:ClientSettings = data; + case SETTINGS_VERSION, _: + throw 'skipped version $version'; + } + return data; + } + function requestTime():Void { if (!isSyncActive) return; if (player.isListEmpty()) return; |
