var msgRe = /([^ ]+) (<[^>]+>) (.*)/; var kibozeRe = /[Nn]eal/; var urlRe = /[a-z]+:\/\/[^ ]*/; var nick = "Mme. M"; if (String.prototype.startsWith == null) { String.prototype.startsWith = function(needle) { return this.lastIndexOf(needle, 0) == 0; } } function getTemplate(className) { return templates.getElementsByClassName(className)[0].cloneNode(true); } function isinView(oObject) { return (oObject.offsetParent.clientHeight <= oObject.offsetTop); } function addMessagePart(p, className, text) { var e = document.createElement("span"); e.className = className; e.appendChild(document.createTextNode(text)); p.appendChild(e); p.appendChild(document.createTextNode(" ")); } function focus(e) { var pct = 1; var timeout; selectForum(e.parentNode); e.scrollIntoView(false); e.style.backgroundColor = "yellow"; timeout = setInterval(function() { pct = pct - 0.1; e.style.backgroundColor = "rgba(255, 255, 0, " + pct + ")"; if (pct <= 0) { e.style.backgroundColor = "inherit"; clearInterval(timeout); } }, 50) } function handleInput(oEvent) { console.log(oEvent); var txt = oEvent.target.value; if (txt.startsWith("/connect ")) { var parts = txt.split(" "); var url = parts[1]; var authtok = parts.slice(2).join(" "); console.log(url) console.log(authtok) networkConnect(url, authtok); storedConnections = [[url, authtok]]; chrome.storage.sync.set({"connections": storedConnections}); } else { visibleRoom.send(txt); } oEvent.target.value = ""; return false; } function hideChannels(oEvent) { var lhs = document.getElementById("rooms-and-nicks"); if (lhs.classList.contains("hidden")) { lhs.classList.remove("hidden"); } else { lhs.classList.add("hidden"); } } function keyPress(oEvent) { document.getElementById("input").focus(); if (oEvent.keyIdentifier == "Enter") { handleInput(oEvent); } } function restore(items) { storedConnections = items["connections"]; for (var i in storedConnections) { var conn = storedConnections[i]; networkConnect(conn[0], conn[1]); } } function init() { chrome.storage.sync.get(["connections"], restore); //document.getElementById("input").addEventListener("change", handleInput); document.getElementById("hide-channels").addEventListener("click", hideChannels); window.addEventListener("keypress", keyPress); templates = document.getElementById("templates"); rooms = document.getElementById("rooms-container").getElementsByClassName("rooms")[0]; } window.addEventListener("load", init);