diff --git a/templates/main.js b/templates/main.js index dc858dc7..6652343d 100755 --- a/templates/main.js +++ b/templates/main.js @@ -45,7 +45,7 @@ function ago($timestamp) { switch(true){ case ($difference < 60) : return "" + $difference + ' ' + _('second(s)'); - case ($difference < 3600): //60*60 = 3600 + case ($difference < 3600): //60*60 = 3600 return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)'); case ($difference < 86400): //60*60*24 = 86400 return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)'); @@ -136,7 +136,7 @@ function changeStyle(styleName, link) { localStorage.stylesheet = styleName; {% endif %} {% raw %} - + // Main stylesheet if (!document.getElementById('stylesheet')) { var s = document.createElement('link'); @@ -161,18 +161,18 @@ function changeStyle(styleName, link) { } document.getElementById('code_stylesheet').href = codestyles[styleName]; - + if (document.getElementsByClassName('styles').length != 0) { var styleLinks = document.getElementsByClassName('styles')[0].childNodes; for (var i = 0; i < styleLinks.length; i++) { styleLinks[i].className = ''; } } - + if (link) { link.className = 'selected'; } - + if (typeof $ != 'undefined') $(window).trigger('stylesheet', styleName); } @@ -181,11 +181,11 @@ function changeStyle(styleName, link) { {% endraw %} {% if config.stylesheets_board %} {% raw %} - + if (!localStorage.board_stylesheets) { localStorage.board_stylesheets = '{}'; } - + var stylesheet_choices = JSON.parse(localStorage.board_stylesheets); if (board_name && stylesheet_choices[board_name]) { for (var styleName in styles) { @@ -213,7 +213,7 @@ function changeStyle(styleName, link) { function init_stylechooser() { var newElement = document.createElement('div'); newElement.className = 'styles'; - + for (styleName in styles) { var style = document.createElement('a'); style.innerHTML = '[' + styleName + ']'; @@ -225,8 +225,8 @@ function init_stylechooser() { } style.href = 'javascript:void(0);'; newElement.appendChild(style); - } - + } + document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild.nextSibling); } @@ -243,7 +243,7 @@ function highlightReply(id) { // don't highlight on middle click return true; } - + var divs = document.getElementsByTagName('div'); for (var i = 0; i < divs.length; i++) { @@ -279,10 +279,10 @@ function dopost(form) { if (form.elements['email'] && form.elements['email'].value != 'sage') { localStorage.email = form.elements['email'].value; } - + saved[document.location] = form.elements['body'].value; sessionStorage.body = JSON.stringify(saved); - + return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != ""); } @@ -301,7 +301,7 @@ function citeReply(id, with_link) { var textarea = document.getElementById('body'); if (!textarea) return false; - + if (document.selection) { // IE textarea.focus(); @@ -311,7 +311,7 @@ function citeReply(id, with_link) { var start = textarea.selectionStart; var end = textarea.selectionEnd; textarea.value = textarea.value.substring(0, start) + '>>' + id + '\n' + textarea.value.substring(end, textarea.value.length); - + textarea.selectionStart += ('>>' + id).length + 1; textarea.selectionEnd = textarea.selectionStart; } else { @@ -344,15 +344,15 @@ function rememberStuff() { localStorage.password = generatePassword(); document.forms.post.password.value = localStorage.password; } - + if (localStorage.name && document.forms.post.elements['name']) document.forms.post.elements['name'].value = localStorage.name; if (localStorage.email && document.forms.post.elements['email']) document.forms.post.elements['email'].value = localStorage.email; - + if (window.location.hash.indexOf('q') == 1) citeReply(window.location.hash.substring(2), true); - + if (sessionStorage.body) { var saved = JSON.parse(sessionStorage.body); if (get_cookie('{% endraw %}{{ config.cookies.js }}{% raw %}')) { @@ -362,14 +362,14 @@ function rememberStuff() { saved[url] = null; } sessionStorage.body = JSON.stringify(saved); - + document.cookie = '{% endraw %}{{ config.cookies.js }}{% raw %}={};expires=0;path=/;'; } if (saved[document.location]) { document.forms.post.body.value = saved[document.location]; } } - + if (localStorage.body) { document.forms.post.body.value = localStorage.body; localStorage.body = ''; @@ -391,14 +391,14 @@ var script_settings = function(script_name) { function init() { init_stylechooser(); - {% endraw %} + {% endraw %} {% if config.allow_delete %} if (document.forms.postcontrols) { document.forms.postcontrols.password.value = localStorage.password; } {% endif %} {% raw %} - + if (window.location.hash.indexOf('q') != 1 && window.location.hash.substring(1)) highlightReply(window.location.hash.substring(1)); } @@ -436,4 +436,3 @@ sc.innerHTML = 'var sc_project={{ config.statcounter_project }};var sc_invisible var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(sc, s); {% endif %} -