« get me outta code hell

this commit is very large because i am doing work - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/lazy-fallback.js
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2020-10-28 17:33:03 -0300
committer(quasar) nebula <towerofnix@gmail.com>2020-10-28 17:33:03 -0300
commit25798012d6a0ab3ba0c439f372bbedc5943ac47e (patch)
tree71dabc10f3283027d54c1d514ef1bf5e6d243800 /lazy-fallback.js
parentf017dfe9c87bdf29430a26aa2b441d56e62c9195 (diff)
this commit is very large because i am doing work
and i would like to not lose progress in case i really screw those git
moves up bad

also it puts everything new into tracking which is kinda nice
Diffstat (limited to 'lazy-fallback.js')
-rw-r--r--lazy-fallback.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/lazy-fallback.js b/lazy-fallback.js
new file mode 100644
index 00000000..a66b922c
--- /dev/null
+++ b/lazy-fallback.js
@@ -0,0 +1,19 @@
+// Fall8ack code for lazy loading. 8asically, this runs if the stuff in
+// lazy-loading.js doesn't; while that file's written with the same kinda
+// modern syntax/APIs used all over the site, displaying the images is a pretty
+// damn important thing to do, so we have this goodol' Olde JavaScripte fix for
+// 8rowsers which have JS ena8led (and so won't display gener8ted <noscript>
+// tags) 8ut don't support what we use for lazy loading.
+
+if (!window.lazyLoadingExecuted) {
+    lazyLoadingFallback();
+}
+
+function lazyLoadingFallback() {
+    var lazyElements = document.getElementsByClassName('lazy');
+    for (var i = 0; i < lazyElements.length; i++) {
+        var element = lazyElements[i];
+        var original = element.getAttribute('data-original');
+        element.setAttribute('src', original);
+    }
+}