function addGodButton() {
var toolbar = document.getElementById('toolbar')
if (!toolbar) return
var i = document.createElement('span')
i.innerHTML='[Б]'
i.onclick = god
i.style.cursor = 'pointer'
toolbar.appendChild(i)
}
addOnloadHook(addGodButton)
function god ()
{
alert(1);
var txt='', hidden = [], wpTextbox1 = document.editform.wpTextbox1
var winScroll = document.documentElement.scrollTop
try {txt='ая'.replace(/а/g,'б').replace(/б(?=я)/,'в')} catch(e){}//check regexp support
if (txt != 'вя' ||
(navigator.appName=='Netscape' && navigator.appVersion.substr (0, 1) < 5))
{ alert(wmCantWork); return }
alert(2);
wpTextbox1.focus()
if (typeof wpTextbox1.selectionStart != 'undefined'
&& (navigator.productSub > 20031000 || is_safari || is_opera)) { //Mozilla/Opera/Safari3
var textScroll = wpTextbox1.scrollTop
var startPos = wpTextbox1.selectionStart
var endPos = wpTextbox1.selectionEnd
txt = wpTextbox1.value.substring(startPos, endPos)
alert(3);
if (txt == '') loc_processAllText()
else{
loc_processText()
wpTextbox1.value = wpTextbox1.value.substring(0, startPos) + txt + wpTextbox1.value.substring(endPos)
}
alert(4);
wpTextbox1.selectionStart = startPos
wpTextbox1.selectionEnd = startPos + txt.length
wpTextbox1.scrollTop = textScroll
}else if (document.selection && document.selection.createRange) { //IE
var range = document.selection.createRange()
txt = range.text
alert(5);
if (txt == '') loc_processAllText()
else{
loc_processText()
range.text = txt
if (range.moveStart) range.moveStart('character', - txt.length)
range.select()
}
alert(6);
}else // other browsers
if (confirm(wmFullText)) loc_processAllText()
document.documentElement.scrollTop = winScroll // scroll back, for IE/Opera
alert(7);
//functions
function loc_processAllText(){
txt = wpTextbox1.value
if (txt=='version') alert('Викификатор '+wmVersion)
loc_processText()
loc_r(/^[\n\r]+/, '')
wpTextbox1.value = txt
txt = ''
if (window.auto_comment && window.insertSummary && !document.editform.wpSection.value)
insertSummary('викификатор')
}
function loc_processText(){
var u = ' ' //messed by RK
if (wgNamespaceNumber % 2 || wgNamespaceNumber==4) { //is talk page
var sigs = txt.match(/\d\d:\d\d, \d\d? \S{3,8} 20\d\d \(UTC\)/g)
if (sigs && sigs.length > 1) {
alert(wmTalkPage); return
}
}
}
alert(8);
loc_hideTag('nowiki')
loc_hideTag('pre')
loc_hideTag('source')
loc_hideTag('code')
loc_hideTag('tt')
loc_hideTag('math')
loc_r(/( |\n|\r)+\{\{(·|•|\*)\}\}/g, '{{$2}}'); //before {{·/•/*}}, usually in templates
loc_hide(/{\{[\s\S]+?}}/g)//templates
loc_hide(/^ .*/mg)
loc_hide(/(https?|ftp|news|nntp|telnet|irc|gopher):\/\/[^\s\[\]<>"]+ ?/gi)
loc_hide(/^#(redirect|перенапр(авление)?)/i)
loc_hideTag('gallery')
alert(9);
loc_r(/ +(\n|\r)/g,'$1')//spaces at EOL
txt = '\n'+txt+'\n'
loc_r(/\{\{Божество([\s\r\n]+)\|/, '{{Божество D&D/d20$1\|')
alert(10);
function loc_r(r1, r2){ txt = txt.replace(r1, r2) }
function loc_hide(re){ loc_r(re, function(s){return '\x01'+hidden.push(s)+'\x02'})}
function loc_hideTag(tag){ loc_hide(RegExp('<' + tag + '( [^>]+)?>[\\s\\S]+?<\\/' + tag + '>','gi')) }
}