Hacked into submission
This commit is contained in:
parent
9303e6f8e5
commit
c96208d569
|
@ -3,8 +3,9 @@
|
||||||
var maxScrollback = 500;
|
var maxScrollback = 500;
|
||||||
var networks = {};
|
var networks = {};
|
||||||
|
|
||||||
function networkConnect(network, baseURL, authtok) {
|
function networkConnect(baseURL, authtok) {
|
||||||
var eventSource;
|
var eventSource;
|
||||||
|
var network = "server"; // XXX: remove this kludge!
|
||||||
var element = getTemplate("server-channels");
|
var element = getTemplate("server-channels");
|
||||||
var channels = element.getElementsByClassName("channels")[0];
|
var channels = element.getElementsByClassName("channels")[0];
|
||||||
var roomElement = element.getElementsByClassName("server")[0];
|
var roomElement = element.getElementsByClassName("server")[0];
|
||||||
|
@ -68,8 +69,8 @@ function networkConnect(network, baseURL, authtok) {
|
||||||
|
|
||||||
var form = new FormData();
|
var form = new FormData();
|
||||||
form.append("type", "command");
|
form.append("type", "command");
|
||||||
|
form.append("network", "slashnet");
|
||||||
form.append("auth", authtok);
|
form.append("auth", authtok);
|
||||||
form.append("network", network);
|
|
||||||
form.append("target", target);
|
form.append("target", target);
|
||||||
form.append("text", text);
|
form.append("text", text);
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ function networkConnect(network, baseURL, authtok) {
|
||||||
}
|
}
|
||||||
networks[network] = element;
|
networks[network] = element;
|
||||||
|
|
||||||
var pullURL = baseURL + "?network=" + encodeURIComponent(network) + "&auth=" + encodeURIComponent(authtok);
|
var pullURL = baseURL + "?auth=" + encodeURIComponent(authtok);
|
||||||
eventSource = new EventSource(pullURL);
|
eventSource = new EventSource(pullURL);
|
||||||
eventSource.addEventListener("message", handleEventSourceMessage);
|
eventSource.addEventListener("message", handleEventSourceMessage);
|
||||||
eventSource.addEventListener("error", handleEventSourceError);
|
eventSource.addEventListener("error", handleEventSourceError);
|
||||||
|
|
6
room.js
6
room.js
|
@ -141,11 +141,13 @@ function newRoom(element, network, name, maxSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
element.close = function() {
|
element.close = function() {
|
||||||
console.log(messages);
|
if (messages.parent) {
|
||||||
console.log(messages.parent);
|
|
||||||
messages.parent.removeChild(messages);
|
messages.parent.removeChild(messages);
|
||||||
|
}
|
||||||
|
if (element.parent) {
|
||||||
element.parent.removeChild(element);
|
element.parent.removeChild(element);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function clicked() {
|
function clicked() {
|
||||||
element.show();
|
element.show();
|
||||||
|
|
18
wirc.js
18
wirc.js
|
@ -48,14 +48,14 @@ function handleInput(oEvent) {
|
||||||
console.log(oEvent);
|
console.log(oEvent);
|
||||||
var txt = oEvent.target.value;
|
var txt = oEvent.target.value;
|
||||||
if (txt.startsWith("/connect ")) {
|
if (txt.startsWith("/connect ")) {
|
||||||
// XXX: should allow tokens with spaces
|
|
||||||
var parts = txt.split(" ");
|
var parts = txt.split(" ");
|
||||||
var network = parts[1];
|
var url = parts[1];
|
||||||
var url = parts[2];
|
var authtok = parts.slice(2).join(" ");
|
||||||
var authtok = parts[3];
|
console.log(url)
|
||||||
|
console.log(authtok)
|
||||||
|
|
||||||
networkConnect(network, url, authtok);
|
networkConnect(url, authtok);
|
||||||
storedConnections[network] = [url, authtok];
|
storedConnections = [[url, authtok]];
|
||||||
chrome.storage.sync.set({"connections": storedConnections});
|
chrome.storage.sync.set({"connections": storedConnections});
|
||||||
} else {
|
} else {
|
||||||
visibleRoom.send(txt);
|
visibleRoom.send(txt);
|
||||||
|
@ -86,10 +86,10 @@ function keyPress(oEvent) {
|
||||||
function restore(items) {
|
function restore(items) {
|
||||||
storedConnections = items["connections"];
|
storedConnections = items["connections"];
|
||||||
|
|
||||||
for (var network in storedConnections) {
|
for (var i in storedConnections) {
|
||||||
var conn = storedConnections[network];
|
var conn = storedConnections[i];
|
||||||
|
|
||||||
networkConnect(network, conn[0], conn[1]);
|
networkConnect(conn[0], conn[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue