aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-03-15 01:36:07 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-03-15 02:25:27 +0100
commitbb7b8ee00bd2c7d26e82c2eb4a0571023e821d9f (patch)
treeb142e1dc98835237d679ab83029f5c1371453113 /doc
parentIntroduce concept of VEvent formatters in frontend. (diff)
downloadcalp-bb7b8ee00bd2c7d26e82c2eb4a0571023e821d9f.tar.gz
calp-bb7b8ee00bd2c7d26e82c2eb4a0571023e821d9f.tar.xz
Introduce user-additions in frontend.
Along with an initial example of their use.
Diffstat (limited to 'doc')
-rw-r--r--doc/ref/javascript.texi2
-rw-r--r--doc/ref/javascript/formatters.texi4
-rw-r--r--doc/ref/javascript/user-additions.texi18
3 files changed, 24 insertions, 0 deletions
diff --git a/doc/ref/javascript.texi b/doc/ref/javascript.texi
index 434b556f..25ac4f00 100644
--- a/doc/ref/javascript.texi
+++ b/doc/ref/javascript.texi
@@ -10,6 +10,7 @@
The frontend code has its entry-point in @code{script.ts}
All elements are initialized in elements.ts
+
@include javascript/clock.texi
@include javascript/lib.texi
@include javascript/eventCreator.texi
@@ -18,6 +19,7 @@ All elements are initialized in elements.ts
@include javascript/globals.texi
@include javascript/server_connect.texi
@include javascript/formatters.texi
+@include javascript/user-additions.texi
@node General Components
@section General Components
diff --git a/doc/ref/javascript/formatters.texi b/doc/ref/javascript/formatters.texi
index 65df48c4..16a988c4 100644
--- a/doc/ref/javascript/formatters.texi
+++ b/doc/ref/javascript/formatters.texi
@@ -10,3 +10,7 @@ Formatting procedures used by some components.
Each procedure takes two arguments. The HTML-element which contents
should be replaced, along with the target value, as returned by @ref{VEvent.getProperty}.
@end deftypevar
+
+@deftypevr {Window Value} {Map<string, (e:HTMLElement, s:string) => void>} formatters
+Same object as @xref{formatters-proc}. Provided for @xref{user-additions.js}.
+@end deftypevr
diff --git a/doc/ref/javascript/user-additions.texi b/doc/ref/javascript/user-additions.texi
new file mode 100644
index 00000000..706b1dd4
--- /dev/null
+++ b/doc/ref/javascript/user-additions.texi
@@ -0,0 +1,18 @@
+@node user-additions.js
+@section user-additions.js
+
+Some things in the JavaScript code is built to be user-extendable.
+The HTML-page attempts to load @code{/static/user/user-additions.js}.
+
+
+Currently; this only entails @ref{formatters}, where you could, for
+example, parse all HTTP-links in a description.
+
+@example
+window.formatters.set('description', (el, d) => @{
+ el.innerHTML = d.replaceAll(/https?:\/\/\S+/g, '<a href="$&">$&</a>');
+@})
+@end example
+
+Remember that the documents are X-HTML, so be @emph{extremely} careful
+with innerHTML.