diff options
author | Yorhel <git@yorhel.nl> | 2010-10-08 16:23:29 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2010-10-08 16:23:29 +0200 |
commit | 60a338e2f039ff9ef3b040cb4d9c73863eb6183c (patch) | |
tree | bf422ad743dd76e8656269d78f55f54a25bfd794 | |
parent | c28e96544351fb52f40262fa42c4acec4b7be2d3 (diff) |
Replaced some annoying getElementById calls.
-rw-r--r-- | script.js | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1,5 +1,9 @@ // Stolen from VNDB +function byId(n) { + return document.getElementById(n) +} + function tag() { if(arguments.length == 1) return typeof arguments[0] != 'object' ? document.createTextNode(arguments[0]) : arguments[0]; @@ -46,18 +50,18 @@ function getCookie(n) { ////// function setsyn(w) { - document.getElementById('s').value = w.textContent; + byId('s').value = w.textContent; return false; } function showall() { - document.getElementById('syntax').style.display = document.getElementById('syntax').style.display == 'none' ? '' : 'none'; + byId('syntax').style.display = byId('syntax').style.display == 'none' ? '' : 'none'; return false; } function unpaste(w,u) { - var close = function () { document.getElementById('unconfirm').parentNode.removeChild(document.getElementById('unconfirm')); return false; }; - if(document.getElementById('unconfirm')) + var close = function () { byId('unconfirm').parentNode.removeChild(byId('unconfirm')); return false; }; + if(byId('unconfirm')) return close(); addBody(tag('div', { id: 'unconfirm' }, tag('form', { method: 'post', action: u }, 'Please enter your passcode to delete this paste.', tag('br', null), @@ -69,7 +73,7 @@ function unpaste(w,u) { } // Copy passcode from cookie to passcode field -var x = document.getElementById('p'); +var x = byId('p'); if(x) { x.value = getCookie('secret_passcode') || ''; } |