diff options
| author | RblSb <msrblsb@gmail.com> | 2020-04-06 21:47:29 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-04-06 21:47:29 +0300 |
| commit | 4c955af4c4be0d3c1d002a867c89166811373a9f (patch) | |
| tree | 06f7e23824b976f5c7b5907fa64e06321f1810d0 | |
| parent | bda198c729ba65905bc34d15b44eb51f8336a8ff (diff) | |
Skip item confirmation for touch
| -rw-r--r-- | res/client.js | 11 | ||||
| -rw-r--r-- | res/langs/en.json | 1 | ||||
| -rw-r--r-- | res/langs/ru.json | 1 | ||||
| -rw-r--r-- | src/client/Buttons.hx | 3 | ||||
| -rw-r--r-- | src/client/Main.hx | 1 | ||||
| -rw-r--r-- | src/client/Utils.hx | 4 |
6 files changed, 16 insertions, 5 deletions
diff --git a/res/client.js b/res/client.js index 32eb424..68064e2 100644 --- a/res/client.js +++ b/res/client.js @@ -648,8 +648,7 @@ client_Buttons.onVideoResize = function() { window.document.querySelector("#userlist").style.height = "" + height + "px"; }; client_Buttons.onClick = function(el,func) { - var isTouch = 'ontouchstart' in window; - if(!isTouch) { + if(!client_Utils.isTouch()) { el.onclick = func; } else { el.ontouchend = func; @@ -907,6 +906,9 @@ client_Main.prototype = { return; }; window.document.querySelector("#voteskip").onclick = function(e1) { + if(client_Utils.isTouch() && !window.confirm(Lang.get("skipItemConfirm"))) { + return; + } if(_gthis.player.isListEmpty()) { return; } @@ -1070,7 +1072,7 @@ client_Main.prototype = { var data = JSON.parse(e.data); var t = data.type; var t1 = t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null); - haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 299, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]}); + haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 300, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]}); switch(data.type) { case "AddVideo": this.player.addVideoItem(data.addVideo.item,data.addVideo.atEnd); @@ -1931,6 +1933,9 @@ client_Settings.write = function(data) { }; var client_Utils = function() { }; client_Utils.__name__ = true; +client_Utils.isTouch = function() { + return 'ontouchstart' in window; +}; client_Utils.prepend = function(parent,child) { if(parent.firstChild == null) { parent.appendChild(child); diff --git a/res/langs/en.json b/res/langs/en.json index 955d0c2..3524b15 100644 --- a/res/langs/en.json +++ b/res/langs/en.json @@ -67,6 +67,7 @@ "acceptableEmbedCodesAre": "Acceptable embed codes are", "customEmbedsCannotBeSynchronized": "CUSTOM EMBEDS CANNOT BE SYNCHRONIZED", "save": "Save", + "skipItemConfirm": "Are you sure you want to skip current video?", "clearPlaylistConfirm": "Are you sure you want to clear the playlist?", "shufflePlaylistConfirm": "Are you sure you want to shuffle the playlist?", diff --git a/res/langs/ru.json b/res/langs/ru.json index 6e6b15e..8297c36 100644 --- a/res/langs/ru.json +++ b/res/langs/ru.json @@ -67,6 +67,7 @@ "acceptableEmbedCodesAre": "Можно добавить видео с тегами", "customEmbedsCannotBeSynchronized": "СИНХРОНИЗАЦИЯ БУДЕТ НЕДОСТУПНА", "save": "Сохранить", + "skipItemConfirm": "Вы уверены что хотите пропустить текущее видео?", "clearPlaylistConfirm": "Вы уверены что хотите очистить плейлист?", "shufflePlaylistConfirm": "Вы уверены что хотите перемешать плейлист?", diff --git a/src/client/Buttons.hx b/src/client/Buttons.hx index 63934e2..2d32d99 100644 --- a/src/client/Buttons.hx +++ b/src/client/Buttons.hx @@ -210,8 +210,7 @@ class Buttons { } static function onClick(el:Element, func:Any->Void):Void { - final isTouch = untyped __js__("'ontouchstart' in window"); - if (!isTouch) el.onclick = func; + if (!Utils.isTouch()) el.onclick = func; else el.ontouchend = func; } diff --git a/src/client/Main.hx b/src/client/Main.hx index 6c7677b..e5cd58b 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -122,6 +122,7 @@ class Main { } final voteSkip = ge("#voteskip"); voteSkip.onclick = e -> { + if (Utils.isTouch() && !Browser.window.confirm(Lang.get("skipItemConfirm"))) return; if (player.isListEmpty()) return; final items = player.getItems(); final pos = player.getItemPos(); diff --git a/src/client/Utils.hx b/src/client/Utils.hx index 69671d2..3ac9953 100644 --- a/src/client/Utils.hx +++ b/src/client/Utils.hx @@ -6,6 +6,10 @@ import js.Browser.window; class Utils { + public static function isTouch():Bool { + return js.Syntax.code("'ontouchstart' in window"); + } + public static function prepend(parent:Element, child:Element):Void { if (parent.firstChild == null) parent.appendChild(child); else parent.insertBefore(child, parent.firstChild); |
