„MediaWiki:Common.js“ – Versionsunterschied
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
D (Diskussion | Beiträge) Vorlage:Korrekter Titel ist sehr veraltet |
D (Diskussion | Beiträge) als gadget OK, aber bitte nicht zwangsweise |
||
Zeile 241: | Zeile 241: | ||
window.attachEvent("onload", PngFix) |
window.attachEvent("onload", PngFix) |
||
} |
} |
||
//================================================================================ |
|||
//*** WikiMiniAtlas |
|||
/* WikiMiniAtlas ist ein Javascript plugin um eine GoogleMaps-artige Landkarte in geokodierte |
|||
Wikipedia Artikel einzublenden. |
|||
Siehe: http://de.wikipedia.org/wiki/Benutzer:Dschwen/WikiMiniAtlas |
|||
*/ |
|||
document.write('<script type="text/javascript" src="' |
|||
+ 'http://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js' |
|||
+ '&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400"></script>'); |
Version vom 5. Januar 2008, 23:34 Uhr
/* Jedes JavaScript hier wird für alle Benutzer für jede Seite geladen. */
//=============================================================
//*** Configuration for "star" logo in front of interwiki links to Featured Articles
/** set to false in Special:Mypage/monobook.js to switch off this "feature" */
var linkFA_enabled = true;
/** description that is displayed when cursor hovers above FA interwiki links */
var linkFA_description = "Dieser Artikel wurde als exzellent bewertet.";
// linkFA_bullet and linkFA_style werden nur für cologneblue, nostalgia and standard verwendet,
// für monobook und simple siehe [[MediaWiki:Common.css]]
/** image to use instead of the standard bullet (for cologneblue, nostalgia and standard */
var linkFA_bullet = "/media/wikipedia/commons/d/d0/Monobook-bullet-star-transparent.png";
/** style to use for the linkFA_bullet img */
var linkFA_style = "margin-right: 0.2em;";
/**
* star logo for featured articles in other languages,
* see Template:Link_FA and MediaWiki:Common.css
*/
addOnloadHook(function() {
// early exit when disabled
if (!linkFA_enabled) return;
// skins need to be treated differently
if (skin == "monobook" || skin == "simple") {
newer();
}
else if (skin == "cologneblue" || skin == "nostalgia" || skin == "standard") {
older();
}
/** skin == "monobook" || skin == "simple" */
function newer() {
// links are to replaced in p-lang only
var pLang = document.getElementById("p-lang");
if (!pLang) return;
var lis = pLang.getElementsByTagName("li");
for (var i = 0; i < lis.length; i++) {
var li = lis[i];
// only links with a corresponding Link_FA template are interesting
if (!document.getElementById(li.className + "-fa")) continue;
// additional class so the template can be hidden with CSS
li.className += " FA";
// change title
li.title = linkFA_description;
}
}
/** skin == "cologneblue" || skin == "nostalgia" || skin == "standard" */
function older() {
// these root elements can contain FA-links
var rootIds = new Array("topbar", "footer");
for (var i=0; i<rootIds.length; i++) {
var rootId = rootIds[i];
var root = document.getElementById(rootId);
if (!root) continue;
// if the root exists, try to decorate all the links within
var links = root.getElementsByTagName("a");
for (var j=0; j<links.length; j++) {
var link = links[j];
decorate(link);
}
}
}
/** id necessary, modify a link to show the FA-star (older) */
function decorate(link) {
// exit if not a FA-link
var lang = link.title.split(":")[0]; // not precise enough
var fa = document.getElementById("interwiki-" + lang + "-fa");
if (!fa) return;
// possible problem owing the standard skin: "Link FA" template is transcluded with a non-interwiki parameter, for example "Special"
// result: links to special pages in the topbar and/or footer might also be marked as a Featured Article
// build an image-node for the FA-star
var img = document.createElement("img");
img.setAttribute("src", linkFA_bullet);
img.setAttribute("alt", linkFA_description);
img.setAttribute("style", linkFA_style);
// decorate the link with the image
link.appendChild(img);
link.appendChild(link.removeChild(link.firstChild));
link.setAttribute("title", linkFA_description);
}
});
//==============================================================================
//*** Fügt einen Link "Alle Sprachen" auf der Hauptseite unter die Sprachverweise hinzu
addOnloadHook(function() {
// only on the main page
if ( wgTitle != 'Hauptseite' || wgNamespaceNumber != 0 ) return;
try {
var node = document.getElementById( "p-lang" )
.getElementsByTagName('div')[0]
.getElementsByTagName('ul')[0];
var aNode = document.createElement( 'a' );
var liNode = document.createElement( 'li' );
aNode.appendChild( document.createTextNode( 'Alle Sprachen' ) );
aNode.setAttribute( 'href' , 'http://de.wikipedia.org/wiki/Wikipedia:Sprachen' );
liNode.appendChild( aNode );
liNode.className = 'interwiki-completelist';
node.appendChild( liNode );
} catch(e) {
// lets just ignore what's happened
}
});
//==============================================================================
//*** Verändert die Tabellensortierfunktion so, dass auch deutsche Tausenderpunkt und Dezimalkommata gehen
// Original aus sv.wikipedia.org
function ts_parseFloat(num) {
if (!num) return 0;
num = num.replace(/\./g, "");
num = num.replace(/,/, ".");
num = parseFloat(num);
return (isNaN(num) ? 0 : num);
}
//==============================================================================
//*** forcePreview: erzwungene vorschau für IPs
/*
* Zwingt IPs zuerst die Vorschau zu benutzen, bevor sie speichern können.
* Copyright Marc Mongenet, 2006 aus frwp
*/
addOnloadHook(function() {
if (wgUserName != null || wgAction != "edit") return;
saveButton = document.getElementById("wpSave");
if (!saveButton) return;
saveButton.disabled = true;
saveButton.value = "Seite speichern (Bitte erst die Vorschau benutzen)";
saveButton.style.fontWeight = "normal";
document.getElementById("wpPreview").style.fontWeight = "bold";
});
//==============================================================================
//*** Fügt der Suche weitere Suchengines hinzu (kopiert aus eswp)
document.write('<script type="text/javascript" src="'
+ '/w/index.php?title=MediaWiki:SpezialSuche.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s&smaxage=3600"></script>');
//================================================================================
//*** force the loading of another JavaScript file (Kopie von [[Commons:Common.js]])
// Local Maintainer: [[Commons:User:Dschwen]]
function includePage(name) {
document.write('<script type="text/javascript" src="' + wgScript + '?title='
+ name
+ '&action=raw&ctype=text/javascript"><\/script>');
}
//==============================================================================
//*** ???
function PngFix()
{
try
{
if (!document.body.filters)
{
window.PngFixDisabled = true
}
}
catch (e)
{
window.PngFixDisabled = true
}
if (!window.PngFixDisabled)
{
var documentImages = document.images
var documentCreateElement = document.createElement
var funcEncodeURI = encodeURI
for (var i = 0; i < documentImages.length;)
{
var img = documentImages[i]
var imgSrc = img.src
if (imgSrc.substr(imgSrc.length - 3).toLowerCase() == "png" && !img.onclick)
{
if (img.useMap)
{
img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + encodeURI(imgSrc) + "')"
img.src = "/media/wikipedia/commons/c/ce/Transparent.gif"
i++
}
else
{
var outerSpan = documentCreateElement("span")
var innerSpan = documentCreateElement("span")
var outerSpanStyle = outerSpan.style
var innerSpanStyle = innerSpan.style
var imgCurrentStyle = img.currentStyle
outerSpan.id = img.id
outerSpan.title = img.title
outerSpan.className = img.className
outerSpanStyle.backgroundImage = imgCurrentStyle.backgroundImage
outerSpanStyle.borderWidth = imgCurrentStyle.borderWidth
outerSpanStyle.borderStyle = imgCurrentStyle.borderStyle
outerSpanStyle.borderColor = imgCurrentStyle.borderColor
outerSpanStyle.display = "inline-block"
outerSpanStyle.fontSize = "0"
outerSpanStyle.verticalAlign = "middle"
if (img.parentElement.href) outerSpanStyle.cursor = "hand"
innerSpanStyle.width = "1px"
innerSpanStyle.height = "1px"
innerSpanStyle.display = "inline-block"
innerSpanStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + funcEncodeURI(imgSrc) + "')"
outerSpan.appendChild(innerSpan)
img.parentNode.replaceChild(outerSpan, img)
}
}
else
{
i++
}
}
}
}
if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substr(22, 1) == "6")
{
window.attachEvent("onload", PngFix)
}