Commit 8119e292 authored by Dave Cooper's avatar Dave Cooper

updated form-elements primitives, new timer app

parent 8c78e09a
glsite @ a34a8203
Subproject commit a34a8203143a0845aca8c66a41bacd767d7ff3cf
((("0" "5") ("Description of task")))
\ No newline at end of file
(("0" "1") ("Description of task"))
\ No newline at end of file
(in-package :timer-journaler)
(defparameter *source-path* (make-pathname :directory (pathname-directory (glisp:source-pathname))
:name nil :type nil))
(publish-directory
:prefix "/timer-static/"
:destination (format nil "~a" (probe-file (merge-pathnames "../static/" *source-path*))))
(define-object assembly (base-ajax-sheet)
:computed-slots
((force-update-flag nil :settable)
(main-sheet-body (with-cl-who-string ()
(:div :id "content"
(:script :src "/timer-static/scripts.js")
(:script :type "text/javascript"
"function timerStop() {"
(str (the (gdl-ajax-call
:form-controls (list
(the timer-form-min)
(the timer-form-sec)
(the journal-form-name)
(the journal-form-descr))
:function-key :record-journal-entry)))
"}")
(str (the timer-header main-div))
(str (the timer-form-min form-control))
(str (the timer-form-sec form-control))
(:br)
(str (the journal-form-name form-control))
(str (the journal-form-descr form-control))
(str (the timer-button main-div))
(:br)
(str (the journal-entries-display main-div)))))
(additional-header-content
(with-cl-who-string ()
(:link :href "/timer-static/style/styles.css"
:rel "stylesheet"
:type "text/css"))))
:objects
; Header that says "TIMER"
((timer-header :type 'sheet-section
:inner-html (with-cl-who-string ()
(:h1 :id "header" "timer")))
; Form for the timer.
(timer-form-min :type 'text-form-control
:default "20"
:size 2)
(timer-form-sec :type 'text-form-control
:default "00"
:size 2)
; Form for the name and description (journal)
(journal-form-name :type 'text-form-control
:default "Name")
(journal-form-descr :type 'text-form-control
:default "Description of task")
; Button that says "START"
(timer-button :type 'sheet-section
:inner-html (with-cl-who-string ()
(:button :onclick
(concatenate 'string
"timerStart('"
(symbol-name (the timer-form-min id))
"','"
(symbol-name (the timer-form-sec id))
"')")
"Start")))
(journal-entries-display :type 'sheet-section
:inner-html (progn (the force-update-flag)
(with-cl-who-string ()
(fmt "Previous entries: ~{~a<br>~}"
(the read-journal-entry))))))
:functions
((read-journal-entry ()
(let ((file-contents
(with-open-file
(stream
(concatenate 'string
(namestring (merge-pathnames "../db/" *source-path*))
(the journal-form-name value))
:direction :input)
(read stream nil nil))))
file-contents))
(toggle-update-flag! ()
(the (set-slot! :force-update-flag
(not (the force-update-flag)))))
(record-journal-entry ()
(the toggle-update-flag!)
(with-open-file
(stream
(concatenate 'string
(namestring (merge-pathnames "../db/" *source-path*))
(the journal-form-name value))
:direction :output
:if-does-not-exist :create
:if-exists :overwrite)
(write
(append
(list (list
(list (the timer-form-min value)
(the timer-form-sec value))
(list (the journal-form-descr value))))
(the read-journal-entry))
:stream stream)))))
("package")
\ No newline at end of file
(in-package :cl-user)
(gwl:define-package :timer-journaler)
(in-package :timer-journaler)
(publish-gwl-app "/timer" 'assembly)
(publish-gwl-app "/timer-journaler" 'assembly)
(publish-gwl-app "/tj" 'assembly)
var minutes, seconds;
var interval;
var timerStarted = false;
var start_min, start_sec;
var min_id, sec_id;
function timerStart(minid, secid) {
if (timerStarted) {
return;
}
timerStarted = true;
minutes = parseInt(document.getElementById(minid).value);
seconds = parseInt(document.getElementById(secid).value);
min_id = minid;
sec_id = secid;
start_min = minutes;
start_sec = seconds;
interval = setInterval(countDown, 1000);
}
function countDown() {
seconds--;
if (seconds==-1) {
seconds = 59;
minutes--;
}
if (minutes==0 && seconds==0) {
clearInterval(interval);
timerStarted = false;
document.getElementById(min_id).value = start_min;
document.getElementById(sec_id).value = start_sec;
timerStop();
return;
}
document.getElementById(min_id).value = minutes;
document.getElementById(sec_id).value = seconds;
}
\ No newline at end of file
body {
padding: 0;
margin: 0;
font-family: "Arial";
}
#content {
text-align: center;
}
input {
outline: 0;
border: 0;
padding: 15px;
font-size: 19pt;
text-align: center;
background-color: #eee;
margin: 5px;
}
button {
background-color: #999;
border: 2px solid #333;
font-size: 19pt;
}
button:hover {
background-color: #ccc;
}
\ No newline at end of file
;;;; -*- coding: utf-8 -*-
(asdf:defsystem
#:timer
:description
"The Gendl™ timer Subsystem"
:author
"Dave Cooper"
:license
"Affero Gnu Public License (http://www.gnu.org/licenses/)"
:serial
t
:version
"20150611"
:depends-on
nil
#-asdf-unicode :defsystem-depends-on #-asdf-unicode (:asdf-encodings)
#+asdf-encodings :encoding #+asdf-encodings :utf-8
:components
((:file "source/package")
(:file "source/assembly")
(:file "source/publish")))
(in-package :gdl-user)
(define-object time-report ()
:computed-slots
((update-flag nil :settable)
(current-time-uncached (iso-8601-date (get-universal-time) :include-time? t) :uncached)
(current-time (progn (the update-flag)
(iso-8601-date (get-universal-time) :include-time? t)))))
#|
GDL-USER> (make-self 'time-report)
#<TIME-REPORT 4020123363>
GDL-USER> (the current-time)
"2015-06-12T16:34:20"
GDL-USER> (the current-time)
"2015-06-12T16:34:20"
GDL-USER> (the current-time)
"2015-06-12T16:34:20"
GDL-USER> (the (set-slot! :update-flag (not (the update-flag))))
NIL
GDL-USER> (the current-time)
"2015-06-12T16:34:41"
GDL-USER> (the current-time)
"2015-06-12T16:34:41"
GDL-USER> (the (set-slot! :update-flag (not (the update-flag))))
NIL
GDL-USER> (the current-time)
"2015-06-12T16:34:49"
GDL-USER> (the current-time)
"2015-06-12T16:34:49"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:53"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:53"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:54"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:55"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:56"
GDL-USER> (the current-time-uncached)
"2015-06-12T16:35:57"
GDL-USER>
|#
......@@ -275,8 +275,8 @@ Can be :table-td (label goes in a td before the form control), :table-td-append
:table-with-class (like :table-td, but adds a class \"form-control\" to the table), or
:as-div (puts label and control inside a div of class \"form-control\").
Default is :table-td"
label-position :table-td)
Default is :as-div"
label-position :as-div)
("Function of one argument. The argument will be the submitted form value converted to the proper type.
The return value from this function can be nil, any non-nil value, or a plist with keys :validated-value
......@@ -481,17 +481,10 @@ and cleared when the error is gone." error nil :settable)
(with-html-output (*stream* nil)
(cond ((the prompt)
(ecase (the label-position)
(:table-td (htm (:table (:tr (:td (write-the (:label :include-prompt? t)))
(:td (write-the form-control))))))
(:table-td-append (htm (:table (:tr (:td (write-the form-control))
(:td (write-the (:label :include-prompt? t)))))))
(:prepend (htm ((:label :for (the field-name)) (write-the prompt))
(write-the form-control)))
(:append (htm (write-the form-control)
((:label :for (the field-name)) (write-the prompt))))
(:table-with-class (htm ((:table :class "form-control")
(:tr (:td (write-the (:label :include-prompt? t)))
(:td (write-the form-control))))))
(:as-div (htm ((:div :class "form-control")
(write-the (:label :include-prompt? t))
(write-the form-control))))))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment