[mw-devel] MW3 r1197 - trunk/webclient

dez at sucs.org dez at sucs.org
Fri Oct 8 17:06:44 BST 2010


Author: dez
Date: 2010-10-08 17:06:43 +0100 (Fri, 08 Oct 2010)
New Revision: 1197

Modified:
   trunk/webclient/say.js
Log:
Makes variables used in functions local


Modified: trunk/webclient/say.js
===================================================================
--- trunk/webclient/say.js	2010-10-08 15:35:03 UTC (rev 1196)
+++ trunk/webclient/say.js	2010-10-08 16:06:43 UTC (rev 1197)
@@ -22,8 +22,7 @@
 			for (one in msg) {
 				if (msg[one].state == 23) return tmo; // CheckOnOff
 				if (msg[one].state == 14) { // IPC_KICK
-					var what;
-					what = "<div class='msgkick user_system'>";
+					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 />";
 						what += "You look up; a large object is falling towards you very fast, very very fast. It looks like a Magic Roundabout!<br />";
@@ -42,12 +41,12 @@
 				}
 
 				/* Escape HTML characters */
-				escapedMsg = msg[one].text.replace(/&/g, "&amp;");
+				var escapedMsg = msg[one].text.replace(/&/g, "&amp;");
 				escapedMsg = escapedMsg.replace(/</g, "&lt;");
 				escapedMsg = escapedMsg.replace(/>/g, "&gt;");
 
 				/* Detect URIs and convert to links */
-				uris = escapedMsg.match(/https?:\/\/[^ ]*/g);
+				var uris = escapedMsg.match(/https?:\/\/[^ ]*/g);
 				for (one in uris) {
 					escapedMsg = escapedMsg.replace(uris[one], "<a target=\"_new\" href=\""+uris[one]+"\">"+uris[one]+"</a>");
 				}
@@ -59,12 +58,12 @@
 				}
 
 				/* Replace colour codes with appropriate span tags */				
-				msgColours = escapedMsg.match(/\u001b../g);
+				var msgColours = escapedMsg.match(/\u001b../g);
 				if (msgColours != null) {
 					for (i=0;i<msgColours.length;i++) {
 						if (isNaN(msgColours[i].charAt(1))) {
-							colourBold = "";
-							fgColour = 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 {
@@ -102,7 +101,7 @@
 
 function sendSay()
 {
-	text = $('#sayit').val();
+	var text = $('#sayit').val();
 
 	if (text.substr(0, 1)=="."||text.substr(0, 1)=="!"||text.substr(0, 1)=="/") {
 		cmdParser(text);
@@ -119,10 +118,10 @@
 
 function cmdParser(text) {
 	if (text.search(" ")==-1) {
-		cmd = text.substring(1);
+		var cmd = text.substring(1);
 	} else {
-		cmd = text.substring(1, text.search(" "));
-		args = text.substring(text.search(" ")+1);
+		var cmd = text.substring(1, text.search(" "));
+		var args = text.substring(text.search(" ")+1);
 	}
 
 	switch(cmd) {
@@ -144,11 +143,11 @@
 }
 
 function drawTime(time) {
-	days = time/86400;
-	hours = (time%86400)/3600;
-	minutes = ((time%86400)%3600)/60;
-	seconds = ((time%86400)%3600)%60;
-	text = "";
+	var days = time/86400;
+	var hours = (time%86400)/3600;
+	var minutes = ((time%86400)%3600)/60;
+	var seconds = ((time%86400)%3600)%60;
+	var text = "";
 	if (days>=2) text += parseInt(days)+"d";
 	if (hours>=1) text += parseInt(hours)+"h";
 	if (minutes>=1&&days<2) text += parseInt(minutes)+"m";
@@ -161,10 +160,10 @@
         var 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) {
-                line = "<td>"+data[person].username+"</td>";
-                line += "<td>"+drawTime(data[person].idle)+"</td>";
-                line += "<td>Room "+data[person].channel+"</td>";
-                text += "<tr>"+line+"</tr>";
+		var line = "<td>"+data[person].username+"</td>";
+		line += "<td>"+drawTime(data[person].idle)+"</td>";
+		line += "<td>Room "+data[person].channel+"</td>";
+		text += "<tr>"+line+"</tr>";
         }
         text += "</tbody></table><hr />";
         addmsg("who", text);




More information about the mw-devel mailing list