|
|
(57 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */ | | /* Any JavaScript here will be loaded for all users on desktop */ |
|
| |
|
| /* Automatically add Aboutfile template to file upload description. Source: nl.wikipedia.org/wiki/MediaWiki:Common.js */ | | /* Alternating wiki logo */ |
| if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && !document.getElementById('wpForReUpload') && !document.getElementsByClassName('mw-destfile-warning')[0] && !document.getElementsByClassName('error')[0]) {
| | $(function() { |
| function loadAutoAboutfileTemplate() { | | var logos = ['b/bc/Wiki.png', 'd/d7/Wiki_2.png', '9/97/Wiki_3.png', '6/6a/Wiki_4.png', '7/79/Wiki_5.png']; |
| uploadDescription = document.getElementById('wpUploadDescription');
| | $('#p-logo a').css('background-image', 'url(https://kh.wiki.gallery/images/' + logos[Math.floor(Math.random() * logos.length)] + ')'); |
| var doubleBracket = '{' + '{';
| | }); |
| uploadDescription.value = doubleBracket + 'aboutfile\n|description=\n|purpose=\n|game=\n|source=\n}}';
| |
| }
| |
| | |
| $(loadAutoAboutfileTemplate);
| |
| }
| |
|
| |
|
| /* Shrinking talk bubble sprites */ | | /* Add user subpages toolbox link */ |
| $(document).ready(function () { | | $(function() { |
| if (document.readyState != "complete") { | | if (mw.config.get('wgCanonicalNamespace') === 'User' && mw.config.get('skin') !== 'timeless') { |
| setTimeout(arguments.callee, 100); | | var subpagesLink = '/Special:PrefixIndex/User:' + mw.config.get('wgTitle').split('/')[0] + '/'; |
| return; | | mw.util.addPortletLink('p-tb', subpagesLink, 'User subpages', 't-subpages', 'Subpages for this user'); |
| } | | } |
| $("table.talkbubble").each(function () {
| |
| $(this).find("td").first().width(90).css("text-align", "center").find("img").each(function () {
| |
| if ($(this).width() > 90) $(this).css("height", "auto").width(90);
| |
| });
| |
| });
| |
| });
| |
|
| |
| /* Username inserts for the USERNAME template */
| |
| function UserNameReplace() {
| |
| if (typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace || mw.config.get('wgUserName') == null) return;
| |
| $('span.insertusername').each(function () {
| |
| $(this).text(mw.config.get('wgUserName'));
| |
| });
| |
| }
| |
| $(UserNameReplace);
| |
|
| |
| // ===========
| |
| // Alternating wiki logo
| |
| // Author: Porplemontage
| |
| // =============
| |
| var logos = ['/images/b/bc/Wiki.png', '/images/9/97/Wiki_3.png', '/images/d/d7/Wiki_2.png'];
| |
| $('#p-logo a').css('background-image', 'url(' + logos[Math.floor(Math.random() * logos.length)] + ')');
| |
|
| |
|
| |
| // ==================
| |
| // Code for Template:Suite3
| |
| // Author: Soxra
| |
| // ==================
| |
|
| |
| $(document).ready(function () {
| |
| $(".morphMaster").each(function () {
| |
| var $master = $(this);
| |
| var $tabs = $master.find(".morphTabBox");
| |
| var $container = $master.find(".morphTabContainer");
| |
|
| |
| $tabs.find(".morphLink").click(function () {
| |
| var id = $(this).attr("id");
| |
| id = id.substr(0, id.length - 4);
| |
| $container.find(".morphContent").hide();
| |
| $container.find("#" + id + "Content").show();
| |
| });
| |
| });
| |
| });
| |
|
| |
| // ==================
| |
| // tabber.js
| |
| // Authors: Eric Fortin, Alexia E. Smith
| |
| // ==================
| |
|
| |
| (function($) {
| |
| $.fn.tabber = function() {
| |
| return this.each(function() {
| |
| // create tabs
| |
| var $this = $(this),
| |
| tabContent = $this.children('.tabbertab'),
| |
| nav = $('<ul>').addClass('tabbernav');
| |
| tabContent.each(function() {
| |
| var anchor = $('<a>').text(this.title).attr('title', this.title).attr('href', 'javascript:void(0);');
| |
| $('<li>').append(anchor).appendTo(nav);
| |
| });
| |
| $this.prepend(nav);
| |
|
| |
| /**
| |
| * Internal helper function for showing content
| |
| * @param string title to show, matching only 1 tab
| |
| * @return true if matching tab could be shown
| |
| */
| |
| function showContent(title) {
| |
| var content = tabContent.filter('[title="' + title + '"]');
| |
| if (content.length !== 1) return false;
| |
| tabContent.hide();
| |
| content.show();
| |
| nav.find('.tabberactive').removeClass('tabberactive');
| |
| nav.find('a[title="' + title + '"]').parent().addClass('tabberactive');
| |
| return true;
| |
| }
| |
| // setup initial state
| |
| var loc = location.hash.replace('#', '');
| |
| if ( loc == '' || !showContent(loc) ) {
| |
| showContent(tabContent.first().attr('title'));
| |
| }
| |
|
| |
| // Repond to clicks on the nav tabs
| |
| nav.on('click', 'a', function(e) {
| |
| var title = $(this).attr('title');
| |
| e.preventDefault();
| |
| location.hash = '#' + title;
| |
| showContent( title );
| |
| });
| |
|
| |
| $this.addClass('tabberlive');
| |
| });
| |
| };
| |
| })(jQuery);
| |
|
| |
| $(document).ready(function() {
| |
| $('.tabber').tabber();
| |
| }); | | }); |
|
| |
|
| // ================== | | /* Hide page previews when portals are used */ |
| // Auto-refresh recent changes
| | $(function() { |
| // Code courtesy of pcj of WoWWiki
| | if (document.getElementsByClassName('nav')[0] && document.getElementsByClassName('dropdown')[0]) |
| // ==================
| | $('head').append('<style type="text/css">.mwe-popups { display: none !important; }</style>'); |
| | |
| function setCookie(c_name, value, expiredays) {
| |
| var exdate = new Date();
| |
| exdate.setDate(exdate.getDate() + expiredays);
| |
| document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
| |
| }
| |
| | |
| function getCookie(c_name) { | |
| if (document.cookie.length > 0) { | |
| c_start = document.cookie.indexOf(c_name + "=");
| |
| if (c_start != -1) {
| |
| c_start = c_start + c_name.length + 1;
| |
| c_end = document.cookie.indexOf(";", c_start);
| |
| if (c_end == -1) c_end = document.cookie.length;
| |
| return unescape(document.cookie.substring(c_start, c_end));
| |
| } | |
| }
| |
| return "";
| |
| }
| |
| | |
| var ajaxPages = new Array("Special:RecentChanges");
| |
| var ajaxRCOverride = false;
| |
| var rcRefresh = 30000;
| |
| | |
| function ajaxRC() {
| |
| appTo = $(".firstHeading");
| |
| appTo.append(' <span style="position:absolute; margin-left:10px;"><span style="font-size: xx-small; cursor:help;" title="Automatically refresh the current page every ' + Math.floor(rcRefresh / 1000) + ' seconds">AUTO-REFRESH:</span><input type="checkbox" id="autoRefreshToggle"><span style="position:relative; left:5px;" id="autoRefreshProgress"><img src="/images/loader.gif" border="0" alt="AJAX operation in progress" /></span></span>');
| |
| $("#autoRefreshToggle").click(function () {
| |
| setCookie("ajaxRC", $("#autoRefreshToggle").is(":checked") ? "on" : "off")
| |
| loadRCData()
| |
| });
| |
| $("#autoRefreshProgress").hide();
| |
| if (getCookie("ajaxRC") == "on" || ajaxRCOverride) {
| |
| $("#autoRefreshToggle").attr("checked", "checked");
| |
| setTimeout("loadRCData();", rcRefresh);
| |
| }
| |
| }
| |
| | |
| function loadRCData() {
| |
| if (!$("#autoRefreshToggle").is(":checked")) return;
| |
| $('#autoRefreshProgress').show()
| |
| $(article).load(location.href + " " + article + " > *", function (data) {
| |
| $(article + " .mw-collapsible").makeCollapsible();
| |
| $('#autoRefreshProgress').hide()
| |
| if ($("#autoRefreshToggle").is(":checked")) setTimeout("loadRCData();", rcRefresh);
| |
| });
| |
| }
| |
| | |
| $(function () {
| |
| article = "#bodyContent";
| |
| for (x in ajaxPages) {
| |
| if (mw.config.get('wgPageName') == ajaxPages[x] && $("#autoRefreshToggle").length == 0) ajaxRC();
| |
| }
| |
| }); | | }); |