From 0a361a268cbbaac447f8a7c04514a6dd056a2a79 Mon Sep 17 00:00:00 2001 From: andreimarcu Date: Wed, 15 Jun 2016 01:17:25 -0700 Subject: [PATCH] Get rid of highlightjs-line-numbers.js --- static/css/highlight/lines.css | 28 +++++++++++++++++++ static/js/bin_hljs.js | 10 ++++++- .../highlight/highlightjs-line-numbers.min.js | 3 -- templates/display/bin.html | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 static/css/highlight/lines.css delete mode 100644 static/js/highlight/highlightjs-line-numbers.min.js diff --git a/static/css/highlight/lines.css b/static/css/highlight/lines.css new file mode 100644 index 0000000..b476e2a --- /dev/null +++ b/static/css/highlight/lines.css @@ -0,0 +1,28 @@ +#normal-code { + border-left: 1px solid #ccc; + margin-left: 36px; + position: relative; +} + +#normal-code code { + counter-reset: linenumbers; +} + +#normal-code code div:before { + content: counter(linenumbers); + counter-increment: linenumbers; + left: -36px; + width: 28px; + position: absolute; + + text-align: right; + padding-right: 5px; + color: #999; + + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} \ No newline at end of file diff --git a/static/js/bin_hljs.js b/static/js/bin_hljs.js index 5ccbd53..083ef4c 100644 --- a/static/js/bin_hljs.js +++ b/static/js/bin_hljs.js @@ -2,6 +2,14 @@ hljs.tabReplace = ' '; hljs.initHighlightingOnLoad(); -hljs.initLineNumbersOnLoad(); + +var codeb = document.getElementById("codeb"); +var lines = codeb.innerHTML.split("\n"); +codeb.innerHTML = ""; +for (var i = 0; i < lines.length; i++) { + var div = document.createElement("div"); + div.innerHTML = lines[i] + "\n"; + codeb.appendChild(div); +}; // @license-end diff --git a/static/js/highlight/highlightjs-line-numbers.min.js b/static/js/highlight/highlightjs-line-numbers.min.js deleted file mode 100644 index 8ef50bc..0000000 --- a/static/js/highlight/highlightjs-line-numbers.min.js +++ /dev/null @@ -1,3 +0,0 @@ -// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat -!function(e){"use strict";function t(){e.addEventListener("load",function(){try{var e=document.querySelectorAll("code.hljs");for(var t in e)e.hasOwnProperty(t)&&n(e[t])}catch(r){console.error("LineNumbers error: ",r)}})}function n(e){if("object"==typeof e){var t=e.parentNode,n=r(t.textContent);if(n>1){for(var o="",l=0;n>l;l++)o+=l+1+"\n";var c=document.createElement("code");c.className="hljs hljs-line-numbers",c.style["float"]="left",c.textContent=o,t.insertBefore(c,e)}}}function r(e){if(0===e.length)return 0;var t=/\r\n|\r|\n/g,n=e.match(t);return n=n?n.length:0,e[e.length-1].match(t)||(n+=1),n}"undefined"==typeof e.hljs?console.error("highlight.js not detected!"):(e.hljs.initLineNumbersOnLoad=t,e.hljs.lineNumbersBlock=n)}(window); -// @license-end \ No newline at end of file diff --git a/templates/display/bin.html b/templates/display/bin.html index 00d8177..a3aab36 100644 --- a/templates/display/bin.html +++ b/templates/display/bin.html @@ -2,6 +2,7 @@ {% block head %} + {% endblock %} {% block innercontentmore %} class="scrollable"{% endblock %} @@ -44,7 +45,6 @@ {% if extra.lang_hl != "text" %} - {% endif %}