]> git.pond.sub.org Git - eow/commitdiff
Forward prompt to browser
authorGerd Flaig <gefla@gefla-mac-zrh>
Sat, 29 Nov 2008 22:35:30 +0000 (23:35 +0100)
committerGerd Flaig <gefla@gefla-mac-zrh>
Sat, 29 Nov 2008 22:35:30 +0000 (23:35 +0100)
empire.lisp
package.lisp
static/eow.js
static/test.html
web.lisp

index 4797ac71e4817e424e26ad250c26ffab57d82ad5..7685f5582a7ff93d4ed2acf5d5a1713c690566fe 100644 (file)
@@ -145,9 +145,10 @@ this stream.")
   (let* ((c (connection m))
         (log (logging-stream c)))
     (with-input-from-string (s message)
   (let* ((c (connection m))
         (log (logging-stream c)))
     (with-input-from-string (s message)
-      (let* ((minutes (read s))
+      (let* ((minutes (read s)) ;;FIXME DANGEROUS
             (btus (read s)))
             (btus (read s)))
-       (format log "[~a:~a]: ~%" minutes btus)))))
+       (format log "[~a:~a]: ~%" minutes btus)
+       (empire-web:prompt minutes btus)))))
 
 (defparameter *line-type-dispatch*
   (list `(,+C_DATA+ . handle-data)
 
 (defparameter *line-type-dispatch*
   (list `(,+C_DATA+ . handle-data)
index 56ca854291b5dc49eec6486185a02e771dbb9a99..26d0ebb91af4e59006ee750ee24512a46ffc2777 100644 (file)
@@ -16,5 +16,5 @@
     (:export :create :enqueue :dequeue))
   (defpackage :empire-web
     (:use :cl :hunchentoot)
     (:export :create :enqueue :dequeue))
   (defpackage :empire-web
     (:use :cl :hunchentoot)
-    (:export :start :send)))
+    (:export :start :send :prompt)))
 
 
index 00b34ee239e46328344d35e3fbf85a4f097b524e..55fb20c134b5db38691cbeaaf3d57ee7d4113724 100644 (file)
@@ -5,14 +5,14 @@ function eowOut(output) {
   dojo.byId("output").appendChild(p);
 }
 
   dojo.byId("output").appendChild(p);
 }
 
-function hello() {
+function get_next_update() {
   dojo.xhrGet( {
     // The following URL must match that used to test the server.
     url: "/eow/update", 
     handleAs: "javascript",
     //handleAs: "text",
 
   dojo.xhrGet( {
     // The following URL must match that used to test the server.
     url: "/eow/update", 
     handleAs: "javascript",
     //handleAs: "text",
 
-    timeout: 5000, // Time in milliseconds
+    timeout: 30000, // Time in milliseconds
 
     // The LOAD function will be called on a successful response.
     load: function(response, ioArgs) {
 
     // The LOAD function will be called on a successful response.
     load: function(response, ioArgs) {
@@ -22,9 +22,19 @@ function hello() {
 
     // The ERROR function will be called in an error case.
     error: function(response, ioArgs) {
 
     // The ERROR function will be called in an error case.
     error: function(response, ioArgs) {
-      console.error("HTTP status code: ", ioArgs.xhr.status);
-      return response;
+       if (response.dojoType == "timeout") {
+         ioArgs.xhr.abort();
+         get_next_update();
+         return response;
+       }
+
+       console.error("HTTP status code: ", ioArgs.xhr.status);
+       return response;
     }
   });
 }
 
     }
   });
 }
 
+function prompt(minutes, btus) {
+  eowOut("[" + minutes + "," + btus + "]: ");
+  get_next_update();
+}
index 3f6cc9f225ddd9b5346b04abbbe0118690d32e98..867d52408c30c3f2095ef6851496a903c7f5c325 100644 (file)
@@ -3,13 +3,13 @@
 <link rel="stylesheet" type="text/css" href="style.css">
 <title>Empire Web Client</title>
 
 <link rel="stylesheet" type="text/css" href="style.css">
 <title>Empire Web Client</title>
 
-<script type="text/javascript" src="dojo-release-1.1.1/dojo/dojo.js"
+<script type="text/javascript" src="dojo-release-1.1.1/dojo/dojo.js.uncompressed.js"
   djConfig="parseOnLoad:true, isDebug:false"></script>
 <script type="text/javascript" src="eow.js"></script>
 <script type="text/javascript">
 var init = function(){
   console.log("I run after the page is ready. See this in the console");
   djConfig="parseOnLoad:true, isDebug:false"></script>
 <script type="text/javascript" src="eow.js"></script>
 <script type="text/javascript">
 var init = function(){
   console.log("I run after the page is ready. See this in the console");
-  hello();
+  get_next_update();
 };
 dojo.addOnLoad(init);
 </script>
 };
 dojo.addOnLoad(init);
 </script>
@@ -31,5 +31,5 @@ dojo.addOnLoad(init);
 
 <hr>
 <address></address>
 
 <hr>
 <address></address>
-<!-- hhmts start --> Last modified: Sun Nov 23 01:38:22 CET 2008 <!-- hhmts end -->
+<!-- hhmts start --> Last modified: Sat Nov 29 23:06:08 CET 2008 <!-- hhmts end -->
 </body> </html>
 </body> </html>
index 093769224ec938c3d91b3669e6250be4ec0959fc..20e27510d2a67c37764967dd29b271b141479ee6 100644 (file)
--- a/web.lisp
+++ b/web.lisp
@@ -40,6 +40,9 @@
   "Push a javascript update fragment to the client."
   (locked-queue:enqueue *update-queue* string))
 
   "Push a javascript update fragment to the client."
   (locked-queue:enqueue *update-queue* string))
 
+(defun prompt (minutes btus)
+  (send (format nil "prompt(~a,~a);~%" minutes btus)))
+
 (defun dispatch (request)
   (let ((script-name (script-name request)))
     (cond
 (defun dispatch (request)
   (let ((script-name (script-name request)))
     (cond