Move scripts from admin changeform to their own JS file
authorMagnus Hagander <magnus@hagander.net>
Thu, 20 Dec 2018 14:42:57 +0000 (15:42 +0100)
committerMagnus Hagander <magnus@hagander.net>
Thu, 20 Dec 2018 16:18:11 +0000 (17:18 +0100)
Could be made more efficient by combining some files, but tihs is just
the /admin/ interface so not used very often.

media/js/admin_pgweb.js [new file with mode: 0644]
templates/admin/change_form_pgweb.html

diff --git a/media/js/admin_pgweb.js b/media/js/admin_pgweb.js
new file mode 100644 (file)
index 0000000..cf83ee4
--- /dev/null
@@ -0,0 +1,8 @@
+window.onload = function() {
+    tael = document.getElementsByTagName('textarea');
+    for (i = 0; i < tael.length; i++) {
+        if (tael[i].className.indexOf('markdown_preview') >= 0) {
+            attach_showdown_preview(tael[i].id, 1);
+        }
+    }
+}
index e458fb964a648cf13fa1314639b58de3679cdfc9..614b5ad070ec404abd2474aeda87bf5c91953b95 100644 (file)
@@ -11,16 +11,7 @@ Note that the summary field can use
 <link rel="stylesheet" type="text/css" href="/media/css/showdown_preview.css" />
 <script type="text/javascript" src="/media/showdown/showdown.js"></script>
 <script type="text/javascript" src="/media/js/showdown_preview.js"></script>
-<script type="text/javascript">
-   window.onload = function() {
-      tael = document.getElementsByTagName('textarea');
-      for (i = 0; i < tael.length; i++) {
-         if (tael[i].className.indexOf('markdown_preview') >= 0) {
-           attach_showdown_preview(tael[i].id, 1);
-         }
-      }
-   }
-</script>
+<script type="text/javascript" src="/media/js/admin_pgweb.js"></script>
 {%endblock%}
 
 {%if notifications%}