Участник:EvilCat/monobook.js — различия между версиями

Материал из Ролевая энциклопедии
Перейти к: навигация, поиск
м (дебаг)
м
Строка 75: Строка 75:
 
txt = '\n'+txt+'\n'
 
txt = '\n'+txt+'\n'
  
alert('тест')
+
r(/\{\{Божество([\s\r\n]+)\|/, '{{Божество D&D/d20$1|')
 
 
/* r(/Тест/i, 'Тест пройден')
 
r(/\{\{Божество([\s\r\n]*)\|/i, '{{Божество D&D/d20$1|') */
 
  
 
}
 
}

Версия 11:54, 5 марта 2012

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 ()
{
 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 }

 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)
    if (txt == '') processAllText()
    else{
      processText()
      wpTextbox1.value = wpTextbox1.value.substring(0, startPos) + txt + wpTextbox1.value.substring(endPos)
    }
    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
   if (txt == '') processAllText()
   else{
     processText()
     range.text = txt
     if (range.moveStart) range.moveStart('character', - txt.length)
     range.select() 
   }
  
 }else // other browsers
   if (confirm(wmFullText)) processAllText()

 document.documentElement.scrollTop = winScroll // scroll back, for IE/Opera


//functions

hideTag('nowiki')
hideTag('pre')
hideTag('source')
hideTag('code')
hideTag('tt')
hideTag('math')

r(/( |\n|\r)+\{\{(·|•|\*)\}\}/g, '{{$2}}'); //before {{·/•/*}}, usually in templates
hide(/{\{[\s\S]+?}}/g)//templates
hide(/^ .*/mg)
hide(/(https?|ftp|news|nntp|telnet|irc|gopher):\/\/[^\s\[\]<>"]+ ?/gi)
hide(/^#(redirect|перенапр(авление)?)/i)
hideTag('gallery')


r(/ +(\n|\r)/g,'$1')//spaces at EOL
txt = '\n'+txt+'\n'

r(/\{\{Божество([\s\r\n]+)\|/, '{{Божество D&D/d20$1|')

}