From 0d36998b0fb8139456bf1eda3f614542fec890c5 Mon Sep 17 00:00:00 2001 From: RblSb Date: Mon, 2 Mar 2020 13:50:16 +0300 Subject: Video sync toggler --- res/client.js | 48 +++++++++++++++++++++++++++++++++++++++--------- res/css/des.css | 3 +++ res/langs/en.json | 3 +++ res/langs/ru.json | 3 +++ 4 files changed, 48 insertions(+), 9 deletions(-) (limited to 'res') diff --git a/res/client.js b/res/client.js index e4c084c..6fcc740 100644 --- a/res/client.js +++ b/res/client.js @@ -459,9 +459,23 @@ client_Buttons.init = function(main) { extendPlayer.classList.toggle("active"); return window.dispatchEvent(new Event("resize")); }; - window.document.querySelector("#togglesynch").onclick = function(e5) { - if(!window.confirm(Lang.get("toggleSynchConfirm"))) { - return; + var toggleSynch = window.document.querySelector("#togglesynch"); + toggleSynch.onclick = function(e5) { + var icon = toggleSynch.firstElementChild; + if(main.isSyncActive) { + if(!window.confirm(Lang.get("toggleSynchConfirm"))) { + return; + } + main.isSyncActive = false; + icon.style.color = "rgba(238, 72, 67, 0.75)"; + icon.classList.add("glyphicon-pause"); + icon.classList.remove("glyphicon-play"); + } else { + main.isSyncActive = true; + icon.style.color = ""; + icon.classList.add("glyphicon-play"); + icon.classList.remove("glyphicon-pause"); + main.send({ type : "UpdatePlaylist"}); } return; }; @@ -475,12 +489,12 @@ client_Buttons.init = function(main) { var getPlaylist = window.document.querySelector("#getplaylist"); getPlaylist.onclick = function(e8) { client_Utils.copyToClipboard(main.getPlaylistLinks().join(",")); - var icon = getPlaylist.firstElementChild; - icon.classList.remove("glyphicon-link"); - icon.classList.add("glyphicon-ok"); + var icon1 = getPlaylist.firstElementChild; + icon1.classList.remove("glyphicon-link"); + icon1.classList.add("glyphicon-ok"); return haxe_Timer.delay(function() { - icon.classList.add("glyphicon-link"); - icon.classList.remove("glyphicon-ok"); + icon1.classList.add("glyphicon-link"); + icon1.classList.remove("glyphicon-ok"); return; },2000); }; @@ -677,6 +691,7 @@ var client_Main = function(host,port) { this.globalIp = ""; this.pageTitle = window.document.title; this.clients = []; + this.isSyncActive = true; var _gthis = this; this.player = new client_Player(this); if(host == null) { @@ -694,6 +709,9 @@ var client_Main = function(host,port) { } this.initListeners(); this.onTimeGet.run = function() { + if(!_gthis.isSyncActive) { + return; + } if(_gthis.player.isListEmpty()) { return; } @@ -851,7 +869,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 : 212, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]}); + haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 214, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]}); switch(data.type) { case "AddVideo": this.player.addVideoItem(data.addVideo.item,data.addVideo.atEnd); @@ -1336,6 +1354,9 @@ client_Player.prototype = { } } ,setVideo: function(i) { + if(!this.main.isSyncActive) { + return; + } var item = this.items[i]; if(client_players_Youtube.isYoutube(item.url)) { this.setPlayer(new client_players_Youtube(this.main,this)); @@ -1527,12 +1548,18 @@ client_Player.prototype = { return this.player != null; } ,play: function() { + if(!this.main.isSyncActive) { + return; + } if(this.player == null) { return; } this.player.play(); } ,pause: function() { + if(!this.main.isSyncActive) { + return; + } if(this.player == null) { return; } @@ -1548,6 +1575,9 @@ client_Player.prototype = { if(isLocal == null) { isLocal = true; } + if(!this.main.isSyncActive) { + return; + } if(this.player == null) { return; } diff --git a/res/css/des.css b/res/css/des.css index 818a174..b04528f 100644 --- a/res/css/des.css +++ b/res/css/des.css @@ -158,6 +158,9 @@ src:url('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/fonts/gl .glyphicon-play:before { content:"\e072" } +.glyphicon-pause:before { + content:"\e073" +} .glyphicon-star-empty:before { content:"\e007" } diff --git a/res/langs/en.json b/res/langs/en.json index 50f12b4..dfd018d 100644 --- a/res/langs/en.json +++ b/res/langs/en.json @@ -32,6 +32,8 @@ "leader": "Leader", "enterAsGuest": "Enter As Guest", "yourName": "Your Name", + "enterUserPassword": "Enter User Password", + "yourPassword": "Your Password", "emotes": "Emotes", "clearChat": "Clear Chat", "addVideoFromUrl": "Add video from URL", @@ -42,6 +44,7 @@ "playlistLocked": "Playlist locked", "expandPlayer": "Expand player", "toggleVideoSync": "Toggle video synchronization", + "toggleSynchConfirm": "Are you sure you want to turn off video sync?", "refreshPlayer": "Refresh player", "fullscreenPlayer": "Fullscreen player", "retrievePlaylistLinks": "Retrieve playlist links", diff --git a/res/langs/ru.json b/res/langs/ru.json index 3d632af..30b6e7a 100644 --- a/res/langs/ru.json +++ b/res/langs/ru.json @@ -32,6 +32,8 @@ "leader": "Лидер", "enterAsGuest": "Войти как гость:", "yourName": "Ваш ник", + "enterUserPassword": "Введите пароль пользователя", + "yourPassword": "Ваш пароль", "emotes": "Смайлы", "clearChat": "Очистить", "addVideoFromUrl": "Добавить видео по ссылке", @@ -42,6 +44,7 @@ "playlistLocked": "Плейлист заблокирован", "expandPlayer": "Расширить плеер", "toggleVideoSync": "Переключить синхронизацию видео", + "toggleSynchConfirm": "Вы уверены что хотите отключить синхронизацию видео?", "refreshPlayer": "Обновить плеер", "fullscreenPlayer": "Полноэкранный режим видео", "retrievePlaylistLinks": "Получить ссылки на видео из плейлиста", -- cgit v1.2.3