Участник:Alex Smotrov/qactions.js
Перейти к навигации
Перейти к поиску
if (document.URL.indexOf('&do:')>0)
$(function(){
var i = document.URL.indexOf('&do:',36);
var ops = document.URL.substring(i+4).split('&')[0].split(':');
var wpTextbox1 = document.getElementById('wpTextbox1');
var wpSummary = document.getElementById('wpSummary');
var arg, obj, value;
for (i in ops){
args = ops[i].split('=');
value = (args.length>1) ? decodeURIComponent(args[1]) : '';
switch(args[0].toLowerCase()){
case 'wikify': if (wpTextbox1 & Wikify) Wikify(); break;
case 'insert': if (wpTextbox1) wpTextbox1.value = value + wpTextbox1.value; break;
case 'append': if (wpTextbox1) wpTextbox1.value += value; break;
case 'summary': if (wpSummary) wpSummary.value += value; break;
case 'focussummary': if (wpSummary) wpSummary.focus(); break;
case 'focustext': if (wpTextbox1) wpTextbox1.focus(); break;
case 'find': if (selectInTextArea) selectInTextArea(value); break;
case 'minor': if (obj=document.getElementById('wpMinoredit')) obj.checked = (value=='1'); break;
case 'watch': if (obj=document.getElementById('wpWatchthis')) obj.checked = (value=='1'); break;
case 'preview': if (obj=document.getElementById('wpPreview')) obj.click(); return;
case 'diff': if (obj=document.getElementById('wpDiff')) obj.click(); return;
case 'save': if ((obj=document.getElementById('wpSave')) && window.enableAutoSave) obj.click(); return;
default: document.title += ' ?' + args[0];
}
}
})
function selectInTextArea(text){ //temporary here
var txtarea = document.getElementById('wpTextbox1'); if (!txtarea) return;
if (txtarea.setSelectionRange) {//Mozilla/Opera
var selPos = txtarea.value.toLowerCase().indexOf(text.toLowerCase());
if (selPos < 0) return;
txtarea.focus();
txtarea.setSelectionRange(selPos, selPos + text.length);
//try to scroll texarea next to cursor
txtarea.scrollTop = txtarea.scrollHeight * selPos / txtarea.value.length - 50;
//try to scroll the window to textarea better
//if (window.pageYOffset + window.innerHeight < txtarea.offsetHeight + 200) window.scrollTo(0,txtarea.offsetHeight - 50);
}else if (txtarea.createTextRange){ //IE
var oRange = txtarea.createTextRange();
if (oRange.findText(text)) oRange.select();
}
}