[mw-devel] MW3 r1212 - trunk/webclient
dez at sucs.org
dez at sucs.org
Sun Oct 10 13:32:21 BST 2010
Author: dez
Date: 2010-10-10 13:32:21 +0100 (Sun, 10 Oct 2010)
New Revision: 1212
Modified:
trunk/webclient/mw.css
trunk/webclient/say.js
trunk/webclient/startup.php
Log:
Moves message state handling into a select rather than using multiple if statements
Tidies up CSS handling of timestamps
Forces wrap of long lines
Modified: trunk/webclient/mw.css
===================================================================
--- trunk/webclient/mw.css 2010-10-10 10:19:01 UTC (rev 1211)
+++ trunk/webclient/mw.css 2010-10-10 12:32:21 UTC (rev 1212)
@@ -64,24 +64,28 @@
.timestamp {
float: left;
- width: 4em;
+ width: 3.5em;
}
.msg_poster {
float: left;
+ display: block;
width: 10em;
text-align: right;
font-style: italic;
- display: block;
}
.msg_content {
- float: left;
- padding-left: 1em;
+ padding-left: 11em;
text-indent: -1em;
display: block;
+ word-wrap: break-word;
}
+.msg_content.withts {
+ padding-left: 14.5em;
+}
+
/* ************************************ */
/* * Message CSS * */
/* ************************************ */
Modified: trunk/webclient/say.js
===================================================================
--- trunk/webclient/say.js 2010-10-10 10:19:01 UTC (rev 1211)
+++ trunk/webclient/say.js 2010-10-10 12:32:21 UTC (rev 1212)
@@ -22,11 +22,53 @@
}
} else {
for (one in msg) {
- if (msg[one].state == 23) { // CheckOnOff
- sendCmdHandle('who', drawWhoList);
- continue;
- }
- if (msg[one].state == 14) { // IPC_KICK
+ switch (msg[one].state) {
+ case 11: // Talker message
+ /* Escape HTML characters */
+ var escapedMsg = msg[one].text.replace(/&/g, "&");
+ escapedMsg = escapedMsg.replace(/</g, "<");
+ escapedMsg = escapedMsg.replace(/>/g, ">");
+
+ /* Detect URIs and convert to links */
+ var uris = escapedMsg.match(/https?:\/\/[^ ]*/g);
+ for (thisuri in uris) {
+ escapedMsg = escapedMsg.replace(uris[thisuri], "<a target=\"_new\" href=\""+uris[thisuri]+"\">"+uris[thisuri]+"</a>");
+ }
+
+ /* Insert timestamp if necessary */
+ var timestamp="";
+ if (userProfile.special.match("t")) {
+ var currentTime = new Date();
+ var withts=" withts";
+ timestamp = "<span class=\"timestamp\">"+pad(currentTime.getHours(), 2)+":"+pad(currentTime.getMinutes(), 2)+" </span>";
+ }
+
+ /* Detect username */
+ if (escapedMsg.substr(0, msg[one].username.length)==msg[one].username) {
+ escapedMsg = escapedMsg.replace(msg[one].username, "<span class='msg_poster'>"+msg[one].username+"</span><span class='msg_content"+withts+"'><span>");
+ escapedMsg = escapedMsg+"</span></span>";
+ }
+
+ /* Replace colour codes with appropriate span tags */
+ var msgColours = escapedMsg.match(/\u001b../g);
+ if (msgColours != null) {
+ for (i=0;i<msgColours.length;i++) {
+ if (isNaN(msgColours[i].charAt(1))) {
+ var colourBold = "";
+ var fgColour = msgColours[i].charAt(1);
+ if (fgColour==fgColour.toUpperCase() && fgColour != "-") { colourBold = " bold"; }
+ escapedMsg = escapedMsg.replace(msgColours[i], "</span><span class='colourfg"+msgColours[i].charAt(1)+colourBold+" colourbg"+msgColours[i].charAt(2)+"'>");
+ } else {
+ escapedMsg = escapedMsg.replace(msgColours[i], "</span><span class='colour"+msgColours[i].replace(/\u001b/g, "")+"'>");
+ }
+ }
+ }
+
+ /* Output the processed line */
+ $("#textlist").append( "<p class='msg"+type+" user_"+userIndex[msg[one].username.toLowerCase()]+"'>" + timestamp + escapedMsg + "</p");
+
+ break;
+ case 14: // IPC_KICK
var what = "<div class='msgkick user_system'>";
if (msg[one].text.substr(0,1) == "m") {
what += "Boing, Zebedee's arrived. \"Look up!\" says Zebedee<br />";
@@ -42,49 +84,11 @@
if (msg[one].text.substr(1,1) == 'r') what += "\""+msg[one].text.substr(2)+"\" says Zebedee<br />";
what += "</div>";
$("#textlist").append(what);
- continue;
+ break;
+ case 23: // CheckOnOff
+ sendCmdHandle('who', drawWhoList);
+ break;
}
-
- /* Escape HTML characters */
- var escapedMsg = msg[one].text.replace(/&/g, "&");
- escapedMsg = escapedMsg.replace(/</g, "<");
- escapedMsg = escapedMsg.replace(/>/g, ">");
-
- /* Detect URIs and convert to links */
- var uris = escapedMsg.match(/https?:\/\/[^ ]*/g);
- for (thisuri in uris) {
- escapedMsg = escapedMsg.replace(uris[thisuri], "<a target=\"_new\" href=\""+uris[thisuri]+"\">"+uris[thisuri]+"</a>");
- }
-
- /* Detect username */
- if (escapedMsg.substr(0, msg[one].username.length)==msg[one].username) {
- escapedMsg = escapedMsg.replace(msg[one].username, "<span class='msg_poster'>"+msg[one].username+"</span><span class='msg_content'><span>");
- escapedMsg = escapedMsg+"</span></span>";
- }
-
- /* Replace colour codes with appropriate span tags */
- var msgColours = escapedMsg.match(/\u001b../g);
- if (msgColours != null) {
- for (i=0;i<msgColours.length;i++) {
- if (isNaN(msgColours[i].charAt(1))) {
- var colourBold = "";
- var fgColour = msgColours[i].charAt(1);
- if (fgColour==fgColour.toUpperCase() && fgColour != "-") { colourBold = " bold"; }
- escapedMsg = escapedMsg.replace(msgColours[i], "</span><span class='colourfg"+msgColours[i].charAt(1)+colourBold+" colourbg"+msgColours[i].charAt(2)+"'>");
- } else {
- escapedMsg = escapedMsg.replace(msgColours[i], "</span><span class='colour"+msgColours[i].replace(/\u001b/g, "")+"'>");
- }
- }
- }
-
- /* 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");
}
}
var objDiv = document.getElementById("textlist");
@@ -140,6 +144,7 @@
sendCmdHandle('who', drawWho);
break;
case "e":
+ case "em":
case "emote":
case "me":
var what = "emote "+args;
@@ -148,6 +153,7 @@
case "sayto":
case "sa":
case "whisper":
+ case "whi":
var what = "sayto "+args;
$.getJSON("send.php", {send: what});
break;
@@ -205,7 +211,7 @@
for (var person in data) {
idleness="";
if (data[person].idle>1800) idleness=" idle";
- var thisUsername=data[person].username;
+ var thisUsername=data[person].username.toLowerCase();
if (thisUsername in userIndex) usercount--;
userIndex[thisUsername]=usercount;
$("#wholist").append("<li class=\"who user_"+usercount+idleness+"\">"+data[person].username+"</li>");
Modified: trunk/webclient/startup.php
===================================================================
--- trunk/webclient/startup.php 2010-10-10 10:19:01 UTC (rev 1211)
+++ trunk/webclient/startup.php 2010-10-10 12:32:21 UTC (rev 1212)
@@ -22,7 +22,7 @@
1 => array("pipe", "w"),
);
$pipes = array();
-$p = proc_open("~arthur/public_html/mw/mwpoll -u $username", $desc, $pipes);
+$p = proc_open("~tswsl1989/mwpoll -u $username", $desc, $pipes);
if ($p === FALSE) {
$smarty->assign("error", "failed to exec mwpoll");
More information about the mw-devel
mailing list