diff options
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/Main.hx | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/client/Main.hx b/src/client/Main.hx index f9232eb..dc5a803 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -201,6 +201,8 @@ class Main { final time = player.getTime(); if (Math.abs(time - newTime) < 2) return; player.setTime(newTime); + case Rewind: + player.setTime(data.rewind.time); case SetLeader: clients.setLeader(data.setLeader.clientName); updateUserList(); @@ -366,8 +368,12 @@ class Main { nameDiv.innerHTML = name + ": "; final textDiv = document.createSpanElement(); - for (filter in filters) { - text = filter.regex.replace(text, filter.replace); + if (text.startsWith("/")) { + if (name == personal.name) handleCommands(text.substr(1)); + } else { + for (filter in filters) { + text = filter.regex.replace(text, filter.replace); + } } textDiv.innerHTML = text; @@ -380,7 +386,7 @@ class Main { while (msgBuf.children.length > 200) msgBuf.removeChild(msgBuf.firstChild); msgBuf.scrollTop = msgBuf.scrollHeight; } - if (personal.name == name) { + if (name == personal.name) { msgBuf.scrollTop = msgBuf.scrollHeight; } if (document.hidden && onBlinkTab == null) { @@ -394,6 +400,20 @@ class Main { } } + final matchNumbers = ~/^-?[0-9]+$/; + + function handleCommands(text:String):Void { + switch (text) { + case "clear": + if (isAdmin()) send({type: ClearChat}); + } + if (matchNumbers.match(text)) { + send({type: Rewind, rewind: { + time: Std.parseInt(text) + }}); + } + } + function setLeaderButton(flag:Bool):Void { final leaderBtn = ge("#leader_btn"); if (isLeader()) { |
