[mw-devel] MW3 r1191 - trunk/webclient
dez at sucs.org
dez at sucs.org
Fri Oct 8 11:20:25 BST 2010
Author: dez
Date: 2010-10-08 11:20:25 +0100 (Fri, 08 Oct 2010)
New Revision: 1191
Modified:
trunk/webclient/say.js
Log:
Introduces command parser which treats text starting with ".", "!" or "/" as a command
Moves who command into parser
Adds support for emote
Modified: trunk/webclient/say.js
===================================================================
--- trunk/webclient/say.js 2010-10-08 07:34:59 UTC (rev 1190)
+++ trunk/webclient/say.js 2010-10-08 10:20:25 UTC (rev 1191)
@@ -95,19 +95,44 @@
function sendSay()
{
text = $('#sayit').val();
- if (text.substr(0, 4)==".who") {
- sendCmdHandle('who', drawWho);
- $('#sayit').val( "" );
+
+ if (text.substr(0, 1)=="."||text.substr(0, 1)=="!"||text.substr(0, 1)=="/") {
+ cmdParser(text);
+ $('#sayit').val("");
return false;
}
var what = "say "+text;
$.getJSON("send.php", {send: what}, function(data, stats) {
- $('#sayit').val( "" );
+ $('#sayit').val("");
});
return false;
}
+
+
+function cmdParser(text) {
+ if (text.search(" ")==-1) {
+ cmd = text.substring(1);
+ } else {
+ cmd = text.substring(1, text.search(" "));
+ args = text.substring(text.search(" ")+1);
+ }
+
+ switch(cmd) {
+ case "who":
+ sendCmdHandle('who', drawWho);
+ break;
+ case "e":
+ case "emote":
+ case "me":
+ var what = "emote "+args;
+ $.getJSON("send.php", {send: what}, function(data, stats) {
+ });
+ break;
+ }
+}
+
function drawTime(time) {
days = time/86400;
hours = (time%86400)/3600;
More information about the mw-devel
mailing list