mirror of
https://github.com/exane/not-gwent-online
synced 2024-11-20 11:26:54 +00:00
limit user name to 20 chars
This commit is contained in:
parent
b9daf667c3
commit
41ac09c59c
@ -705,7 +705,7 @@ let ChooseSideModal = Modal.extend({
|
|||||||
|
|
||||||
let User = Backbone.Model.extend({
|
let User = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
name: localStorage["userName"] || null,
|
name: typeof localStorage["userName"] === "string" ? localStorage["userName"].slice(0, 20) : null,
|
||||||
deck: localStorage["userDeck"] || "random",
|
deck: localStorage["userDeck"] || "random",
|
||||||
serverOffline: true
|
serverOffline: true
|
||||||
},
|
},
|
||||||
@ -834,6 +834,7 @@ let User = Backbone.Model.extend({
|
|||||||
//app.socket.subscribe(room);
|
//app.socket.subscribe(room);
|
||||||
},
|
},
|
||||||
setName: function(name){
|
setName: function(name){
|
||||||
|
name = name.slice(0, 20);
|
||||||
this.get("app").send("request:name", {name: name});
|
this.get("app").send("request:name", {name: name});
|
||||||
localStorage["userName"] = name;
|
localStorage["userName"] = name;
|
||||||
},
|
},
|
||||||
@ -916,6 +917,7 @@ let Lobby = Backbone.View.extend({
|
|||||||
/*let val = $(e.target).val();
|
/*let val = $(e.target).val();
|
||||||
this.app.trigger("setDeck", val);
|
this.app.trigger("setDeck", val);
|
||||||
this.$el.find("#deckChoice option[value='" + val + "']").attr("selected", "selected")*/
|
this.$el.find("#deckChoice option[value='" + val + "']").attr("selected", "selected")*/
|
||||||
|
|
||||||
localStorage["userName"] = this.app.user.get("name");
|
localStorage["userName"] = this.app.user.get("name");
|
||||||
/*this.render();*/
|
/*this.render();*/
|
||||||
this.$el.find(".name-input").val(this.app.user.get("name"));
|
this.$el.find(".name-input").val(this.app.user.get("name"));
|
||||||
|
@ -51,6 +51,7 @@ var User = (function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.setName = function(name) {
|
r.setName = function(name) {
|
||||||
|
name = name.slice(0, 20);
|
||||||
console.log("user name changed from %s to %s", this._name, name);
|
console.log("user name changed from %s to %s", this._name, name);
|
||||||
this._name = name;
|
this._name = name;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user