Remember previous settings

This commit is contained in:
Neale Pickett 2014-10-24 12:29:38 -06:00
parent 3c698cf678
commit 576f7b7bce
2 changed files with 21 additions and 8 deletions

View File

@ -1,6 +1,6 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"version": "1.0.0", "version": "1.0",
"name": "__MSG_appName__", "name": "__MSG_appName__",
"short_name": "__MSG_appShortName__", "short_name": "__MSG_appShortName__",

View File

@ -158,6 +158,9 @@ function addMessage(txt) {
addMessagePart(p, "raw", command + " " + args + " " + msg); addMessagePart(p, "raw", command + " " + args + " " + msg);
break; break;
} }
while (forumElement.childNodes.length > 500) {
forumElement.removeChild(forumElement.firstChild)
}
forumElement.appendChild(p); forumElement.appendChild(p);
p.scrollIntoView(false); p.scrollIntoView(false);
} }
@ -181,13 +184,12 @@ function handleCommand(event) {
var parts = txt.split(" "); var parts = txt.split(" ");
connect(parts[1], parts[2], parts[3]); connect(parts[1], parts[2], parts[3]);
return; } else {
oReq.onload = reqListener;
oReq.open("POST", window.postURL, true);
oReq.send(new FormData(event.target));
} }
oReq.onload = reqListener;
oReq.open("POST", window.postURL, true);
oReq.send(new FormData(event.target));
event.target.reset(); event.target.reset();
return false; return false;
@ -198,12 +200,23 @@ function connect(url, server, authtok) {
document.getElementById("server").value = server; document.getElementById("server").value = server;
document.getElementById("authtok").value = authtok; document.getElementById("authtok").value = authtok;
var pullURL = url + "?server=" + server + "&auth=" + authtok var pullURL = url + "?server=" + server + "&auth=" + authtok
var source = new EventSource(pullURL);
source.onmessage = newmsg; if (window.source != null) {
window.source.close();
}
window.source = new EventSource(pullURL);
window.source.onmessage = newmsg;
chrome.storage.sync.set({"url": url, "server": server, "authtok": authtok});
}
function restore(items) {
connect(items["url"], items["server"], items["authtok"]);
} }
function init() { function init() {
document.getElementById("command").onsubmit = handleCommand; document.getElementById("command").onsubmit = handleCommand;
chrome.storage.sync.get(["url", "server", "authtok"], restore);
} }
window.onload = init; window.onload = init;