2015-01-28 14:35:22 +00:00
|
|
|
var UIEvents = require("../../../service/UI/UIEvents");
|
|
|
|
|
2015-01-22 16:02:37 +00:00
|
|
|
var nickname = null;
|
|
|
|
var eventEmitter = null;
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
var NicknameHandler = {
|
2015-01-22 16:02:37 +00:00
|
|
|
init: function (emitter) {
|
|
|
|
eventEmitter = emitter;
|
|
|
|
var storedDisplayName = window.localStorage.displayname;
|
|
|
|
if (storedDisplayName) {
|
|
|
|
nickname = storedDisplayName;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
setNickname: function (newNickname) {
|
|
|
|
if (!newNickname || nickname === newNickname)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nickname = newNickname;
|
|
|
|
window.localStorage.displayname = nickname;
|
|
|
|
eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newNickname);
|
|
|
|
},
|
|
|
|
getNickname: function () {
|
|
|
|
return nickname;
|
|
|
|
},
|
|
|
|
addListener: function (type, listener) {
|
|
|
|
eventEmitter.on(type, listener);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
module.exports = NicknameHandler;
|