From bb7b8ee00bd2c7d26e82c2eb4a0571023e821d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 15 Mar 2022 01:36:07 +0100 Subject: Introduce user-additions in frontend. Along with an initial example of their use. --- doc/ref/javascript/formatters.texi | 4 ++++ doc/ref/javascript/user-additions.texi | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 doc/ref/javascript/user-additions.texi (limited to 'doc/ref/javascript') 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 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, '$&'); +@}) +@end example + +Remember that the documents are X-HTML, so be @emph{extremely} careful +with innerHTML. -- cgit v1.2.3