From 873203207e76ca15ab302e6ab3581bd0309863d0 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 26 Nov 2009 15:03:12 +0100 Subject: JavaScript: Support the creation of new revisions upon user request. --- logikorr.js | 16 ++++++++++++++-- logikorr.lisp | 9 ++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/logikorr.js b/logikorr.js index a0730bf..1fd21f4 100644 --- a/logikorr.js +++ b/logikorr.js @@ -1,6 +1,17 @@ var loader; var autocompleteList; -YUI().use('node-base', 'io-base', 'io-form', 'io-queue', 'json', function (Y) { +YUI().use('node', 'node-base', 'io-base', 'io-form', 'io-queue', 'json', function (Y) { + function registerMakeRevisionAction() { + var button = Y.one("#make-revision"); + button.on("click", function(e) { + Y.io("make-new-revision", + { 'on': { 'complete': function(id, o, args) { + Y.log("Neue Version: " + o.responseText); + Y.one("#new-version-label").set("innerText", "Gesichert. Neue Version: " + o.responseText + "."); + } } }); + }); + } + function markAsChanged(input) { input.setAttribute("style", "background-color: #faa"); } @@ -116,5 +127,6 @@ YUI().use('node-base', 'io-base', 'io-form', 'io-queue', 'json', function (Y) { } }; - return Y.on('domready', makeStudentRow); + Y.on('domready', registerMakeRevisionAction); + Y.on('domready', makeStudentRow); }); diff --git a/logikorr.lisp b/logikorr.lisp index c272880..0ce4884 100644 --- a/logikorr.lisp +++ b/logikorr.lisp @@ -40,7 +40,8 @@ *database*))) (find-students) (write-database-to-file new-path) - (setq *database* new-path))) + (setq *database* new-path) + (1+ number))) (defmacro with-authentication (() &body body) `(call-with-authentication (lambda () ,@body))) @@ -113,6 +114,7 @@ (<:body (<:h1 "Logik I: Korrekturergebnisse") (<:h2 "Neue Ergebnisse") + (<:form (<:button :type "button" :id "make-revision" (<:as-html "Aktuelle Version sichern")) (<:div :id "new-version-label" :style "display: inline; color: #070")) (<:table :id "ergebnisse") (<:h2 "Bestehende Ergebnisse") (<:table @@ -242,6 +244,11 @@ div.autocomplete ul li { (write-database))) "\"OK\"") +(define-easy-handler (create-new-revision :uri "/make-new-revision") + () + (with-authentication () + (format nil "~D" (make-new-revision)))) + (defun write-database () (find-and-initialise-database) (write-database-to-file *database*)) -- cgit v1.2.3