User:Ugog Nizdast/displayNumberOfTags.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. |
This user script seems to have a documentation page at User:Ugog Nizdast/displayNumberOfTags and an accompanying .css page at User:Ugog Nizdast/displayNumberOfTags.css. |
/* [[Category:Wikipedia scripts]]
Originally inspired from User:Numbermaniac/goToTop.js
*/
if (typeof rightDefault === 'undefined') var rightDefault;
function scrollOver (target,x) {
lengt = target.length;
if ( x >= lengt ) x = 0;
$( 'html, body' ).animate( { scrollTop: $(target[x]).offset().top-40 }, 'slow' );
x++;
return x;
}
$(function() {
importStylesheet('User:Ugog Nizdast/displayNumberOfTags.css');
var pgn = (mw.config.get( 'wgPageName')), isa = (mw.config.get( 'wgIsArticle')), cnp = (mw.config.get( 'wgCanonicalNamespace' )),
act = (mw.config.get( 'wgAction'));
if ( (pgn != "Main_Page") && (cnp === "") && ((act == "view") || (act == "edit") || (act == "purge") || (act == "submit")) ) { //check if page content is loaded
var inline = '<span id="inline">'+$(".Inline-Template").length+" inline,"+'</span>';
var major = '<span id="major">'+$(".ambox").length+" major"+'</span>';
$( 'body' ).append( '<span id="msg">Cleanup tags: '+inline+' '+major+'<span>'); //append inline and major to bottom
if (rightDefault) $("#msg").css('right', "0"); //config variables
var i = 0, j = 0;
$('#inline').click( function() {
i = scrollOver($(".Inline-Template"),i); //as its clicked, scroll over each tag
} );
$('#major').click( function() {
j = scrollOver($(".ambox"),j);
} );
}
});
//hooray my first script!