(module cuicui ~(js console) (export (class Cuicui (date::elong read-only) (host::string read-only) (contents::string read-only)))) (define %cuicuis '()) (define %cuicui-mutex (make-mutex)) (define-service (cuicui/new message) (synchronize %cuicui-mutex (tprint "ajout du message: " message) (let* ((req::http-request (current-request)) (new (instantiate::Cuicui (date (current-seconds)) (host (socket-hostname req.socket)) (contents message)))) (set! %cuicuis (cons new %cuicuis)) (hop-event-broadcast! "new-cuicui" new)) (length %cuicuis))) (define-service (cuicui/messages) (synchronize %cuicui-mutex (list-copy %cuicuis))) (define-service (cuicui) ( ( :title "Cui-cui !" :css "http://getbootstrap.com/dist/css/bootstrap.css") ( ~ (define ( cuicui::Cuicui) (
(

cuicui.contents) ( cuicui.host))) (

:class "container page-header jumbotron" (

"Bienvenue sur cui-cuiā„¢!" ( :src (service-resource cuicui "cuicui.png") :class "pull-right"))) (
:class "container" (
:class "form-group" ( :id "message-box" :class "form-control" :type 'text :autofocus #t :maxlength 100 :onkeyup ~ (let ((b (dom-get-element-by-id "go"))) (when (= 13 event.keyCode) (b.click)) (if (> (string-length this.value) 139) (dom-add-class! b "btn-danger") (dom-remove-class! b "btn-danger")))) (