persistence_set/get functions, save the join/part status
This commit is contained in:
parent
e9b3fedb17
commit
2c94713ba0
@ -258,9 +258,7 @@ var submit = function() {
|
|||||||
if (hub_state === 0) {
|
if (hub_state === 0) {
|
||||||
hub_state = 1;
|
hub_state = 1;
|
||||||
|
|
||||||
if (window.localStorage) {
|
persistence_set("login", str);
|
||||||
localStorage["login"] = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
var name_parts = str.split(":", 2);
|
var name_parts = str.split(":", 2);
|
||||||
hub_last_nick = name_parts[0];
|
hub_last_nick = name_parts[0];
|
||||||
@ -594,6 +592,7 @@ var joinparts_getstr = function() {
|
|||||||
var toggle_joinparts = function(ev) {
|
var toggle_joinparts = function(ev) {
|
||||||
var $el = ev.target || ev.srcElement;
|
var $el = ev.target || ev.srcElement;
|
||||||
show_joins = ! show_joins;
|
show_joins = ! show_joins;
|
||||||
|
persistence_set("show_joins", show_joins);
|
||||||
$el.innerHTML = joinparts_getstr();
|
$el.innerHTML = joinparts_getstr();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -609,7 +608,7 @@ var updateTitle = function() {
|
|||||||
var sock = {};
|
var sock = {};
|
||||||
var hub_state = 0; // [disconnected, sent-nick, connected]
|
var hub_state = 0; // [disconnected, sent-nick, connected]
|
||||||
var hub_last_nick = '';
|
var hub_last_nick = '';
|
||||||
var hub_hubname = 'DCWebUI';
|
var hub_hubname = DCWEBUI_CONF.title;
|
||||||
|
|
||||||
var pm_tabs = {}; // nick => tabid
|
var pm_tabs = {}; // nick => tabid
|
||||||
var next_tabid = 1;
|
var next_tabid = 1;
|
||||||
@ -619,15 +618,27 @@ var last_tab = "tab-main";
|
|||||||
|
|
||||||
var show_joins = false;
|
var show_joins = false;
|
||||||
|
|
||||||
|
/* */
|
||||||
|
|
||||||
|
var persistence_set = function(key, value) {
|
||||||
|
if (window.localStorage) {
|
||||||
|
window.localStorage[key] = JSON.stringify(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var persistence_get = function(key, fallback) {
|
||||||
|
try {
|
||||||
|
return JSON.parse( window.localStorage[key] );
|
||||||
|
} catch (ex) {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
write("tab-main").system("Communicating with server...");
|
write("tab-main").system("Communicating with server...");
|
||||||
|
|
||||||
if (window.localStorage) {
|
$("#chatbox").value = persistence_get("login", "");
|
||||||
var saved_login = localStorage["login"];
|
show_joins = persistence_get("show_joins", false);
|
||||||
if (saved_login !== undefined) {
|
|
||||||
$("#chatbox").value = saved_login;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.title = DCWEBUI_CONF.title;
|
document.title = DCWEBUI_CONF.title;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user