diff options
author | luxagraf <sng@luxagraf> | 2021-02-22 23:16:59 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf> | 2021-02-22 23:16:59 -0500 |
commit | 0ea88c5c740ba04b88591eb2f84dba9ed5351f9a (patch) | |
tree | 1eaa80c69276febb697dba94c63dcfaa84da8fe4 /app | |
parent | f1b3ae97fcf704f0e1fe9a9a572561a45eb5a7b3 (diff) |
html: eliminated a lot of inline JS
Diffstat (limited to 'app')
-rw-r--r-- | app/pages/templates/pages/luxagraf/page_detail.html | 7 | ||||
-rw-r--r-- | app/posts/templates/posts/essay_detail.html | 75 | ||||
-rw-r--r-- | app/posts/templates/posts/fieldnote_detail.html | 19 | ||||
-rw-r--r-- | app/posts/templates/posts/post_detail.html | 73 | ||||
-rw-r--r-- | app/posts/templates/posts/src_detail.html | 27 |
5 files changed, 9 insertions, 192 deletions
diff --git a/app/pages/templates/pages/luxagraf/page_detail.html b/app/pages/templates/pages/luxagraf/page_detail.html index 4029f24..4096c0f 100644 --- a/app/pages/templates/pages/luxagraf/page_detail.html +++ b/app/pages/templates/pages/luxagraf/page_detail.html @@ -31,10 +31,3 @@ {%endif%} </main> {% endblock %} -{% block js %} -<script src="/media/js/lightbox.js" type="text/javascript"></script> -<script>var opts={captions:true,onload:function(){var im=document.getElementById("jslghtbx-contentwrapper");var link=im.appendChild(document.createElement('a')) -link.href=im.firstChild.src;link.innerHTML="open ";link.target="_blank";link.setAttribute('class','p-link');im.appendChild(link);}};var lightbox=new Lightbox();lightbox.load(opts);</script> -{% endblock %} - - diff --git a/app/posts/templates/posts/essay_detail.html b/app/posts/templates/posts/essay_detail.html index b6a0db8..c4d2b66 100644 --- a/app/posts/templates/posts/essay_detail.html +++ b/app/posts/templates/posts/essay_detail.html @@ -128,77 +128,6 @@ {%endif%} {% endblock %} {% block js %} -<script type="text/javascript"> -document.addEventListener("DOMContentLoaded", function(event) { - var leaflet = document.createElement('script'); - leaflet.src = "/media/js/leaflet-master/leaflet-mod.js"; - document.body.appendChild(leaflet); - var lightbox = document.createElement('script'); - lightbox.src = "/media/js/lightbox.js"; - document.body.appendChild(lightbox); - leaflet.onload = function(){ - var detail = document.createElement('script'); - detail.src = "/media/js/detail.min.js"; - document.body.appendChild(detail); - {% with object.get_template_name_display as t %}{%if t == "single" or t == "single-dark" %} - detail.onload = function(){ - createMap(); - var open = false; - } - {%endif%}{%endwith%} - } - - {%comment%} - lightbox.onload = function() { - var opts= { - //nextOnClick: false, - captions: true, - onload: function(){ - var im = document.getElementById("jslghtbx-contentwrapper"); - var link = im.appendChild(document.createElement('a')) - link.href = im.firstChild.src; - link.innerHTML= "open "; - link.target = "_blank"; - link.setAttribute('class', 'p-link'); - im.appendChild(link); - } - }; - var lightbox = new Lightbox(); - lightbox.load(opts); - } - {%endcomment%} - {% if object.enable_comments %} -{% get_comment_count for object as comment_count %} -{%if comment_count > 0 %} - //delay loading of gravatar images using noscript data-hash attribute - dataattr = document.getElementsByClassName("datahashloader"); - for(var i=0; i<dataattr.length; i++) { - var c = dataattr[i].parentNode; - var img = document.createElement("img"); - img.src = 'https://images.luxagraf.net/gravcache/' + dataattr[i].getAttribute('data-hash') + '.jpg'; - img.className += "gravatar"; - c.insertBefore(img, c.childNodes[3]); - } -{%endif%} -{%endif%} -{% if object.has_video %} -var tester = document.getElementsByClassName("vidauto"); -var wrapper = document.getElementById('wrapper'); -var dist = 100; - -window.onscroll = function() { - for (var i=0; i<tester.length; i++) { - checkVisible(tester[i]) ? tester[i].play() : tester[i].pause(); - } -}; - -function checkVisible(elm) { - var rect = elm.getBoundingClientRect(); - var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight); - return !(rect.bottom < 0 || rect.top - viewHeight >= 0); -} -{%endif%} - -}); -</script> +<script src="/media/js/leaflet-master/leaflet-mod.js"></script> +<script src="/media/js/detail.min.js"></script> {%endblock%} diff --git a/app/posts/templates/posts/fieldnote_detail.html b/app/posts/templates/posts/fieldnote_detail.html index a645e86..f678400 100644 --- a/app/posts/templates/posts/fieldnote_detail.html +++ b/app/posts/templates/posts/fieldnote_detail.html @@ -47,22 +47,7 @@ </article> </main> {% endblock %} - {% block js %} -<script> -document.addEventListener("DOMContentLoaded", function(event) { - var leaflet = document.createElement('script'); - leaflet.src = "/media/js/leaflet-master/leaflet-mod.js"; - document.body.appendChild(leaflet); - leaflet.onload = function(){ - var detail = document.createElement('script'); - detail.src = "/media/js/detail.min.js"; - document.body.appendChild(detail); - detail.onload = function(){ - createMap(); - var open = false; - } - } -}); -</script> +<script src="/media/js/leaflet-master/leaflet-mod.js"></script> +<script src="/media/js/detail.min.js"></script> {%endblock%} diff --git a/app/posts/templates/posts/post_detail.html b/app/posts/templates/posts/post_detail.html index 4c897fc..b7c31fa 100644 --- a/app/posts/templates/posts/post_detail.html +++ b/app/posts/templates/posts/post_detail.html @@ -109,75 +109,6 @@ {%endif%} {% endblock %} {% block js %} -<script type="text/javascript"> -document.addEventListener("DOMContentLoaded", function(event) { - var leaflet = document.createElement('script'); - leaflet.src = "/media/js/leaflet-master/leaflet-mod.js"; - document.body.appendChild(leaflet); - var lightbox = document.createElement('script'); - lightbox.src = "/media/js/lightbox.js"; - document.body.appendChild(lightbox); - leaflet.onload = function(){ - var detail = document.createElement('script'); - detail.src = "/media/js/detail.min.js"; - document.body.appendChild(detail); - {% with object.get_template_name_display as t %}{%if t == "single" or t == "single-dark" %} - detail.onload = function(){ - createMap(); - var open = false; - } - {%endif%}{%endwith%} - } - - lightbox.onload = function() { - var opts= { - //nextOnClick: false, - captions: true, - onload: function(){ - var im = document.getElementById("jslghtbx-contentwrapper"); - var link = im.appendChild(document.createElement('a')) - link.href = im.firstChild.src; - link.innerHTML= "open "; - link.target = "_blank"; - link.setAttribute('class', 'p-link'); - im.appendChild(link); - } - }; - var lightbox = new Lightbox(); - lightbox.load(opts); - } - {% if object.enable_comments %} -{% get_comment_count for object as comment_count %} -{%if comment_count > 0 %} - //delay loading of gravatar images using noscript data-hash attribute - dataattr = document.getElementsByClassName("datahashloader"); - for(var i=0; i<dataattr.length; i++) { - var c = dataattr[i].parentNode; - var img = document.createElement("img"); - img.src = 'https://images.luxagraf.net/gravcache/' + dataattr[i].getAttribute('data-hash') + '.jpg'; - img.className += "gravatar"; - c.insertBefore(img, c.childNodes[3]); - } -{%endif%} -{%endif%} -{% if object.has_video %} -var tester = document.getElementsByClassName("vidauto"); -var wrapper = document.getElementById('wrapper'); -var dist = 100; - -window.onscroll = function() { - for (var i=0; i<tester.length; i++) { - checkVisible(tester[i]) ? tester[i].play() : tester[i].pause(); - } -}; - -function checkVisible(elm) { - var rect = elm.getBoundingClientRect(); - var viewHeight = Math.max(document.documentElement.clientHeight, window.innerHeight); - return !(rect.bottom < 0 || rect.top - viewHeight >= 0); -} -{%endif%} - -}); -</script> +<script src="/media/js/leaflet-master/leaflet-mod.js"></script> +<script src="/media/js/detail.min.js"></script> {%endblock%} diff --git a/app/posts/templates/posts/src_detail.html b/app/posts/templates/posts/src_detail.html index 675531c..232bba0 100644 --- a/app/posts/templates/posts/src_detail.html +++ b/app/posts/templates/posts/src_detail.html @@ -111,27 +111,6 @@ </main> {% endblock %} {% block js %} -<script type="text/javascript"> -window.onload = function() { - {% if object.enable_comments %} -{%if comment_count > 0 %} - //delay loading of gravatar images using noscript data-hash attribute - dataattr = document.getElementsByClassName("datahashloader"); - for(var i=0; i<dataattr.length; i++) { - var c = dataattr[i].parentNode; - var img = document.createElement("img"); - img.src = 'https://images.luxagraf.net/gravcache/' + dataattr[i].getAttribute('data-hash') + '.jpg'; - img.className += "gravatar"; - c.insertBefore(img, c.childNodes[3]); - } -{%endif%} -{%endif%} - {% with object.get_template_name_display as t %}{%if t == "single" or t == "single-dark" %} - createMap(); - var open = false; - {%endif%}{%endwith%} -} -</script> -{% if object.has_code %} -{%endif %} -{% endblock %} +<script src="/media/js/leaflet-master/leaflet-mod.js"></script> +<script src="/media/js/detail.min.js"></script> +{%endblock%} |