client: patch one case of not clearing userlist, set spellcheck attr when in text-entry mode

This commit is contained in:
mappu 2017-02-05 17:28:35 +13:00
parent e15a6afceb
commit 0a5db6a015

View File

@ -294,7 +294,7 @@ var submit = function() {
if (! str.length) return;
if (hub_state === 0) {
hub_state = 1;
transition(1); // disables #chatbox
hub_last_nick = str.split(":", 2)[0];
@ -313,7 +313,6 @@ var submit = function() {
persistence_set("login", hub_pass.length > 0 ? hub_last_nick+":"+hub_pass : hub_last_nick);
sock.emit('hello', {'nick' : hub_last_nick, 'pass' : hub_pass});
$("#chatbox").disabled = true;
write("tab-main").system("Connecting...");
} else if (hub_state === 2) {
@ -685,6 +684,23 @@ var persistence_get = function(key, fallback) {
}
};
var transition = function(new_state) {
hub_state = new_state;
if (new_state === 0) {
userlist.clear();
$("#chatbox").spellcheck = false;
} else if (new_state === 1) {
$("#chatbox").disabled = true;
} else if (new_state === 2) {
$("#chatbox").disabled = false;
$("#chatbox").spellcheck = true;
}
};
window.onload = function() {
write("tab-main").system("Communicating with server...");
@ -749,7 +765,7 @@ window.onload = function() {
sock = io.connect(DCWEBUI_CONF.extern);
sock.on('cls', function() {
hub_state = 0;
transition(0);
var pre_login = persistence_get("login", "");
if (pre_login.indexOf(":") !== -1) {
@ -793,8 +809,7 @@ window.onload = function() {
}
});
sock.on('hello', function() {
hub_state = 2;
$("#chatbox").disabled = false;
transition(2);
});
sock.on('part', function(u) {
userlist.del(u.user);
@ -817,13 +832,11 @@ window.onload = function() {
} catch (ex) {}
});
sock.on('close', function() {
hub_state = 0;
userlist.clear();
transition(0);
write("tab-main").system("Connection closed by remote host.");
});
sock.on('disconnect', function() {
hub_state = 0;
userlist.clear();
transition(0);
write("tab-main").system("Lost connection to the server.");
});
sock.on('usercommand', function(data) {