remove inline js on pastebin pages

This commit is contained in:
mutantmonkey 2015-10-03 23:58:56 -07:00
parent 335517bf17
commit b83f11e80a
3 changed files with 12 additions and 14 deletions

7
static/js/bin.js Executable file → Normal file
View File

@ -14,6 +14,11 @@ function init() {
navlist.insertBefore(editA, navlist.firstChild); navlist.insertBefore(editA, navlist.firstChild);
navlist.insertBefore(separator, navlist.children[1]); 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"); var normalcontent = document.getElementById("normal-content");
normalcontent.removeChild(document.getElementById("normal-code")); normalcontent.removeChild(document.getElementById("normal-code"));
var editordiv = document.getElementById("editor"); var editordiv = document.getElementById("editor");
editordiv.style.display = "block"; editordiv.style.display = "block";

2
static/js/bin_hljs.js Normal file
View File

@ -0,0 +1,2 @@
hljs.tabReplace = ' ';
hljs.initHighlightingOnLoad();

View File

@ -46,25 +46,16 @@
{% block main %} {% block main %}
<div id="normal-content" class="normal {% if extra.lang_hl != "story" %}fixed{% endif %}"> <div id="normal-content" class="normal {% if extra.lang_hl != "story" %}fixed{% endif %}">
<pre id="normal-code"><code id="codeb" style="white-space: pre-wrap;" class="{{ extra.lang_hl }}">{{ extra.contents }}</pre></code> <pre id="normal-code"><code id="codeb" style="white-space: pre-wrap;" class="{{ extra.lang_hl }}">{{ extra.contents }}</code></pre>
<div id="editor" style="display: none; height: 800px; font-size: 11px;">{{ extra.contents }}</div> <div id="editor" style="display: none; height: 800px; font-size: 11px;" data-lang="{{ extra.lang_ace }}">{{ extra.contents }}</div>
</div> </div>
{% if extra.lang_hl != "text" %} {% if extra.lang_hl != "text" %}
<script src="/static/js/highlight/highlight.pack.js"></script> <script src="/static/js/highlight/highlight.pack.js"></script>
<script> <script src="/static/js/bin_hljs.js"></script>
hljs.tabReplace = ' ';
hljs.initHighlightingOnLoad();
</script>
{% endif %} {% endif %}
<script type="text/javascript" src="/static/js/bin.js"></script>
<script src="/static/js/ace/ace.js"></script> <script src="/static/js/ace/ace.js"></script>
<script type="text/javascript"> <script src="/static/js/bin.js"></script>
var editor = ace.edit("editor");
editor.getSession().setMode("ace/mode/{{ extra.lang_ace }}");
editor.setTheme("ace/theme/tomorrow");
</script>
{% endblock %} {% endblock %}