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