MediaWiki:Common.js

/*  Changes  so that it'll show the logical color symbol, but clicking on it  will do insertTags(, , '')

Used in http://nethack.wikia.com/wiki/MediaWiki:Edittools

Relies on specific behaviour of the logical color templates: http://nethack.wikia.com/wiki/Category:Function_templates function WikiHack_replacechars { var l = document.getElementsByTagName('span'); if (!l) return; for (var i = 0; i < l.length; i++) { if (l[i].className == "NH_replacechars") { for (var j = 0; j < l[i].childNodes.length; j++) { var fc = l[i].childNodes[j]; if (fc.className && fc.className.match(/^nhsym clr-/)) { var clr = fc.className.replace("nhsym clr-", ""); var chr = fc.innerHTML; var a = document.createElement('a'); a.setAttribute('href', '#'); a.setAttribute('onclick', 'javascript:insertTags("","",""); return false'); a.appendChild(fc.cloneNode(true)); l[i].replaceChild(a, fc); }     }    }  } }

if(wgAction == 'edit' || wgAction == 'submit') addOnloadHook(WikiHack_replacechars)