Namechanges

This commit is contained in:
Kasper Rynning-Tønnesen
2015-12-18 12:18:15 +01:00
parent 09ead1db67
commit 8c137d1b04
3 changed files with 22 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@@ -4,7 +4,10 @@ var Chat = {
{ {
if(data.value.length > 150) if(data.value.length > 150)
return; return;
if($(".tab a.active").attr("href") == "#all_chat") if(data.value.startsWith("/name ")){
socket.emit("namechange", data.value.substring(6));
}
else if($(".tab a.active").attr("href") == "#all_chat")
socket.emit("all,chat", data.value); socket.emit("all,chat", data.value);
else else
socket.emit("chat", data.value); socket.emit("chat", data.value);

View File

@@ -168,16 +168,22 @@ var Helper = {
return "#" + Helper.componentToHex(r) + Helper.componentToHex(g) + Helper.componentToHex(b); return "#" + Helper.componentToHex(r) + Helper.componentToHex(g) + Helper.componentToHex(b);
} }
} }
Element.prototype.remove = function() { Element.prototype.remove = function() {
this.parentElement.removeChild(this); this.parentElement.removeChild(this);
} }
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() { NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
for(var i = 0, len = this.length; i < len; i++) { for(var i = 0, len = this.length; i < len; i++) {
if(this[i] && this[i].parentElement) { if(this[i] && this[i].parentElement) {
this[i].parentElement.removeChild(this[i]); this[i].parentElement.removeChild(this[i]);
} }
} }
} }
String.prototype.startsWith = function(searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
}