User:Cecil/quickbar.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.
![]() | Documentation for this user script can be added at User:Cecil/quickbar. |
// <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 = true; // monobook-Version anzeigen?
var zeigehilfe = true; // kurze Hilfetexte beim überfahren mit der Maus anzeigen ? default true
var debugme = false; // Debug-Modus?
// **************** 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 = getParamValue("diff");
var isEdit = ((getParamValue('action')=='edit') || (getParamValue('action')=='submit'));
var isHistory = (getParamValue('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;
/*
* hier wird der Quickbar in die Seite geschrieben
* (ab hier bitte nichts ändern)
*/
function buildQuickbar() { // DerHexer
if (deletewithoutlinking3) {
w (0,'<center>Delete without linking</center>','Delete without linking','');
decodeadminreasons(deletereasons, 'false');
}
if (deletewithlinking3) {
w (0,trenner+'<center>Delete with linking</center>','Delete with linking','');
decodeadminreasons(deletereasonslinking, 'true');
}
if (deletekeep3) {
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");
}
if (duplicate3) {
w (0,trenner+'<center>Duplicate</center>','Scripts for duplicates','');
w (4,"duplicate();","duplicate","","+duplicated images");
}
}
buildQuickbar();
document.write(Quickbar);
if (typeof(version) == 'undefined') var version = "?";
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 duplicate() { // DerHexer
var lemma = getLemma();
lemma = lemma.replace(/Image:/, '');
var tables = document.getElementsByTagName("table");
for (i=0; i<tables.length; i++) {
var as = tables[i].getElementsByTagName("a");
for (j=0; j<as.length; j++) {
if (as[j].getAttributeNode("href").childNodes[0].nodeValue == '/wiki/Category:Duplicate') {
var duplicate2 = as[j+1].getAttributeNode("title").childNodes[0].nodeValue.replace(/Image:/, '');
break;
}
}
}
var uri = 'http://commons.wikimedia.org/w/index.php?title=User:CommonsDelinker/commands&action=edit&addarticle=' + lemma + '&duplicate=' + duplicate2;
window.open(uri);
}
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 deleting(deletereason, linking) { // DerHexer
// Variables that should be defined in your monobook
if (typeof(autosave) == 'undefined')
autosave = false;
if (typeof(isPHP ) == 'undefined')
isPHP = (document.URL.indexOf('index.php') > 0);
var speichernpa = (autosave) ? "&" + speichernp + "=1" : "";
var lemma;
if ( getParamValue("title") > "" )
lemma = getParamValue("title");
else
lemma = decodeURIComponent(location.href.substring(location.href.indexOf("/wiki/") + 6)).split('#')[0];
if (isPHP) lemma=lemma.split('+').join('_');
var linkedpage = '';
// Wir müssen die Seite erst zum Editieren öffnen
uri = 'http://commons.wikimedia.org/w/index.php?title=' + encodeURIComponent(lemma) + "&action=delete"
+ "&deletereason=" + encodeURIComponent(deletereason) + "&linking=";
if (linking == 'true') {
var tables = document.getElementsByTagName("table");
for (i=0; i<tables.length; i++) {
if (tables[i].getAttributeNode("class").childNodes[0].nodeValue == 'boilerplate') {
var title = tables[i].getElementsByTagName("a")[1].getAttributeNode("title").childNodes[0].nodeValue;
if (title.search(/Commons\:Deletion requests\//) != -1) {
linkedpage = title;
}
break;
}
}
uri = uri + linkedpage;
}
uri = uri + speichernpa;
location.href = uri;
}
function getLemma () { //Littl
var lemma;
if ((isContrib) && ( getParamValue("target") > "" ))
lemma = getParamValue("target");
else if ( getParamValue("title") > "" )
lemma = getParamValue("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;
}
// </nowiki>