aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-01-13 22:47:46 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-01-13 22:47:46 +0100
commit341e5a65a7b36e1f70ed9e6c2ae4f5b18c083b5b (patch)
tree6f01775b070e61b50cb88c757672aef6bbbfe4f4 /doc
parentSplit javascript doc into multiple files. (diff)
downloadcalp-341e5a65a7b36e1f70ed9e6c2ae4f5b18c083b5b.tar.gz
calp-341e5a65a7b36e1f70ed9e6c2ae4f5b18c083b5b.tar.xz
Doc work.
Diffstat (limited to 'doc')
-rw-r--r--doc/frontend.org24
-rw-r--r--doc/ref/Makefile2
-rw-r--r--doc/ref/calp.texi21
-rw-r--r--doc/ref/javascript/clock.texi82
-rw-r--r--doc/ref/javascript/date_time.texi37
-rw-r--r--doc/ref/javascript/draggable.texi22
-rw-r--r--doc/ref/javascript/input_list.texi49
7 files changed, 208 insertions, 29 deletions
diff --git a/doc/frontend.org b/doc/frontend.org
index 0b5725aa..63d6fe1f 100644
--- a/doc/frontend.org
+++ b/doc/frontend.org
@@ -1,29 +1,5 @@
** Javascript "components"
-*** input-list
-file:../static/input_list.js
-
-All elements having 'input-list' ∈ =class=
-
-Direct children must all have 'unit' ∈ =class=
-One direct child must have 'final' ∈ =class=
-
-binds =get_value= on instances, by default returning the value
-of all =<input/>= tags joined by =,=. This can be overwritten with
-- =data-joinby= :: Alternative character to join by
-- =data-bindby= :: replacement for get_value
-
-TODO: instead, override value?
-
-=addEventList('input',= is overwritten, registering the listener for all input
-elements.
-
*** Popup
Handles popup. Currently rather specific
-*** Dragable
-file:../static/dragable.js
-
-Manually apply =bind_popup_control= to the statusbar of a floating "window".
-Nothing is required from the component, but the "window" must have
-'popup-container' ∈ =class=
diff --git a/doc/ref/Makefile b/doc/ref/Makefile
index 35dd6604..2232a70e 100644
--- a/doc/ref/Makefile
+++ b/doc/ref/Makefile
@@ -1,4 +1,4 @@
-TEXI_FILES := $(wildcard *.texi)
+TEXI_FILES := $(shell find . -type f -name \*.texi)
INFOFLAGS :=
all: calp.info
diff --git a/doc/ref/calp.texi b/doc/ref/calp.texi
index a2408f89..e280a455 100644
--- a/doc/ref/calp.texi
+++ b/doc/ref/calp.texi
@@ -17,6 +17,27 @@ Copyright @copyright{} 2020 Hugo Hörnquist
@alias nicode=code
@end ifnotinfo
+@c @ifinfo
+@c @macro i{text}
+@c \text\
+@c @end macro
+@c @end ifinfo
+
+@c for use with deftp for extended classes
+@macro extends{class}
+@w{@i{extends} \class\}
+@end macro
+
+@c For things that should be fixed in the (actual) code.
+@c An ``invitation'' to the reader
+@macro TODO{text}
+text @footnote{Improvements welcome}
+@end macro
+
+@macro githash{hash,path,line}
+@url{https://git.hornquist.se/calp/tree/\path\?id=\hash\#n\line\,\hash\}
+@end macro
+
@titlepage
@title Calp
@author Hugo Hörnquist
diff --git a/doc/ref/javascript/clock.texi b/doc/ref/javascript/clock.texi
index 1602e687..5f599c9b 100644
--- a/doc/ref/javascript/clock.texi
+++ b/doc/ref/javascript/clock.texi
@@ -1,4 +1,84 @@
-
@node clock
@section clock.js
+@deftp {(abstract) class} Clock
+Interface for ``things'' which wants to get updated on a human timescale.
+
+@defmethod Clock update now
+Called every now and then, with @var{now} being the current time.
+@end defmethod
+
+All instances are expected to implement @code{update}, but are free to
+implement any other methods they see fit.
+@end deftp
+
+Below, only the methods (including @code{constructor} and
+@code{update} which do something of note (excluding the expected))
+are noted.
+
+@deftp {class} Timebar @extends{Clock}
+The (blue) vertical line which show the current time in the current day.
+
+@c @defmethod Timebar constructor ∅
+@c @end defmethod
+@c
+@c @defmethod Timebar update now
+@c @end defmethod
+@end deftp
+
+@deftp {class} SmallcalCellHighlight @extends{Clock}
+Highlights the current date in the small calendar to the side.
+Currently directly sets a border
+@TODO{but should preferably set a class instead}.
+
+@defmethod SmallcalCellHighlight constructor small_cal
+@var{small_cal} is the DOM-node of the calendar.
+(it should support querySelector).
+@end defmethod
+
+@c @defmethod SmallcalCellHighlight update now
+@c @end defmethod
+@end deftp
+
+@deftp {class} ButtonUpdater @extends{Clock}
+Updates the ``Today'' link in the side panel to point directly to the
+correct web-address. The link works without JavaScript, but then
+requires a redirect from the server.
+
+All actual updating logic is already abstracted away. It would be
+desirable if something more was done with this.
+
+@defmethod ButtonUpdater el proc
+Takes the element @var{el} to be updated, and the procedure @var{proc}
+which will be called with the element, and the current time.
+@end defmethod
+@end deftp
+
+
+As of commit
+@githash{c9719ce7937f0f0f2aa371ced1d585f67af22457,static/script.js,231}
+all objects required manual setup. See static/script.js:
+
+@verbatim
+ 231 let start_time = document.querySelector("meta[name='start-time']").content;
+ 232 let end_time = document.querySelector("meta[name='end-time']").content;
+ 233
+ 234 const button_updater = new ButtonUpdater(
+ 235 document.getElementById("today-button"),
+ 236 (e, d) => e.href = d.format('~Y-~m-~d') + ".html"
+ 237 );
+ 238
+ 239 const sch = new SmallcalCellHighlight(
+ 240 document.querySelector('.small-calendar'))
+ 241
+ 242 const timebar = new Timebar(start_time, end_time);
+ 243
+ 244 timebar.update(new Date);
+ 245 window.setInterval(() => {
+ 246 let d = new Date;
+ 247 timebar.update(d);
+ 248 button_updater.update(d);
+ 249 sch.update(d);
+ 250 }, 1000 * 60);
+ 251
+@end verbatim
diff --git a/doc/ref/javascript/date_time.texi b/doc/ref/javascript/date_time.texi
index 7bc47625..1f62c72e 100644
--- a/doc/ref/javascript/date_time.texi
+++ b/doc/ref/javascript/date_time.texi
@@ -1,4 +1,39 @@
-
@node date_time
@section date_time.js
+@defun init_date_time
+@c possibly have special index for these
+@cindex dummy component
+Procedure which initializes the dummy component for date-time input.
+When called, finds all elements with class ``date-time'', and makes
+them date-time inputs.
+
+@c <input type='date-time'/>
+
+The expected HTML form is
+@example
+<div class="date-time" name="@var{name}">
+ <input type="date"/>
+ <input type="time"/>
+</div>
+@end example
+
+Each date-time gets the following fields:
+
+@defivar date_time value
+The current date-time value as a string,
+on the form @code{YYYY-mm-ddTHH:MM[:SS]}
+(@code{SS} if the underlying time input has it).
+
+A new date-time can also be set to the field, the same format as above
+is expected.
+@end defivar
+
+@defivar date_time name
+The ``name'' field of the date-time input. Since @code{name} note that
+this is an addition, since name is actually invalid on non-input
+components. We nevertheless use it here since we are emulating an
+input element.
+@end defivar
+
+@end defun
diff --git a/doc/ref/javascript/draggable.texi b/doc/ref/javascript/draggable.texi
index e91d12f7..689dd005 100644
--- a/doc/ref/javascript/draggable.texi
+++ b/doc/ref/javascript/draggable.texi
@@ -1,4 +1,24 @@
-
@node dragable
@section dragable.js
+@c TODO This text is just yanked from the old org file, along with the
+@c source codes header. It should probably be rewritten.
+
+Manually apply =bind_popup_control= to the statusbar of a floating
+"window". Nothing is required from the component, but the "window"
+must have 'popup-container' ∈ =class=
+
+@defun bind_popup_control nav
+Apply to a given component to make it draggable.
+Drag area (usually a title bar) should be be the only argument.
+It is REQUIRED that the object which should be moved have the class
+@code{popup-container}.
+
+@example
+<div class='popup-container'>
+ ...
+ <nav />
+ ...
+</div>
+@end example
+@end defun
diff --git a/doc/ref/javascript/input_list.texi b/doc/ref/javascript/input_list.texi
index bda2de83..e22d4c2b 100644
--- a/doc/ref/javascript/input_list.texi
+++ b/doc/ref/javascript/input_list.texi
@@ -1,4 +1,51 @@
-
@node input_list
@section input_list.js
+@cindex dummy component
+
+All elements with the class @code{input-list} are treated as a
+collection of input fields. Uses including setting tags on calendar
+entries.
+
+All direct children of the ``input-list'' @emph{must} have the class
+@code{unit}, and one direct child @code{unit} have the class @code{final}.
+
+@c All elements having 'input-list' ∈ =class=
+
+@c Direct children must all have 'unit' ∈ =class=
+@c One direct child must have 'final' ∈ =class=
+
+@defmethod input_list get_value
+
+@example
+querySelectorAll('input')
+ .map(x => x.value)
+ .join(@var{joinby})
+@end example
+@end defmethod
+
+@defivar input_list [data-]joinby
+ Alternative character to join by
+@end defivar
+
+@defivar input_list [data-]bindby
+ replacement for get_value
+@end defivar
+
+binds =get_value= on instances, by default returning the value
+of all =<input/>= tags joined by =,=. This can be overwritten with
+
+TODO: instead, override value?
+
+=addEventList('input',= is overwritten, registering the listener for all input
+elements.
+
+
+ ∀ children('.input-list') => 'unit' ∈ classList(child)
+
+ <div class="input-list">
+ <div class="unit"><input/></div>
+ <div class="unit final"><input/></div>
+ </div>
+@defun init_input_list
+@end defun