diff options
| author | RblSb <msrblsb@gmail.com> | 2020-05-01 10:10:33 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-05-01 10:10:33 +0300 |
| commit | 7408555ad16b5d0e380d1d90eb62e64eb14987f1 (patch) | |
| tree | d9a5e87c543a4f52549f8fcb0e6da48115dfbc40 /src | |
| parent | bea88e624b4c271d583c73607be0f37e1498f671 (diff) | |
Minor changes
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/Buttons.hx | 22 | ||||
| -rw-r--r-- | src/client/Main.hx | 16 |
2 files changed, 26 insertions, 12 deletions
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; |
