From b83f11e80a9866eeb49588a918938f4570a26a9f Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sat, 3 Oct 2015 23:58:56 -0700 Subject: [PATCH] remove inline js on pastebin pages --- static/js/bin.js | 7 ++++++- static/js/bin_hljs.js | 2 ++ templates/display/bin.html | 17 ++++------------- 3 files changed, 12 insertions(+), 14 deletions(-) mode change 100755 => 100644 static/js/bin.js create mode 100644 static/js/bin_hljs.js diff --git a/static/js/bin.js b/static/js/bin.js old mode 100755 new mode 100644 index 4d26afc..b610083 --- a/static/js/bin.js +++ b/static/js/bin.js @@ -14,6 +14,11 @@ function init() { navlist.insertBefore(editA, navlist.firstChild); navlist.insertBefore(separator, navlist.children[1]); + var lang = document.getElementById('editor').getAttribute('data-lang'); + var editor = ace.edit("editor"); + editor.getSession().setMode("ace/mode/" + lang); + editor.setTheme("ace/theme/tomorrow"); + } @@ -25,7 +30,7 @@ function edit() { var normalcontent = document.getElementById("normal-content"); normalcontent.removeChild(document.getElementById("normal-code")); - + var editordiv = document.getElementById("editor"); editordiv.style.display = "block"; diff --git a/static/js/bin_hljs.js b/static/js/bin_hljs.js new file mode 100644 index 0000000..ff8ef6e --- /dev/null +++ b/static/js/bin_hljs.js @@ -0,0 +1,2 @@ +hljs.tabReplace = ' '; +hljs.initHighlightingOnLoad(); diff --git a/templates/display/bin.html b/templates/display/bin.html index 433cbb2..9c77584 100644 --- a/templates/display/bin.html +++ b/templates/display/bin.html @@ -46,25 +46,16 @@ {% block main %}
-
{{ extra.contents }}
- +
{{ extra.contents }}
+
{% if extra.lang_hl != "text" %} - + {% endif %} - - - + {% endblock %}