Участник:EvilCat/monobook.js — различия между версиями
м |
м (дебаг) |
||
Строка 13: | Строка 13: | ||
function god () | function god () | ||
{ | { | ||
+ | alert(1); | ||
var txt='', hidden = [], wpTextbox1 = document.editform.wpTextbox1 | var txt='', hidden = [], wpTextbox1 = document.editform.wpTextbox1 | ||
var winScroll = document.documentElement.scrollTop | var winScroll = document.documentElement.scrollTop | ||
− | + | alert(2); | |
try {txt='ая'.replace(/а/g,'б').replace(/б(?=я)/,'в')} catch(e){}//check regexp support | try {txt='ая'.replace(/а/g,'б').replace(/б(?=я)/,'в')} catch(e){}//check regexp support | ||
if (txt != 'вя' || | if (txt != 'вя' || | ||
(navigator.appName=='Netscape' && navigator.appVersion.substr (0, 1) < 5)) | (navigator.appName=='Netscape' && navigator.appVersion.substr (0, 1) < 5)) | ||
{ alert(wmCantWork); return } | { alert(wmCantWork); return } | ||
− | + | alert(3); | |
wpTextbox1.focus() | wpTextbox1.focus() | ||
− | + | alert(4); | |
if (typeof wpTextbox1.selectionStart != 'undefined' | if (typeof wpTextbox1.selectionStart != 'undefined' | ||
&& (navigator.productSub > 20031000 || is_safari || is_opera)) { //Mozilla/Opera/Safari3 | && (navigator.productSub > 20031000 || is_safari || is_opera)) { //Mozilla/Opera/Safari3 | ||
Строка 29: | Строка 30: | ||
var endPos = wpTextbox1.selectionEnd | var endPos = wpTextbox1.selectionEnd | ||
txt = wpTextbox1.value.substring(startPos, endPos) | txt = wpTextbox1.value.substring(startPos, endPos) | ||
+ | alert(5); | ||
if (txt == '') processAllText() | if (txt == '') processAllText() | ||
else{ | else{ | ||
Строка 34: | Строка 36: | ||
wpTextbox1.value = wpTextbox1.value.substring(0, startPos) + txt + wpTextbox1.value.substring(endPos) | wpTextbox1.value = wpTextbox1.value.substring(0, startPos) + txt + wpTextbox1.value.substring(endPos) | ||
} | } | ||
+ | alert(6); | ||
wpTextbox1.selectionStart = startPos | wpTextbox1.selectionStart = startPos | ||
wpTextbox1.selectionEnd = startPos + txt.length | wpTextbox1.selectionEnd = startPos + txt.length | ||
wpTextbox1.scrollTop = textScroll | wpTextbox1.scrollTop = textScroll | ||
− | + | alert(7); | |
}else if (document.selection && document.selection.createRange) { //IE | }else if (document.selection && document.selection.createRange) { //IE | ||
var range = document.selection.createRange() | var range = document.selection.createRange() | ||
txt = range.text | txt = range.text | ||
+ | alert(8); | ||
if (txt == '') processAllText() | if (txt == '') processAllText() | ||
else{ | else{ | ||
Строка 48: | Строка 52: | ||
range.select() | range.select() | ||
} | } | ||
− | + | alert(9); | |
}else // other browsers | }else // other browsers | ||
if (confirm(wmFullText)) processAllText() | if (confirm(wmFullText)) processAllText() | ||
− | + | alert(10); | |
document.documentElement.scrollTop = winScroll // scroll back, for IE/Opera | document.documentElement.scrollTop = winScroll // scroll back, for IE/Opera | ||
Строка 63: | Строка 67: | ||
hideTag('tt') | hideTag('tt') | ||
hideTag('math') | hideTag('math') | ||
− | + | alert(11); | |
r(/( |\n|\r)+\{\{(·|•|\*)\}\}/g, '{{$2}}'); //before {{·/•/*}}, usually in templates | r(/( |\n|\r)+\{\{(·|•|\*)\}\}/g, '{{$2}}'); //before {{·/•/*}}, usually in templates | ||
hide(/{\{[\s\S]+?}}/g)//templates | hide(/{\{[\s\S]+?}}/g)//templates | ||
Строка 71: | Строка 75: | ||
hideTag('gallery') | hideTag('gallery') | ||
− | + | alert(12); | |
r(/ +(\n|\r)/g,'$1')//spaces at EOL | r(/ +(\n|\r)/g,'$1')//spaces at EOL | ||
txt = '\n'+txt+'\n' | txt = '\n'+txt+'\n' | ||
r(/\{\{Божество([\s\r\n]+)\|/, '{{Божество D&D/d20$1|') | r(/\{\{Божество([\s\r\n]+)\|/, '{{Божество D&D/d20$1|') | ||
− | + | alert(13); | |
} | } |
Версия 16:49, 8 марта 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 () { alert(1); var txt='', hidden = [], wpTextbox1 = document.editform.wpTextbox1 var winScroll = document.documentElement.scrollTop alert(2); 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(3); wpTextbox1.focus() alert(4); 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(5); if (txt == '') processAllText() else{ processText() wpTextbox1.value = wpTextbox1.value.substring(0, startPos) + txt + wpTextbox1.value.substring(endPos) } alert(6); wpTextbox1.selectionStart = startPos wpTextbox1.selectionEnd = startPos + txt.length wpTextbox1.scrollTop = textScroll alert(7); }else if (document.selection && document.selection.createRange) { //IE var range = document.selection.createRange() txt = range.text alert(8); if (txt == '') processAllText() else{ processText() range.text = txt if (range.moveStart) range.moveStart('character', - txt.length) range.select() } alert(9); }else // other browsers if (confirm(wmFullText)) processAllText() alert(10); document.documentElement.scrollTop = winScroll // scroll back, for IE/Opera //functions hideTag('nowiki') hideTag('pre') hideTag('source') hideTag('code') hideTag('tt') hideTag('math') alert(11); 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') alert(12); r(/ +(\n|\r)/g,'$1')//spaces at EOL txt = '\n'+txt+'\n' r(/\{\{Божество([\s\r\n]+)\|/, '{{Божество D&D/d20$1|') alert(13); }