diff --git a/templates/main.js b/templates/main.js index 71180259..0b514a80 100644 --- a/templates/main.js +++ b/templates/main.js @@ -1,5 +1,13 @@ -{% raw %}function get_cookie(cookie_name) -{ +{% raw %} + +var selectedstyle = '{% endraw %}{{ config.default_stylesheet.0 }}{% raw %}'; +var styles = [ + {% endraw %}{% for stylesheet in stylesheets %}{% raw %}['{% endraw %}{{ stylesheet.name }}{% raw %}', '{% endraw %}{{ stylesheet.uri }}{% raw %}']{% endraw %}{% if not loop.last %}{% raw %}, + {% endraw %}{% endif %}{% endfor %}{% raw %} +]; +var saved = {}; + +function get_cookie(cookie_name) { var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); if(results) return (unescape(results[2])); @@ -7,9 +15,8 @@ return null; } -function highlightReply(id) -{ - if(window.event !== undefined && event.which == 2) { +function highlightReply(id) { + if(typeof window.event != "undefined" && event.which == 2) { // don't highlight on middle click return true; } @@ -21,23 +28,18 @@ function highlightReply(id) divs[i].className = divs[i].className.replace(/highlighted/, ''); } if (id) { - post = document.getElementById('reply_'+id); + var post = document.getElementById('reply_'+id); if(post) post.className += ' highlighted'; } } -function focusId(id) -{ - document.getElementById(id).focus(); - init(); -} function generatePassword() { - pass = ''; - chars = '{% endraw %}{{ config.genpassword_chars }}{% raw %}'; - for(i=0;i<8;i++) { - rnd = Math.floor(Math.random() * chars.length); - pass += chars.substring(rnd,rnd + 1); + var pass = ''; + var chars = '{% endraw %}{{ config.genpassword_chars }}{% raw %}'; + for(var i = 0; i < 8; i++) { + var rnd = Math.floor(Math.random() * chars.length); + pass += chars.substring(rnd, rnd + 1); } return pass; } @@ -56,17 +58,17 @@ function dopost(form) { return form.elements['body'].value != "" || form.elements['file'].value != ""; } function citeReply(id) { - body = document.getElementById('body'); + var body = document.getElementById('body'); if (document.selection) { // IE body.focus(); - sel = document.selection.createRange(); + var sel = document.selection.createRange(); sel.text = '>>' + id + '\n'; } else if (body.selectionStart || body.selectionStart == '0') { // Mozilla - start = body.selectionStart; - end = body.selectionEnd; + var start = body.selectionStart; + var end = body.selectionEnd; body.value = body.value.substring(0, start) + '>>' + id + '\n' + body.value.substring(end, body.value.length); } else { // ??? @@ -74,13 +76,6 @@ function citeReply(id) { } } -var selectedstyle = '{% endraw %}{{ config.default_stylesheet.0 }}{% raw %}'; -var styles = [ - {% endraw %}{% for stylesheet in stylesheets %}{% raw %}['{% endraw %}{{ stylesheet.name }}{% raw %}', '{% endraw %}{{ stylesheet.uri }}{% raw %}']{% endraw %}{% if not loop.last %}{% raw %}, - {% endraw %}{% endif %}{% endfor %}{% raw %} -]; -var saved = {}; - function changeStyle(x) { localStorage.stylesheet = styles[x][1]; document.getElementById('stylesheet').href = styles[x][1]; @@ -88,7 +83,7 @@ function changeStyle(x) { } if(localStorage.stylesheet) { - for(x=0;x