MediaWiki:Common.js

/* Makes username template work */ function userNameReplace { "use strict"; var disableUsernameReplace; if (disableUsernameReplace || mw.config.get('wgUserName') === null) { return; }   $("span.insertusername").html(mw.config.get('wgUserName')); } addOnloadHook(userNameReplace); // Change title $(function {    "use strict";    var newTitle = $('#title-meta').html,        edits = $('#user_masthead_since').text;    if (!newTitle) {        return;    }    $('.firstHeading, #WikiaUserPagesHeader h1, #WikiaPageHeader h1').html(newTitle);    $('.#user_masthead_head h2').html(newTitle + '' + edits + ' '); }); /* LockForums */ window.LockForums = { expiryDays: 60, expiryMessage: "This thread is considered archived because it hasn\'t been commented on in over  days, please don\'t bump this thread!", forumName: "Forum" }; /* MassProtect */ massProtectDelay = 300; //—————————————————————————————— ! ! ! ———————————————————————————————// /* Import scripts. NOTE: Place scripts configurations above this line */ importArticles({   type: 'script',    articles: [        'u:dev:MassProtect/code.js',        //Mass protection.        'u:dev:BackToTopButton/code.js',    //Back to top button.        'u:dev:WallGreetingButton/code.js', //Message walls greetings.         'u:dev:UserTags/code.js',           //Customizes user tags.        'u:dev:SignatureCheck/code.js',     //Talk pages vestige.        'u:dev:ReferencePopups/code.js',    //Allowes to make very neat things :0        'u:dev:PurgeButton/code.js',        //Refresh button.        'u:dev:LockOldBlogs/code.js',       //Automatically locks old blogposts.        'u:dev:FloatingToc/code.js',        //Makes the toc more mobile.        'u:dev:LockForums/code.js',         //Automatically locks old forums.         'u:dev:Countdown/code.js',          //Countdowns.        'u:dev:AdminDashboard JS-Button/code.js', //A JS button is added to the Admin Dashboard. 'u:dev:FileUsageAuto-update/code.js', 'u:dev:MiniComplete/code.js', 'u:dev:ExtendedNavigation/code.js', 'u:dev:DisplayClock/code.js', 'u:dev:DisableArchiveEdit/code.js', // DisableArchiveEdit – Discourages/disables the editing of talk page archives – By User:Porter21 'u:dev:SpoilerAlert/code.js',      // Hides the content area of a page and displays a spoiler alert – See w:c:dev:SpoilerAlert for info & attribution 'u:dev:HeaderLinks/code.js', 'u:dev:DynamicImages/code.js', 'u:dev:AjaxRC/code.js' ] });

importArticles({   type: "script",    articles: [        "w:c:dev:PurgeBlogs/code.js",        "w:c:dev:PageRenameAuto-update/code.js"    ] });

// ************************************************** // Experimental javascript countdown timer (Splarka) // Version 0.0.3 // ************************************************** // // Usage example: // //  Only January 01 2007 00:00:00 PST until New years. // //  Javascript disabled. function updatetimer(i) { var now = new Date; var then = timers[i].eventdate; var diff = count=Math.floor((then.getTime-now.getTime)/1000); // catch bad date strings if(isNaN(diff)) { timers[i].firstChild.nodeValue = '** ' + timers[i].eventdate + ' **' ; return; } // determine plus/minus if(diff<0) { diff = -diff; var tpm = ' '; } else { var tpm = ' '; } // calcuate the diff var left = (diff%60) + ' seconds'; diff=Math.floor(diff/60); if(diff > 0) left = (diff%60) + ' minutes ' + left; diff=Math.floor(diff/60); if(diff > 0) left = (diff%24) + ' hours ' + left; diff=Math.floor(diff/24); if(diff > 0) left = diff + ' days ' + left timers[i].firstChild.nodeValue = tpm + left; // a setInterval is more efficient, but calling setTimeout // makes errors break the script rather than infinitely recurse timeouts[i] = setTimeout('updatetimer(' + i + ')',1000); } function checktimers { //hide 'nocountdown' and show 'countdown' var nocountdowns = getElementsByClassName(document, 'span', 'nocountdown'); for(var i in nocountdowns) nocountdowns[i].style.display = 'none' var countdowns = getElementsByClassName(document, 'span', 'countdown'); for(var i in countdowns) countdowns[i].style.display = 'inline' //set up global objects timers and timeouts. timers = getElementsByClassName(document, 'span', 'countdowndate'); //global timeouts = new Array; // generic holder for the timeouts, global if(timers.length == 0) return; for(var i in timers) { timers[i].eventdate = new Date(timers[i].firstChild.nodeValue); updatetimer(i); //start it up  } } addOnloadHook(checktimers); // ************************************************** // - end -  Experimental javascript countdown timer // **************************************************

/* User Tags sec. 1*/ window.UserTagsJS = { tags: { bureaucrat: { link: 'Special:ListUsers/bureaucrat' },       bot: { link: 'Special:Listusers/bot' },       chatmoderator: { link: 'Special:ListUsers/chatmoderator' },       patroller: { link: 'Special:ListUsers/patroller' },       imagecontrol: { u: 'imagecontrol', link: 'Special:ListUsers/imagecontrol' },       rollback: { link: 'Special:ListUsers/rollback' },       sysop: { link: 'Special:ListUsers/sysop' }   },    modules: { autoconfirmed: true, inactive: { days: 60, namespaces: [0], zeroIsInactive: true },       mwGroups: [ 'bannedfromchat', 'bureaucrat', 'chatmoderator', 'sysop', 'rollback', 'patroller', 'bot', 'imagecontrol' ],       newuser: true } }; /* User Tags sec. 2 */ window.UserTagsJS = { modules: {}, tags: { // group: { associated tag data } founder: { u:'Founder', order: -1/0 }, bureaucrat: { u:'Bureaucrat', link:'Project:Staff of the Wiki#Bureaucrats', order: -1/0 }, adopter: { u:'Wiki Adopter', link:'Project:Staff of the Wiki#Wiki_Adopter', order: -1/0 }, usermonth: { u:'User of the Month', order: -1/0 }, vstf: { u:'VSTF', order: -1/0 }, staff: { u:'Staff', order: -1/0 }, councilor: 'Councilor', facebook: 'Facebook Manager', twitter: {u: 'Twitter Manager', link:'Project:Staff of the Wiki#Twitter_Manager'}, google: 'Google+ Manager', assistant: 'Assistant', skype: 'Skype Admin', permdisabled: 'Permanantly Disabled Account', admincrat: {u: 'Admincrat', link:'Project:Staff of the Wiki#Admincrats'}, supportadmin: {u: 'Support Administrator', link:'Project:Staff of the Wiki#Support_Administrators', order: -1/0 }, patroller: {u: 'Patroller', link:'Project:Staff of the Wiki#Patrollers', order: -1/0 }, formeradmin: {u: 'Former Administrator', link:'Project:Staff of the Wiki#Former_Admins', order: -1/0 }, } }; UserTagsJS.modules.custom = { 'AbercrombieFizzwidget': ['founder', 'permdisabled', 'formeradmin'], 'Crossovers': ['adopter', 'admincrat', 'twitter'], 'BouncingParatroopa': ['admincrat','usermonth'], };

UserTagsJS.modules.inactive = 30; UserTagsJS.modules.newuser = true; UserTagsJS.modules.autoconfirmed = true; UserTagsJS.modules.mwGroups = ['bureaucrat', 'chatmoderator', 'patroller', 'rollback', 'bannedfromchat', 'bot', 'bot-global', 'assistant', 'moderator']; // ************************************************* // Pagetitle rewrite // // Rewrites the page's title, used by Template:Title // ************************************************* $(function{	var newTitle = $("#title-meta").html;	if (!newTitle) return;	var edits = $("#user_masthead_since").text;	$(".firstHeading,#WikiaUserPagesHeader h1,#WikiaPageHeader h1").html(newTitle);	$("#user_masthead_head h2").html(newTitle + "" + edits + " "); }); /* Replaces with the name of the user browsing the page. Requires copying Template:USERNAME. */ function UserNameReplace { if(typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace || wgUserName == null) return; $("span.insertusername").html(wgUserName); } addOnloadHook(UserNameReplace); /* End of the replacement */

/*TLH Quiz*/ importArticles({   type: "script",    articles: [        "w:c:dev:PurgeBlogs/code.js",        "w:c:dev:PageRenameAuto-update/code.js"    ] });

var quizName = "The Loud House Quiz"; var quizLang = "en"; var resultsTextArray = [ "You need to watch more TLH!", "Not bad. You have a decent knowledge of TLH.", "You are a TLH expert!" ]; var questions = [ ["How many sisters does the character Lincoln Loud have?", "10",      "33",       "22",       "11"],       ["When is The Loud House coming out?", "Jan. 2016", "Nov. 2015", "It has already come out", "Dec. 2015"], ["Why does Lincoln have so many sisters?", "His mother wanted many childern.", "IDK", "The Loud family was mostly male, and they needed more females", "shrugs"] ];

importArticles({   type: 'script',    articles: [        'u:dev:Quiz/code.js'    ] });