diff --git a/evennia/web/webclient/static/webclient/js/evennia.js b/evennia/web/webclient/static/webclient/js/evennia.js index f1a4fe1029..76b9669411 100644 --- a/evennia/web/webclient/static/webclient/js/evennia.js +++ b/evennia/web/webclient/static/webclient/js/evennia.js @@ -110,9 +110,9 @@ An "emitter" object must have a function if (typeof callback === 'function') { cmdmap[cmdid] = callback; } + log('client msg sending: ', data); this.connection.msg(data); - log('client msg sending: ', cmdname, args, outargs, outkwargs); }, // Evennia -> Client. @@ -219,9 +219,9 @@ An "emitter" object must have a function log("incoming " + data); Evennia.emit(data[0], data[1], data[2]); }; - websocket.msg = function(cmdname, args, kwargs) { - // send - websocket.send(JSON.stringify([cmdname, args, kwargs])); + websocket.msg = function(data) { + // send data across the wire. Make sure to json it. + websocket.send(JSON.stringify(data)); }; return websocket; diff --git a/evennia/web/webclient/static/webclient/js/webclient_gui.js b/evennia/web/webclient/static/webclient/js/webclient_gui.js index e86a55059c..04eb12b292 100644 --- a/evennia/web/webclient/static/webclient/js/webclient_gui.js +++ b/evennia/web/webclient/static/webclient/js/webclient_gui.js @@ -27,17 +27,17 @@ var inputlog = function() { history[0] = ''; // the very latest input is empty for new entry. - function history_back() { + var back = function () { // step backwards in history stack history_pos = Math.min(++history_pos, history.length - 1); return history[history.length - 1 - history_pos]; - } - function history_fwd() { + }; + var fwd = function () { // step forwards in history stack history_pos = Math.max(--history_pos, 0); return history[history.length -1 - history_pos]; - } - function history_add(input) { + }; + var add = function (input) { // add a new entry to history, don't repeat latest if (input != history[history.length-1]) { if (history.length >= history_max) { @@ -45,12 +45,12 @@ var inputlog = function() { } history[history.length-1] = input; history[history.length] = ''; - } - } - return {back: history_back, - fwd: history_fwd, - add: history_add} -}; + }; + }; + return {back: back, + fwd: fwd, + add: add} +}(); $.fn.appendCaret = function() { /* jQuery extension that will forward the caret to the end of the input, and @@ -100,10 +100,12 @@ $(document).keydown( function(event) { inputfield.focus(); if (code === 13) { // Enter key sends text - outtext = inputfield.val() - inputlog.add(outtext) + outtext = inputfield.val(); + inputlog.add(outtext); + inputfield.val(""); + log("sending outtext", outtext); Evennia.msg("text", [outtext], {}); - event.prevetDefault() + event.preventDefault() } else if (code === 38) { // Arrow up inputfield.val(inputlog.back()).appendCaret(); diff --git a/evennia/web/webclient/templates/webclient/webclient.html b/evennia/web/webclient/templates/webclient/webclient.html index 23fc272b07..9e19c9af6f 100644 --- a/evennia/web/webclient/templates/webclient/webclient.html +++ b/evennia/web/webclient/templates/webclient/webclient.html @@ -12,7 +12,7 @@