User:Selmo/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Selmo/monobook.css. |
// [[User:Lupin/popups.js]]
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
// Script from [[User:Lupin/recent2.js]]
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></s'+'cript>');
// CHECK THAT I'VE REMEMBERED TO SIGN TALK PAGES AND IF SURE DO IT AUTOMATIC:
// *** aut. signing / (automatische Unterschrift) *** [[User:Olliminatore/signing.js]]
// created 23.04.2006 by [[User:Olliminatore]]
// updated 23.04.2006 by [[:en:User:Ilmari Karonen]]
// current version 1.48 13.08.2006
//<pre><nowiki>
// Helper-function
String.prototype.trim = function(){return this.replace(/^\s*|\s*$/g,"")};
if (typeof usersignature == 'undefined') usersignature = ' --\~\~\~\~\n';
addOnloadHook(function(){
if(!document.editform) return;
var title = encodeURI(document.title); // object to string
// regarded pages type encoded
var regpages=new Array('talk:', 'Talk:', ':Village pump', ':Articles for deletion', ':Requests for deletion', ':Requests for ');
for(p in regpages)
if(title.indexOf(regpages[p])!=-1){
regpages=false;
break
}
if(regpages) return;
var txtarea=document.editform.wpTextbox1;
var txtOld=txtarea.value.trim();
// txtOld_l=txtOld.length
var txtOldEnd=txtOld.slice(-24);
var tNode = document.editform.wpMinoredit.parentNode
setSigBox()
tNode.insertBefore(neuB, tNode.getElementsByTagName("DIV").item(0));
var sig = /~{3}/g
function doSign(event){
if(document.editform.onsubmit==''){ // only once!
removeEvent(document.editform.wpSave,"click",doSign);
removeEvent(document.editform.wpPreview,"click",doSign);
}
if(document.editform.onsubmit=='') removeEvent(document.editform.wpSave,"click",doSign); // only once!
if(document.editform.wpMinoredit.checked || !sigBox.checked) return;
var cOld = txtOld.match(/<nowiki>.*?~{3}.*?<\/nowiki>/g); if (cOld) cOld = cOld.length;
var cNew = sig.exec(txtarea.value); if (cNew) cNew = cNew.length;
if(cNew <= cOld){ // then search a set position
txt=txtarea.value.trim();
txtEnd=txt.slice(-24);
if(txtOldEnd!=txtEnd) return txtarea.value = txt + usersignature; // aut. underwrite
else { // post between
pos = getCaretPos(txtarea);
pos = txt.indexOf('\n', pos); // go to the post-end
txtEnds = txt.substr(pos,24).replace(/(^\s*)/,""); // after
txtpEnds = txt.slice(pos-18,pos); // before
oldp = txtOld.indexOf(txtEnds);
if(oldp!=-1 && oldp < pos - 3 && txtOld.indexOf(txtpEnds+RegExp.$1+txtEnds)==-1) // if some added
return txtarea.value = txt.slice(0,pos).trim() + usersignature + txt.slice(pos+1);
}
// FIXME: the edit-end is not found
}
else if(!sig.test(txtOld) || cOld < cNew) return;
if (event) event=(window.Event)? event.target: event.srcElement;
if (event.name == 'wpPreview') return; // not for preview
return document.editform.onsubmit=new Function("document.editform.onsubmit='';return confirm('No signing was found. Continue anyway?')");
};
addEvent(document.editform.wpSave,"click", doSign);
addEvent(document.editform.wpPreview,"click", doSign);
addEvent(document.editform.wpMinoredit,"click", setSigBox);
});
var sigBox = document.createElement("input");
sigBox.setAttribute('type','checkbox');
sigBox.setAttribute('name','wpSigning');
sigBox.setAttribute('id','wpSigning');
sigBox.setAttribute('checked','checked');
sigBox.defaultChecked=true;
var neuB = document.createElement("label");
neuB.appendChild(sigBox);
neuB.appendChild(document.createTextNode("Undersign"));
neuB.setAttribute('for','wpSigning');
neuB.setAttribute('title','This edit automatic undersigning.');
function setSigBox(){
if(document.editform.wpMinoredit.checked)
sigBox.setAttribute('disabled', 'disabled');
else
sigBox.removeAttribute('disabled');
}
function getCaretPos(txtObj) {
if (txtObj.setSelectionRange) return txtObj.selectionStart; // NS like
else if(!document.selection) return 0; // not IE like
txtObj.focus();
var c="\001", pos=0;
var range=document.selection.createRange();
var txt=range.text, dul=range.duplicate();
dul.moveToElementText(txtObj);
range.text=txt+c;
pos=(dul.text.indexOf(c));
range.moveStart('character',-1);
range.text="";
return pos;
};
/* add/removeEvent Original idea by John Resig
Tweaked by Scott Andrew LePera, Dean Edwards and Peter-Paul Koch
Fixed for IE by Tino Zijdel (crisp) @date 2005-10 */
function addEvent(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false)}else if(obj.attachEvent){var eProp=type+fn;obj["e"+eProp]=fn;obj[eProp]=function(){obj["e"+eProp](window.event)};obj.attachEvent("on"+type,obj[eProp])}else{obj['on'+type]=fn}};
function removeEvent(obj,type,fn){if(obj.removeEventListener){obj.removeEventListener(type,fn,false)}else if(obj.detachEvent){var eProp=type+fn;obj.detachEvent("on"+type,obj[eProp]);obj['e'+eProp]=null;obj[eProp]=null}else{obj['on'+type]=null}};
//*** end ***
//</nowiki></pre>
// Interwiki <noinclude>[[en:User:Olliminatore/sign.js]]</noinclude>