[mw-devel] MW3 r1194 - in trunk/webclient: . templates
dez at sucs.org
dez at sucs.org
Fri Oct 8 15:37:38 BST 2010
Author: dez
Date: 2010-10-08 15:37:38 +0100 (Fri, 08 Oct 2010)
New Revision: 1194
Modified:
trunk/webclient/mw.css
trunk/webclient/say.js
trunk/webclient/templates/front.html
Log:
Adds clickable links
Adds the who list (but doesn't keep it up to date yet)
Modified: trunk/webclient/mw.css
===================================================================
--- trunk/webclient/mw.css 2010-10-08 13:43:38 UTC (rev 1193)
+++ trunk/webclient/mw.css 2010-10-08 14:37:38 UTC (rev 1194)
@@ -3,8 +3,17 @@
font-size: 10pt;
}
+#wholist {
+ float: right;
+ width: 13%;
+ border: 1px solid black;
+ list-style: none;
+ margin: 0;
+ padding: 0.5em;
+}
+
#textlist, #sayit {
- clear: both;
+ float: left;
border: 1px solid black;
padding: 0.5em;
overflow: auto;
@@ -22,12 +31,12 @@
#textlist {
height: 70%;
- width: 97%;
+ width: 82%;
}
#sayit {
height: 10%;
- width: 98%;
+ width: 83%;
margin-top: 0.5em;
}
@@ -46,10 +55,13 @@
width: 10em;
text-align: right;
font-style: italic;
+ display: block;
}
.msg_content {
- padding-left: 10em;
+ padding-left: 11em;
+ text-indent: -1em;
+ display: block;
}
/* ************************************ */
@@ -64,7 +76,7 @@
/* * Term Colours (Silver on Black) * */
/* ************************************************* */
-#textlist, #textlist table {
+#textlist, #textlist table, a {
background: #000000;
color: #d6d6d6;
}
Modified: trunk/webclient/say.js
===================================================================
--- trunk/webclient/say.js 2010-10-08 13:43:38 UTC (rev 1193)
+++ trunk/webclient/say.js 2010-10-08 14:37:38 UTC (rev 1194)
@@ -1,5 +1,9 @@
- var die=0;
+var die=0;
+function pageInit() {
+ sendCmdHandle('who', drawWhoList);
+}
+
function addmsg(type, msg) {
var tmo = 500;
@@ -42,14 +46,18 @@
escapedMsg = escapedMsg.replace(/</g, "<");
escapedMsg = escapedMsg.replace(/>/g, ">");
+ /* Detect URIs and convert to links */
+ uris = escapedMsg.match(/https?:\/\/[^ ]*/g);
+ for (one in uris) {
+ escapedMsg = escapedMsg.replace(uris[one], "<a target=\"_new\" href=\""+uris[one]+"\">"+uris[one]+"</a>");
+ }
+
/* Detect username */
if (escapedMsg.substr(0, msg[one].username.length)==msg[one].username) {
- escapedMsg = escapedMsg.replace(msg[one].username, "<div class='msg_poster'>"+msg[one].username+"</div><div class='msg_content'>");
- escapedMsg = escapedMsg+"</div>";
+ escapedMsg = escapedMsg.replace(msg[one].username, "<span class='msg_poster'>"+msg[one].username+"</span><span class='msg_content'>");
+ escapedMsg = escapedMsg+"</span>";
}
- /* Detect URIs and convert to links */
-
/* Replace colour codes with appropriate span tags */
msgColours = escapedMsg.match(/\u001b../g);
if (msgColours != null) {
@@ -109,8 +117,6 @@
return false;
}
-
-
function cmdParser(text) {
if (text.search(" ")==-1) {
cmd = text.substring(1);
@@ -127,9 +133,13 @@
case "emote":
case "me":
var what = "emote "+args;
- $.getJSON("send.php", {send: what}, function(data, stats) {
- });
+ $.getJSON("send.php", {send: what});
break;
+ case "q":
+ case "qq":
+ case "quit":
+ sendCmd('quit');
+ break;
}
}
@@ -148,7 +158,6 @@
function drawWho(data, stat)
{
- var text = "Who List: ";
var count = 0;
text = "<hr /><table cellspacing=\"0\" cellpadding=\"0\"><tbody>";
text += "<tr><th style=\"width: 10em;\">Name</th><th style=\"width: 6em;\">Idle</th><th>What...</th></tr>";
@@ -163,6 +172,16 @@
addmsg("who", text);
}
+function drawWhoList(data, stat)
+{
+ var count = 0;
+ text = "<hr /><table cellspacing=\"0\" cellpadding=\"0\"><tbody>";
+ text += "<tr><th style=\"width: 10em;\">Name</th><th style=\"width: 6em;\">Idle</th><th>What...</th></tr>";
+ for (person in data) {
+ $("#wholist").append("<li id=\"who_"+data[person].username+"\">"+data[person].username+"</li");
+ }
+}
+
function sendCmdHandle(cmd, handle)
{
$.getJSON("send.php", {send: cmd}, handle);
Modified: trunk/webclient/templates/front.html
===================================================================
--- trunk/webclient/templates/front.html 2010-10-08 13:43:38 UTC (rev 1193)
+++ trunk/webclient/templates/front.html 2010-10-08 14:37:38 UTC (rev 1194)
@@ -10,6 +10,9 @@
</form>
<h1>Milliways</h1>
+<ul id="wholist">
+</ul>
+
<div id="textlist">
<div class="welcome">Milliways III - Web Edition</div>
</div>
@@ -17,6 +20,7 @@
<textarea name="sayit" id="sayit" cols="80" rows="3" onKeyPress="return submitenter(this,event)"></textarea>
</form>
<script language="javascript" type="text/javascript">
+pageInit();
var sayit = document.getElementById("sayit");
sayit.focus();
</script>
More information about the mw-devel
mailing list