Benutzer:Slomox/Themen.js
aus Wikipedia, der freien Enzyklopädie
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Internet Explorer/Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
- Opera: Strg+F5
// <nowiki>
var links = {};
var l10n = {};
var default_settings = {
default_talk: "Wikipedia:Auskunft",
lang: 'de',
wiki: 'de',
wiki_to: 'de'
};
var settings = (typeof settings === 'undefined') ? default_settings : settings;
$(function() {
if ((mw.config.get( 'wgAction' ) === 'view') && (mw.config.get( 'wgNamespaceNumber' ) === 0)) {
$.ajax({
type: "GET",
url: '//' + settings.wiki + '.wikipedia.org/w/index.php?title=User:Slomox/Themen/l10n.' + settings.lang + '.json&action=raw&ctype=text/json',
dataType: 'json',
success: function( jsondata ){
l10n = jsondata;
var li = $('<li/>');
var a = $('<a/>').html(get_l10n('text for activation button')).attr('title', get_l10n('title attribute for activation button'));
var span = $('<span/>')
.attr('id', 'project-talk-links')
.one('click', function() {
$.ajax({
type: "GET",
url: '//' + settings.wiki + '.wikipedia.org/w/index.php?title=User:Slomox/ThemenAll.json&action=raw&ctype=text/json',
dataType: 'json',
success: function( jsondata ){
links = jsondata;
ready();
}
});
});
li.append(span.append(a));
$('#p-namespaces ul').append(li);
}
});
}
});
function ready() {
var newlinks = [];
var categories = mw.config.get( 'wgCategories' );
$.each(categories, function(key, elem) {
if (typeof links[elem] !== 'undefined') {
$.each(links[elem], function(keyLink, elemLink) {
newlinks.push({category: elem, link: elemLink });
});
}
});
newlinks.push({category: get_l10n('title for default talk'), link: settings.default_talk });
var obj = {};
for (var i=0, len=newlinks.length; i < len; i++)
obj[newlinks[i].link] = newlinks[i];
newlinks = [];
for (var key in obj) {
newlinks.push(obj[key]);
}
var ul = $('<ul/>').css({
"list-style": "disc",
"float": "none"
});
$.each(newlinks, function(key, elem) {
ul.append($('<li/>').css({
"float": "none",
"background": "none"
}).append(
$('<a/>')
.attr('href', '//' + settings.wiki_to + '.wikipedia.org/wiki/' + elem.link.replace(' ', '_'))
.attr('title', ((elem.category !== get_l10n('title for default talk'))?get_l10n('based on category:') + elem.category:elem.category))
.html(elem.link))
);
});
var div = $('<div/>').css({
"position": "absolute",
"height": "auto",
"float": "none",
"background": "#fff",
"z-index": "1",
"border": "1px solid #a7d7f9",
"margin": "2.43rem 0 0 -1px"
}).append($('<div/>').css({
"font-size": "75%",
"padding": ".3rem 0.615em 0",
"background": "none",
"max-width": "250px",
"white-space": "initial"
}).html(get_l10n('text before list'))).append(ul);
$('#project-talk-links').append(div).on('click', function() {
$('#project-talk-links > div').toggle();
});
}
function get_l10n(text) {
if (typeof l10n[text] !== 'undefined') return l10n[text];
else return text;
}
// </nowiki>