diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json new file mode 100644 index 0000000..c0c2c24 --- /dev/null +++ b/app/_locales/en/messages.json @@ -0,0 +1,15 @@ +{ + "appName": { + "message": "wIRC Chat Client", + "description": "Application name" + }, + "appShortName": { + "message": "wIRC", + "description": "Short application name" + }, + "appDesc": { + "message": "Chat client for the wIRC bouncer thingamajiggy", + "description": "Application description for app store listing" + } +} + diff --git a/app/background.js b/app/background.js new file mode 100644 index 0000000..31c2421 --- /dev/null +++ b/app/background.js @@ -0,0 +1,5 @@ +chrome.app.runtime.onLaunched.addListener(function() { + chrome.app.window.create('wirc.html', { + 'state': 'normal' + }) +}) diff --git a/app/manifest.json b/app/manifest.json new file mode 100644 index 0000000..e29cd47 --- /dev/null +++ b/app/manifest.json @@ -0,0 +1,21 @@ +{ + "manifest_version": 2, + "version": "1.0.0", + + "name": "__MSG_appName__", + "short_name": "__MSG_appShortName__", + "description": "__MSG_appDesc__", + "author": "Neale Pickett ", + "icons": {"128": "wirc.png"}, + "app": { + "background": { + "scripts": ["background.js"] + } + }, + "permissions": [ + "storage", + "fileSystem", + "https://woozle.org/" + ], + "default_locale": "en" +} diff --git a/wirc.css b/app/wirc.css similarity index 100% rename from wirc.css rename to app/wirc.css diff --git a/index.html b/app/wirc.html similarity index 68% rename from index.html rename to app/wirc.html index 51912bf..62cd9e5 100644 --- a/index.html +++ b/app/wirc.html @@ -2,9 +2,9 @@ #tron - - - + + +
@@ -14,7 +14,7 @@ - +
diff --git a/wirc.js b/app/wirc.js similarity index 87% rename from wirc.js rename to app/wirc.js index 927e2fe..8569e1e 100644 --- a/wirc.js +++ b/app/wirc.js @@ -4,6 +4,12 @@ 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 isinView(oObject) { return (oObject.offsetParent.clientHeight <= oObject.offsetTop); } @@ -13,7 +19,6 @@ function selectForum(fe) { for (i = 0; i < kids.length; i += 1) { e = kids[i]; - console.log(i, e); if (e == fe) { e.style.display = "block"; } else { @@ -166,12 +171,21 @@ function newmsg(event) { } function handleCommand(event) { - window.evt = event; var oReq = new XMLHttpRequest(); function reqListener() { } + + var txt = document.getElementById("text").value; + if (txt.startsWith("/connect ")) { + // XXX: should allow tokens with spaces + var parts = txt.split(" "); + + connect(parts[1], parts[2], parts[3]); + return; + } + oReq.onload = reqListener; - oReq.open("POST", "wirc.cgi", true); + oReq.open("POST", window.postURL, true); oReq.send(new FormData(event.target)); event.target.reset(); @@ -179,14 +193,16 @@ function handleCommand(event) { return false; } -function init() { - var server = document.getElementById("server").value; - var authtok = prompt("Auth token", ""); +function connect(url, server, authtok) { + window.postURL = url; + document.getElementById("server").value = server; document.getElementById("authtok").value = authtok; - - var source = new EventSource("wirc.cgi?server=" + server + "&auth=" + authtok); + var pullURL = url + "?server=" + server + "&auth=" + authtok + var source = new EventSource(pullURL); source.onmessage = newmsg; - +} + +function init() { document.getElementById("command").onsubmit = handleCommand; } diff --git a/chat.png b/app/wirc.png similarity index 100% rename from chat.png rename to app/wirc.png