summaryrefslogtreecommitdiff
path: root/elm/Lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-11-03 14:12:35 +0100
committerYorhel <git@yorhel.nl>2019-11-10 12:44:55 +0100
commitcc4607635279792b59953bba2e3cb4a3928e76df (patch)
tree227627601aa35df51e2ca10ff0006495bb933e9e /elm/Lib
parent6ae025a405ea6e40c37a183ba7f3a98c4d9e39cb (diff)
Reorganize JS and Elm instantiation + more efficient ulist loading
The order in which .js files are concatenated is (and always has been) important, so rather than relying on name order I've changed that to an explicit $JS_FILES list in the Makefile. Less convenient, but at least we have more freedom regarding .js file naming and organization now. Rather than encoding the Elm flags as JSON in 'data-' attributes, I've added a system for global page variables (pagevars) where the Elm flags are now stored separately from their HTML tags. This has the advantage of more efficient encoding (no more &quot;s), faster parsing (just a single JSON.parse()), and easier/more efficient modification of the Elm arguments from JS. The pagevars provide a unified way of passing other variables to JS as well, which I've used to deduplicate the list of labels on the new ulist page. That shaves off a good 40 KiB on the page size for a typical listing. Whether all of this actually improves the page loading time, I don't really know. Most of the slowness in Firefox seems to come from simply instantiating many <input time="date"> objects.
Diffstat (limited to 'elm/Lib')
-rw-r--r--elm/Lib/Ffi.elm2
-rw-r--r--elm/Lib/Ffi.js13
2 files changed, 14 insertions, 1 deletions
diff --git a/elm/Lib/Ffi.elm b/elm/Lib/Ffi.elm
index 9c3b1c23..c073b4a6 100644
--- a/elm/Lib/Ffi.elm
+++ b/elm/Lib/Ffi.elm
@@ -5,7 +5,7 @@
-- This module is a hack to work around the lack of an FFI (Foreign Function
-- Interface) in Elm. The functions in this module are stubs, their
-- implementations are replaced by the Makefile with calls to
--- window.elmFfi_<name> and the actual implementations are in 1-ffi.js.
+-- window.elmFfi_<name> and the actual implementations are in Ffi.js.
--
-- Use sparingly, all of this will likely break in future Elm versions.
module Lib.Ffi exposing (..)
diff --git a/elm/Lib/Ffi.js b/elm/Lib/Ffi.js
new file mode 100644
index 00000000..c06314ff
--- /dev/null
+++ b/elm/Lib/Ffi.js
@@ -0,0 +1,13 @@
+window.elmFfi_innerHtml = function(wrap,call) { // \s -> _VirtualDom_property('innerHTML', _Json_wrap(s))
+ return function(s) {
+ return {
+ $: 'a2',
+ n: 'innerHTML',
+ o: wrap(s)
+ }
+ }
+};
+
+window.elmFfi_elemCall = function(wrap,call) { // _Browser_call
+ return call
+};