From 991a5820ea736f8acaafe4b3437befb741f0915b Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 29 Jul 2012 11:22:35 -0700 Subject: [PATCH 1/1] Send messages with --- webclient/rc.css | 1 + webclient/rc.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/webclient/rc.css b/webclient/rc.css index bc5ea69..c878e19 100644 --- a/webclient/rc.css +++ b/webclient/rc.css @@ -2,3 +2,4 @@ html, body, #outer-table, #history { width: 99.9%; height: 100%; margin: 0; padd #status { background-color: #eef } #say { width: 100% } #history { vertical-align: bottom } +img { width: 1px; height: 1px; } diff --git a/webclient/rc.js b/webclient/rc.js index 13190c5..8e565c5 100644 --- a/webclient/rc.js +++ b/webclient/rc.js @@ -1,3 +1,29 @@ +var servers = ['chkno.net', 'localhost'] + +var session = Math.random(); + +function addport(server) { + // Add the default port if server doesn't contain a port number already + if (server.indexOf(":") == -1) { + return server + ":21059"; + } else { + return server; + } +} + +function rcsend(d, message) { + var id = new Date().getTime() + "-" + session + "-" + Math.random(); + var path = "/speak" + + "?id=" + encodeURIComponent(id) + + "&text=" + encodeURIComponent(message); + for (i in servers) { + var uri = "http://" + addport(servers[i]) + path; + var img = document.createElement("img"); + img.setAttribute("src", uri); + d.appendChild(img); + } +} + function rckeydown(event) { if (event.keyCode == 13) { var d = document.createElement("div"); @@ -5,6 +31,7 @@ function rckeydown(event) { var h = document.getElementById("history"); h.appendChild(d); window.scrollTo(0, document.body.scrollHeight); + rcsend(d, document.input.say.value); document.input.say.value = ""; return false; } -- 2.44.1