[mw-devel] MW3 r1209 - in trunk/webclient: . templates

dez at sucs.org dez at sucs.org
Sun Oct 10 00:33:16 BST 2010


Author: dez
Date: 2010-10-10 00:33:16 +0100 (Sun, 10 Oct 2010)
New Revision: 1209

Modified:
   trunk/webclient/mw.css
   trunk/webclient/say.js
   trunk/webclient/templates/front.html
Log:
Adds timestamp support


Modified: trunk/webclient/mw.css
===================================================================
--- trunk/webclient/mw.css	2010-10-09 22:03:56 UTC (rev 1208)
+++ trunk/webclient/mw.css	2010-10-09 23:33:16 UTC (rev 1209)
@@ -62,8 +62,12 @@
 	clear: both;
 }
 
+.timestamp {
+	float: left;
+	width: 4em;
+}
+
 .msg_poster {
-	clear: both;
 	float: left;
 	width: 10em;
 	text-align: right;
@@ -72,7 +76,8 @@
 }
 
 .msg_content {
-	padding-left: 11em;
+	float: left;
+	padding-left: 1em;
 	text-indent: -1em;
 	display: block;
 }

Modified: trunk/webclient/say.js
===================================================================
--- trunk/webclient/say.js	2010-10-09 22:03:56 UTC (rev 1208)
+++ trunk/webclient/say.js	2010-10-09 23:33:16 UTC (rev 1209)
@@ -3,6 +3,7 @@
 
 function pageInit() {
 	sendCmdHandle('who', drawWhoList);
+	sendCmdHandle('whoami', userProfile);
 }
 
 	function addmsg(type, msg) {
@@ -76,6 +77,12 @@
 					}
 				}
 
+				/* Insert timestamp if necessary */
+				if (userProfile.special.match("t")) {
+					var currentTime = new Date()
+					escapedMsg = "<span class=\"timestamp\">"+pad(currentTime.getHours(), 2)+":"+pad(currentTime.getMinutes(), 2)+" </span>"+escapedMsg;
+				}
+
 				/* Output the processed line */
 				$("#textlist").append( "<p class='msg"+type+" user_"+userIndex[msg[one].username]+"'>" + escapedMsg + "</p");
 			}
@@ -192,7 +199,6 @@
 	for (var person in data) {
 		idleness="";
 		if (data[person].idle>1800) idleness=" idle";
-
 		var thisUsername=data[person].username;
 		if (thisUsername in userIndex) usercount--;
 		userIndex[thisUsername]=usercount;
@@ -201,6 +207,13 @@
 	}
 }
 
+function userProfile(data, stat) {
+	userProfile=new Object;
+	for (var item in data) {
+		userProfile[item] = data[item];
+	}
+}
+
 function sendCmdHandle(cmd, handle)
 {
 	$.getJSON("send.php", {send: cmd}, handle);
@@ -211,6 +224,14 @@
 	$.getJSON("send.php", {send: cmd});
 }
 
+function pad(number, length) {
+    var str = '' + number;
+    while (str.length < length) {
+        str = '0' + str;
+    }
+    return str;
+}
+
 function submitenter(myfield,e)
 {
 	var keycode;

Modified: trunk/webclient/templates/front.html
===================================================================
--- trunk/webclient/templates/front.html	2010-10-09 22:03:56 UTC (rev 1208)
+++ trunk/webclient/templates/front.html	2010-10-09 23:33:16 UTC (rev 1209)
@@ -8,7 +8,7 @@
 </ul>
 
 <div id="textlist">
-<div class="welcome">Milliways III - Web Edition</div>
+<p class="welcome">Milliways III - Web Edition</p>
 </div>
 <form action="" id="sayform">
 	<textarea name="sayit" id="sayit" cols="80" rows="3" onKeyPress="return submitenter(this,event)"></textarea>




More information about the mw-devel mailing list