+
+ var commands = {
+ tell : function() {},
+ yell : function() {},
+ move : function(direction) {
+ player.move(direction);
+ },
+ }
+ $('#submit').click(function() {
+ var text = $('#chat').val();
+ var parts = text.match(/^(\w+)\s(.*)/);
+ var cmd = parts[1];
+ text = parts[2];
+ if (commands[cmd] != undefined) commands[cmd](text);
+ });
+ $('#chat').keypress(function(e) {
+ if (e.which == '13') {
+ $('#submit').click();
+ $('#chat').val('');
+ }
+ });
+