User:Yonatanh/monobook.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
The accompanying .css page for this skin can be added at User:Yonatanh/monobook.css. |
//[[MediaWiki talk:Quick-delete.js]]
document.write('<script type="text/javascript" src="/w/index.php?title=MediaWiki:Quick-delete.js&action=raw&ctype=text/javascript"><\/script>');
// get URL parameters (used for page type variables)
var UrlParameters = new Array ();
readparams();
function readparams() {
var asReadInUrlParameters;
var asReadInUrlParameter;
// Get URL parameters
asReadInUrlParameters = location.search.substring(1, location.search.length).split("&");
for (i = 0; i < asReadInUrlParameters.length; i++) {
asReadInUrlParameter = asReadInUrlParameters[i].split("=");
UrlParameters[decodeURIComponent(asReadInUrlParameter[0])] = decodeURIComponent(asReadInUrlParameter[1]);
}
}
function fillActionPage() {
if (UrlParameters["deletereason"] > "") {
if (UrlParameters["linking"] > '') {
document.getElementById("deleteconfirm").wpReason.value = UrlParameters["deletereason"] + ', see [[' + UrlParameters["linking"] + '|reason]]';
} else {
document.getElementById("deleteconfirm").wpReason.value = UrlParameters["deletereason"];
}
document.getElementById("deleteconfirm").wpConfirmB.click();
}
}
if (UrlParameters["deletereason"] > "") {
addOnloadHook(fillActionPage);
}
// <nowiki>
// Funktionen im Quickbar (monobook.js)
var usedropdown = false; // Wenn keine Dropdowns gewünscht sind, hier false eintragen!
var qbnewpage = false; // sollen Seiten aus dem QuickBar im neuen Fenster aufgerufen werden?
var timeout = 50000; // 50 Sekunden auf das Neuladen der Seite warten
var zeigeversion = false; // monobook-Version anzeigen?
var zeigehilfe = true; // kurze Hilfetexte beim überfahren mit der Maus anzeigen ? default true
var debugme = false; // Debug-Modus?
// Modul: admin.js
var delreason = true; // Löschgründe ergänzen?
var deletereasons = "copyright violation, see [[Commons:Licensing]]|copyvio; test; useless redirect; fair use, see [[Commons:Licensing]]|fair use; duplicate; Derivative work, see [[Commons:Derivative works]]|derivative work; see request for deletion|regular deletion; replaced by template, orphaned"; // Delete without linking
var deletereasonslinking = "deleted|regular deletion"; // Delete with linking
// **************** SETUP Ende ***********************************
var user = wgUserName ; // username wird automatisch übernommen
// page type variables: namespaces
var isArticle = (wgNamespaceNumber == 0);
var isArticleTalk = (wgNamespaceNumber == 1);
var isBild = (wgCanonicalNamespace == "Image");
var isCategory = (wgCanonicalNamespace == "Category");
var isTemplate = (wgCanonicalNamespace == "Template");
var isGeneric = false;
if ((!isBild) && (!isCategory) && (!isTemplate))
isGeneric = true;
var isProject = (wgCanonicalNamespace == "Project");
// page type variables: namespace == -1
var isSpecial = (wgCanonicalNamespace == "Special");
var isRestore = (isSpecial && (wgCanonicalSpecialPageName == "Undelete"));
var isContrib = (isSpecial && (wgCanonicalSpecialPageName == "Contributions"));
var isWatchlist = (isSpecial && (wgCanonicalSpecialPageName == "Watchlist"));
// page type variables: namespace == -1
var isTalk = (!isSpecial && isOdd(wgNamespaceNumber));
// page type variables: other stuff
var isPHP = (document.URL.indexOf('index.php') > 0);
var isDiff = UrlParameters["diff"];
var isEdit = ((UrlParameters['action']=='edit') || (UrlParameters['action']=='submit'));
var isHistory = (UrlParameters['action']=='history');
/*
* ab hier wird der Quickbar (der Kasten oben links) zusammengebaut
*
* zuerst die allgemeinen Variablen (hier bitte nix ändern!)
*/
var Quickbar = '<div class="pBody noprint" id="p-quickbar" style="position:absolute; top:5px; z-index:10; width:14em;">';
var xxx = '';
var trenner='<hr />';
var br ='<br />';
var qbtarget = '_self';
if (qbnewpage) qbtarget = '_blank';
var dropdown = usedropdown;
var scrpt = '';
var scrptn = 0;
var indropdown;
var ind;
/*
* Quickbar-Zusammenbau, Teil 1:
*
* zuerst die Reihenfolge der einzelnen Abschnitte:
*/
function buildQuickbar() {
w (0,'<center>Delete without linking</center>','Delete without linking','');
decodeadminreasons(deletereasons, 'false');
w (0,trenner+'<center>Delete with linking</center>','Delete with linking','');
decodeadminreasons(deletereasonslinking, 'true');
w (0,trenner+'<center>Scripts for COM:DR</center>','Scripts for COM:DELETE','');
w (4,"deleteimage();","delete","","+deleted image");
w (4,"keepimage();","keep","","+kept image");
w (4,"deleteimage(true);","delete_auto","","+autodelete image");
}
/*
* hier wird der Quickbar in die Seite geschrieben
* (ab hier bitte nichts ändern)
*/
buildQuickbar();
document.write(Quickbar);
if (typeof(version) == 'undefined') var version = "?";
if (!isEdit || zeigeversion || isPHP) {
document.write(
'<div align=right>',
(zeigeversion) ?
('<a href="#" onclick="amIuptodate()" title="Versionscheck">' + (adminflag ? 'A/' : '') + version + '</a> ')
: '',
(!isEdit) ?
('<input type="checkbox" id="reloadme" name="reloadme" onchange="setReload()" title="Seite alle ' + (timeout/1000) + ' s neu laden?"></input> ')
: ' ',
'<a href="/w/index.php?title=Spezial%3APrefixindex&from=',user,
'&namespace=2" target="', qbtarget, '" title="Meine Seiten im Benutzernamensraum">',
(user.split(' ')[0].length < 10) ? user.split(' ')[0] : 'MyPages',
'</a>',
'</div>');
}
document.write(xxx,'</div>');
if (scrpt > '') {
document.write('<script> function _doopt (was) { switch (was) {', scrpt, '}}<\/script>');
scrpt='';
}
//
// ab hier functions
//
function w (was,lurl,linktext,targt,title) {
if (!title) title=linktext;
if (!zeigehilfe) title='';
if (!dropdown) {
switch (was) {
case 0 : xxx=xxx+lurl;break;
case 1 : xxx=xxx+'<a href="'+lurl+'" target="'+targt+'" title="'+title+'">'+linktext+'</a> ';break;
case 2 : xxx=xxx+'<a href="#" onclick="newtext('+ lurl +')" title="'+title+'">'+linktext+'</a> ';break;
case 3 : xxx=xxx+'<a href="#" onclick="insertTagsWrapper('+ lurl +')" title="'+title+'">'+linktext+'</a> ';break;
case 4 : xxx=xxx+'<a href="#" onclick="'+ lurl +'" title="'+title+'">'+linktext+'</a> ';break;
}
} //if
else //todo: Hilfe bei Dropdowns. Benutzt die überhaupt jemand????
{
var ltext='__________'.substr(1,ind)+linktext;
switch (was) {
case 0 : if (lurl==br) {xxx=xxx+'<option>'+linktext+'</option>';ind=2;}
else
if (lurl==trenner) newdropdown(linktext);
break;
case 1 : xxx=xxx+'<option value="1|'+lurl+'">'+ltext+'</option>';break;
case 2 : xxx=xxx+'<option value="2|'+scrptn+'">'+ltext+'</option>';
scrpt=scrpt+'case '+scrptn+':newtext('+lurl+');break;';scrptn++;break;
case 3 : xxx=xxx+'<option value="3|'+scrptn+'">'+ltext+'</option>';
scrpt=scrpt+'case '+scrptn+':insertTagsWrapper('+lurl+');break;';scrptn++;break;
case 4 : xxx=xxx+'<option value="4|'+scrptn+'">'+ltext+'</option>';
scrpt=scrpt+'case '+scrptn+':'+lurl+';break;';scrptn++;break;
} //switch
} //else
} //w
function isEven(myNumber) {
return (myNumber % 2 == 0);
}
function isOdd(myNumber) {
return (! isEven(myNumber));
}
function importJavascriptL(page)
{
try {
/* check the parameters and set defaults */
if(!page) throw("importJavascriptL: Missing parameter page.");
/* create import url */
var import_url = 'http://commons.wikimedia.org' + wgScriptPath + '/index.php?title=User:' + page +
'.js&action=raw&ctype=text/javascript&smaxage=2678400&dontcountme=s';
/* import page */
var Head = document.getElementsByTagName('head').item(0);
var Script = document.createElement('script');
Script.setAttribute('type', 'text/javascript');
Script.setAttribute('src', import_url);
Script.setAttribute('charset', 'utf-8');
Head.appendChild(Script);
return true;
} catch(e) {
alert(e.message);
return false;
}
}
function decodeadminreasons(adminreasons, linking) { // DerHexer
var adminreason = adminreasons.split('; ');
for (i=0; i < adminreason.length; i++) {
var adminreasoncount = adminreason[i].split("|");
if (linking == 'true') {
var newadminreason = adminreason[i].replace('|'+adminreasoncount[adminreasoncount.length-1]+'', '');
switch(newadminreason.split("|").length) {
case 1 : w (4,"deleting('" + adminreasoncount[0] + "', '" + linking + "');","" + adminreasoncount[0] + ""); break;
case 2 : w (4,"deleting('" + newadminreason + "', '" + linking + "');","" + adminreasoncount[adminreasoncount.length-1] + ""); break;
}
} else {
switch(adminreasoncount.length) {
case 1 : w (4,"deleting('" + adminreasoncount[0] + "', '" + linking + "');","" + adminreasoncount[0] + ""); break;
case 2 : w (4,"deleting('" + adminreasoncount[0] + "', '" + linking + "');","" + adminreasoncount[1] + ""); break;
}
}
}
}
function deleteimage(save) { // DerHexer
if (!save) save = false;
var m = /===((.(?!===))*.)===/(document.editform.wpTextbox1.value);
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\=\=\=/, "\{\{delh\}\}\n===");
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\-\-\-\-\n\'\'\'deleted\'\'\', --\~\~\~\~\n\n\{\{delf\}\}';
document.editform.wpSummary.value = 'deleted';
if (save == true) document.editform.wpSave.click();
}
function keepimage() { // DerHexer
var m = /===((.(?!===))*.)===/(document.editform.wpTextbox1.value);
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\=\=\=/, "\{\{delh\}\}\n===");
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\-\-\-\-\n\'\'\'kept\'\'\', --\~\~\~\~\n\n\{\{delf\}\}';
document.editform.wpSummary.value = 'kept';
}
function getLemma () { //Littl
var lemma;
if ((isContrib) && ( UrlParameters["target"] > "" ))
lemma = UrlParameters["target"];
else if ( UrlParameters["title"] > "" )
lemma = UrlParameters["title"];
else {
lemma = decodeURIComponent(location.href.substring(location.href.indexOf("/wiki/") + 6)).split('#')[0];
// fix linky links (?redirect=no)
//lemma = lemma.split['\x3F'][0];
if (lemma.indexOf("redirect=no")!=-1)
lemma=lemma.substring(0,lemma.indexOf("redirect=no")-1);
}
// if (lemma.substring(0, 5) == "Bild:") lemma=lemma.slice(5);
// if (lemma.substring(0, 10) == "Kategorie:") lemma=lemma.slice(10);
if (isPHP) lemma=lemma.split('+').join('_');
return lemma;
}
// ***** FOOT-Block *****
if (delreason && wgUserName == 'Polarlys') // change when copying if (delreason && wgUserName == 'Polarlys') to if (delreason)
importJavascriptL('Polarlys/admin'); // [[:w:de:Benutzer:DerHexer/admin.js]]