aboutsummaryrefslogtreecommitdiffstats
path: root/build/client.js
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-02-22 07:26:52 +0300
committerRblSb <msrblsb@gmail.com>2020-02-22 07:26:52 +0300
commit9fda2015a00b21911ef031cc5bfb0ea2e27d3d7f (patch)
treeef540016f3e0391c19e3f9dc1afd3776baa388e1 /build/client.js
parent08d068181045f91f0aa160f9b088a18048b948ec (diff)
Rewind command
Diffstat (limited to 'build/client.js')
-rw-r--r--build/client.js48
1 files changed, 41 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) {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage