From: Gerd Flaig Date: Sun, 14 Dec 2008 22:35:07 +0000 (+0100) Subject: Initial working command line X-Git-Url: http://git.pond.sub.org/?p=eow;a=commitdiff_plain;h=f08c83a6016dddd28fd4acc9bb12c4350a40c004 Initial working command line --- diff --git a/empire.lisp b/empire.lisp index 7685f55..5d1b950 100644 --- a/empire.lisp +++ b/empire.lisp @@ -139,7 +139,8 @@ this stream.") (defmethod handle-data ((m play-mode) message) (let* ((c (connection m)) (log (logging-stream c))) - (format log "handle-data ~a~%" message))) + (format log "handle-data ~a~%" message) + (empire-web:data message))) (defmethod handle-prompt ((m play-mode) message) (let* ((c (connection m)) diff --git a/package.lisp b/package.lisp index 26d0ebb..5cf8ad0 100644 --- a/package.lisp +++ b/package.lisp @@ -10,11 +10,13 @@ (:use :cl) (:export :read-message-loop :read-message - :make-connection)) + :make-connection + :connect + :send-message)) (defpackage :locked-queue (:use :cl :sb-thread) (:export :create :enqueue :dequeue)) (defpackage :empire-web (:use :cl :hunchentoot) - (:export :start :send :prompt))) + (:export :start :send :prompt :data))) diff --git a/static/eow.js b/static/eow.js index 55fb20c..31a21f2 100644 --- a/static/eow.js +++ b/static/eow.js @@ -34,7 +34,54 @@ function get_next_update() { }); } +function submit_cmdline(cmdline_form) { + dojo.xhrGet( { + // The following URL must match that used to test the server. + url: "/eow/command", + handleAs: "text", + + timeout: 30000, // Time in milliseconds + + // The LOAD function will be called on a successful response. + load: function(response, ioArgs) { + console.log(response); + return response; + }, + + // The ERROR function will be called in an error case. + error: function(response, ioArgs) { + if (response.dojoType == "timeout") { + ioArgs.xhr.abort(); + return response; + } + + console.error("HTTP status code: ", ioArgs.xhr.status); + return response; + }, + + form: cmdline_form + }); +} + function prompt(minutes, btus) { eowOut("[" + minutes + "," + btus + "]: "); get_next_update(); } + +function msg(m) { + eowOut(m); + get_next_update(); +} + +function setup_client() { + var input = dojo.byId("inputfield"); + input.focus(); +} + +function inputfield_keyup(e) { + console.log(e); + if (e.keyCode == 13) { // Enter + submit_cmdline(e.target.form.id); + e.target.value = ""; + } +} diff --git a/static/login.html b/static/login.html new file mode 100644 index 0000000..2dd2944 --- /dev/null +++ b/static/login.html @@ -0,0 +1,20 @@ + + +Login + + + +

Login

+ +
+ +
Username +
Password +
+ +
+ +
+
+ Last modified: Sun Dec 14 22:16:18 CET 2008 + diff --git a/static/test.html b/static/test.html index 867d524..28f676c 100644 --- a/static/test.html +++ b/static/test.html @@ -9,6 +9,7 @@