diff options
| author | RblSb <msrblsb@gmail.com> | 2020-02-22 07:26:52 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-02-22 07:26:52 +0300 |
| commit | 9fda2015a00b21911ef031cc5bfb0ea2e27d3d7f (patch) | |
| tree | ef540016f3e0391c19e3f9dc1afd3776baa388e1 /build | |
| parent | 08d068181045f91f0aa160f9b088a18048b948ec (diff) | |
Rewind command
Diffstat (limited to 'build')
| -rw-r--r-- | build/client.js | 48 | ||||
| -rw-r--r-- | build/server.js | 11 |
2 files changed, 52 insertions, 7 deletions
diff --git a/build/client.js b/build/client.js index 3c9515c..8d796a3 100644 --- a/build/client.js +++ b/build/client.js @@ -259,6 +259,25 @@ Std.__name__ = true; Std.string = function(s) { return js_Boot.__string_rec(s,""); }; +Std.parseInt = function(x) { + if(x != null) { + var _g = 0; + var _g1 = x.length; + while(_g < _g1) { + var i = _g++; + var c = x.charCodeAt(i); + if(c <= 8 || c >= 14 && c != 32 && c != 45) { + var v = parseInt(x, (x[(i + 1)]=="x" || x[(i + 1)]=="X") ? 16 : 10); + if(isNaN(v)) { + return null; + } else { + return v; + } + } + } + } + return null; +}; var StringTools = function() { }; StringTools.__name__ = true; StringTools.startsWith = function(s,start) { @@ -410,6 +429,7 @@ var client_Main = function(host,port) { if(port == null) { port = 4201; } + this.matchNumbers = new EReg("^-?[0-9]+$",""); this.onTimeGet = new haxe_Timer(2000); this.isConnected = false; this.personal = new Client(null,null,"Unknown",0); @@ -603,6 +623,9 @@ client_Main.prototype = { this.player.pause(); } break; + case "Rewind": + this.player.setTime(data.rewind.time); + break; case "SetLeader": ClientTools.setLeader(this.clients,data.setLeader.clientName); this.updateUserList(); @@ -790,12 +813,18 @@ client_Main.prototype = { nameDiv.className = "username"; nameDiv.innerHTML = name + ": "; var textDiv = window.document.createElement("span"); - var _g = 0; - var _g1 = this.filters; - while(_g < _g1.length) { - var filter = _g1[_g]; - ++_g; - text = text.replace(filter.regex.r,filter.replace); + if(StringTools.startsWith(text,"/")) { + if(name == this.personal.name) { + this.handleCommands(HxOverrides.substr(text,1,null)); + } + } else { + var _g = 0; + var _g1 = this.filters; + while(_g < _g1.length) { + var filter = _g1[_g]; + ++_g; + text = text.replace(filter.regex.r,filter.replace); + } } textDiv.innerHTML = text; var isInChatEnd = msgBuf.scrollHeight - msgBuf.scrollTop == msgBuf.clientHeight; @@ -807,7 +836,7 @@ client_Main.prototype = { while(msgBuf.children.length > 200) msgBuf.removeChild(msgBuf.firstChild); msgBuf.scrollTop = msgBuf.scrollHeight; } - if(this.personal.name == name) { + if(name == this.personal.name) { msgBuf.scrollTop = msgBuf.scrollHeight; } if(window.document.hidden && this.onBlinkTab == null) { @@ -822,6 +851,11 @@ client_Main.prototype = { this.onBlinkTab.run(); } } + ,handleCommands: function(text) { + if(this.matchNumbers.match(text)) { + this.send({ type : "Rewind", rewind : { time : Std.parseInt(text)}}); + } + } ,setLeaderButton: function(flag) { var leaderBtn = window.document.querySelector("#leader_btn"); if((this.personal.group & 2) != 0) { diff --git a/build/server.js b/build/server.js index 6c35793..611ca9c 100644 --- a/build/server.js +++ b/build/server.js @@ -794,6 +794,17 @@ server_Main.prototype = { })); this.broadcast(data); break; + case "Rewind": + if(this.videoList.length == 0) { + return; + } + data.rewind.time += this.videoTimer.getTime(); + if(data.rewind.time < 0) { + data.rewind.time = 0; + } + this.videoTimer.setTime(data.rewind.time); + this.broadcast(data); + break; case "SetLeader": ClientTools.setLeader(this.clients,data.setLeader.clientName); this.broadcast({ type : "SetLeader", setLeader : { clientName : data.setLeader.clientName}}); |
