aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-03-02 14:29:03 +0300
committerRblSb <msrblsb@gmail.com>2020-03-02 14:29:03 +0300
commitb239467d9917849a746f2026c7f0b185a6341914 (patch)
treea17a39506d8e8720fced122bca924d8fd6dc9956 /res
parent0d36998b0fb8139456bf1eda3f614542fec890c5 (diff)
Synch threshold setting
Diffstat (limited to 'res')
-rw-r--r--res/client.js57
-rw-r--r--res/index.html7
-rw-r--r--res/langs/en.json1
-rw-r--r--res/langs/ru.json1
4 files changed, 47 insertions, 19 deletions
diff --git a/res/client.js b/res/client.js
index 6fcc740..37f4207 100644
--- a/res/client.js
+++ b/res/client.js
@@ -594,8 +594,20 @@ client_Buttons.initNavBar = function(main) {
client_Buttons.hideMenus();
return;
};
+ var synchThresholdBtn = window.document.querySelector("#synchThresholdBtn");
+ synchThresholdBtn.onclick = function(e3) {
+ var secs = main.synchThreshold + 1;
+ if(secs > 5) {
+ secs = 1;
+ }
+ main.setSynchThreshold(secs);
+ client_Buttons.updateSynchThresholdBtn(main);
+ synchThresholdBtn.blur();
+ return;
+ };
+ synchThresholdBtn.innerText += ": " + main.synchThreshold + "s";
var swapLayoutBtn = window.document.querySelector("#swapLayoutBtn");
- swapLayoutBtn.onclick = function(e3) {
+ swapLayoutBtn.onclick = function(e4) {
var p = window.document.querySelector("#main");
p.insertBefore(p.children[2],p.children[0]);
p.insertBefore(p.children[2],p.children[1]);
@@ -609,7 +621,7 @@ client_Buttons.initNavBar = function(main) {
return;
};
var removeBtn = window.document.querySelector("#removeVideoBtn");
- removeBtn.onclick = function(e4) {
+ removeBtn.onclick = function(e5) {
if(main.toggleVideoElement()) {
removeBtn.innerText = Lang.get("removeVideo");
} else {
@@ -625,6 +637,10 @@ client_Buttons.hideMenus = function() {
var _g = 0;
while(_g < menus.length) menus[_g++].style.display = "";
};
+client_Buttons.updateSynchThresholdBtn = function(main) {
+ var tmp = "" + Lang.get("synchThreshold") + ": " + main.synchThreshold;
+ window.document.querySelector("#synchThresholdBtn").innerText = tmp + "s";
+};
client_Buttons.initChatInput = function(main) {
var guestName = window.document.querySelector("#guestname");
guestName.onkeydown = function(e) {
@@ -691,6 +707,7 @@ var client_Main = function(host,port) {
this.globalIp = "";
this.pageTitle = window.document.title;
this.clients = [];
+ this.synchThreshold = 2;
this.isSyncActive = true;
var _gthis = this;
this.player = new client_Player(this);
@@ -708,16 +725,7 @@ var client_Main = function(host,port) {
port = "80";
}
this.initListeners();
- this.onTimeGet.run = function() {
- if(!_gthis.isSyncActive) {
- return;
- }
- if(_gthis.player.isListEmpty()) {
- return;
- }
- _gthis.send({ type : "GetTime"});
- return;
- };
+ this.onTimeGet.run = $bind(this,this.requestTime);
window.document.onvisibilitychange = function() {
if(!window.document.hidden && _gthis.onBlinkTab != null) {
window.document.title = _gthis.getPageTitle();
@@ -736,7 +744,16 @@ client_Main.main = function() {
new client_Main();
};
client_Main.prototype = {
- openWebSocket: function(host,port) {
+ requestTime: function() {
+ if(!this.isSyncActive) {
+ return;
+ }
+ if(this.player.isListEmpty()) {
+ return;
+ }
+ this.send({ type : "GetTime"});
+ }
+ ,openWebSocket: function(host,port) {
var _gthis = this;
this.ws = new WebSocket("ws://" + host + ":" + port);
this.ws.onmessage = $bind(this,this.onMessage);
@@ -869,7 +886,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 : 214, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]});
+ haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 217, className : "client.Main", methodName : "onMessage", customParams : [data[t1]]});
switch(data.type) {
case "AddVideo":
this.player.addVideoItem(data.addVideo.item,data.addVideo.atEnd);
@@ -894,7 +911,7 @@ client_Main.prototype = {
var newTime = data.getTime.time;
var time = this.player.getTime();
if((this.personal.group & 1 << ClientGroup.Leader._hx_index) != 0) {
- if(Math.abs(time - newTime) < 2) {
+ if(Math.abs(time - newTime) < this.synchThreshold) {
return;
}
this.player.setTime(time,false);
@@ -905,7 +922,7 @@ client_Main.prototype = {
} else {
this.player.pause();
}
- if(Math.abs(time - newTime) < 2) {
+ if(Math.abs(time - newTime) < this.synchThreshold) {
return;
}
this.player.setTime(newTime);
@@ -969,7 +986,7 @@ client_Main.prototype = {
case "SetTime":
var newTime1 = data.setTime.time;
var time1 = this.player.getTime();
- if(Math.abs(time1 - newTime1) < 2) {
+ if(Math.abs(time1 - newTime1) < this.synchThreshold) {
return;
}
this.player.setTime(newTime1);
@@ -1271,6 +1288,12 @@ client_Main.prototype = {
icon.classList.remove("glyphicon-ok");
}
}
+ ,setSynchThreshold: function(s) {
+ this.synchThreshold = s;
+ this.onTimeGet.stop();
+ this.onTimeGet = new haxe_Timer(s * 1000);
+ this.onTimeGet.run = $bind(this,this.requestTime);
+ }
,escapeRegExp: function(regex) {
var _this_r = new RegExp("([.*+?^${}()|[\\]\\\\])","g".split("u").join(""));
return regex.replace(_this_r,"\\$1");
diff --git a/res/index.html b/res/index.html
index c3bcde5..773dca6 100644
--- a/res/index.html
+++ b/res/index.html
@@ -36,8 +36,11 @@
<li><a id="exitBtn" href="#">${login}</a></li>
</ul>
</li>
- <li><a href="javascript:void(0)">${settings}</a></li>
- <!-- <li><a id="showchansettings" href="javascript:void(0)">${channel}</a></li> -->
+ <li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">${settings}<b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ <li><a href="#" id="synchThresholdBtn">${synchThreshold}</a></li>
+ </ul>
+ </li>
<li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">${layout}<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#" id="swapLayoutBtn">${swapLayout}</a></li>
diff --git a/res/langs/en.json b/res/langs/en.json
index dfd018d..e8845ec 100644
--- a/res/langs/en.json
+++ b/res/langs/en.json
@@ -21,6 +21,7 @@
"login": "Login",
"exit": "Exit",
"settings": "Settings",
+ "synchThreshold": "Synch Threshold",
"channel": "Channel",
"layout": "Layout",
"swapLayout": "Swap Layout",
diff --git a/res/langs/ru.json b/res/langs/ru.json
index 30b6e7a..c768be4 100644
--- a/res/langs/ru.json
+++ b/res/langs/ru.json
@@ -21,6 +21,7 @@
"login": "Войти",
"exit": "Выход",
"settings": "Настройки",
+ "synchThreshold": "Частота синхронизации",
"channel": "Канал",
"layout": "Разметка",
"swapLayout": "Сменить разметку",
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage