diff --git a/assets/javascripts/loader.js b/assets/javascripts/loader.js index 87ddf36..80ae9f0 100644 --- a/assets/javascripts/loader.js +++ b/assets/javascripts/loader.js @@ -1,29 +1,32 @@ -function updateCodes() { +function updateCodes(file_class) { + $('table.syntaxhl th.line-num').remove(); $('table.syntaxhl').each( function(i, block) { var parentBlock = $(this).parent() var code = ''; var line = 0; - $(this).find('td pre').each( - function(i, block) { - line++; + $(this).find('td pre').each(function(i, block) { + line++; - var html = $(this).html() - if (!html.trim()) html = "\n" - code += html -// code += '' + line -// + '' + $(this).html() - }) + var html = $(this).html() + if (!html.trim()) + html = "\n" + code += html + }) $(this).remove() - parentBlock.append('
' + code
- + '
')
+ if (file_class) {
+ var header = ''
+ } else {
+ var header = '';
+ }
+ parentBlock.append(header + code + '
')
});
$('pre code:not(.hljs)').each(function(i, block) {
if (!$(this).hasClass('nohighlight')) {
$(this).html($.trim($(this).html()));
hljs.highlightBlock($(this)[0]);
- // numberLines($(this).parent()[0])
$(this).parent().show();
}
});
@@ -38,9 +41,15 @@ function updateCodes() {
}
$(document).ready(function() {
- updateCodes();
+
+ var file_class = ''
+ if ($('body').hasClass('controller-attachments')) {
+ file_class = document.location.toString().split('.').pop()
+ }
+
+ updateCodes(file_class);
setInterval(function() {
- updateCodes();
+ updateCodes(file_class);
}, 5000);
$(document).ajaxComplete(function() {
updateCodes();