User:Arved/common.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 can be added at User:Arved/common.css. |
// [[User:Caorongjin/wordcount]]
importScript('User:Caorongjin/wordcount.js');
/**
* Anzahl der Beobachter für Artikel in einem Tab
* oben rechts anzeigen lassen mit Verweis auf
* Artikel-Informationsseite
*
* Nutzbar für den Vector- und Monobook-Skin
*
* Author: Benutzer:Nightfly85
*/
(function($, mw) {
function placeTab(text, url, title, isSelected) {
var liClass = isSelected ? 'selected' : '',
$liElement = $('<li id="ca-n-watchers" style="display:none" class="' + liClass +'" ><span><a title="' + title + '" href="' + url + '">' + text + '</a></span></li>');
$('#ca-history').after($liElement);
$liElement.slideDown();
}
var isInfoPage = (mw.config.get('wgAction') == 'info'),
articleName = mw.util.wikiUrlencode(mw.config.get('wgPageName')),
wikiBaseUrl = mw.config.get('wgServer') + mw.config.get('wgScriptPath'),
infoUrl = wikiBaseUrl + '/index.php?action=info&title=' + articleName,
apiUrl = wikiBaseUrl + '/api.php?action=query&prop=info&inprop=watchers&format=xml&titles=' + articleName;
if(isInfoPage) {
// The info tab is selected, so highlight the tab and forget the ajax stuff
placeTab('Information', infoUrl, 'Page Information', true);
} else {
if(false === mw.config.get('wgIsArticle') ) {
return; // Generated page
}
$.ajax({ url: apiUrl }).done(function(xmlData) {
var numViewer = $(xmlData).find('page').attr('watchers'),
numViewerText = (numViewer > 0) ? '<strong>' + numViewer + '</strong>' : 'Nearly no';
placeTab(numViewerText + ' Watcher', infoUrl, 'Show Page Information', false);
});
}
})(jQuery, mediaWiki);