MediaWiki:Cosmos.js

/* All JavaScript here will be loaded for users of the Cosmos skin */ $(function{ if(window.JSloaded){ return; }

$( "#discord-widget" ).html(' ');

window.JSloaded = true; $('.blog-left-units').after($('#blog-page-right'));

mw.loader.load('/w/index.php?title=MediaWiki:RecentChangesMultiple.js&action=raw&ctype=text/javascript');

if(mw.config.get('wgCanonicalSpecialPageName') == 'UpdateProfile'){ $('.page-Special_UpdateProfile div.profile-update:nth-of-type(1) > .profile-update-title').append('    Edit Bio'); } mw.config.set({'wgAjaxLicensePreview' :true}); if(mw.config.get('wgCanonicalSpecialPageName') == "AdminLinks" ){ $('#mw-content-text').html($('#mw-content-text').html.replace(/·/g, '•')); $('a[href*="MediaWiki:Sidebar"]').replaceWith('Edit JavaScript file'); } if(mw.config.get('wgCanonicalSpecialPageName') == "AdminLinks" && !mw.config.get('wgUserGroups').includes('sysop')){ $('#firstHeading').html('Permission error'); $('title').html('Permission error - ' + mw.config.get("wgSiteName")); $('#mw-content-text').html(' You do not have permission to view admin links, for the following reason: You are not allowed to execute the action you have requested. '); }

/*if(mw.config.get('wgPageName') == "Project_New_America_(Earth-2:_Post-Crisis)"){ window.history.replaceState(null,null, "/wiki/Project:_New_America_(Earth-2:_Post-Crisis)"); } if(mw.config.get('wgPageName') == "DC_Multiverse_Wiki:New_America_(Earth-2:_Post-Crisis)"){ window.location.replace("/wiki/Project_New_America_(Earth-2:_Post-Crisis)"); } window.setInterval(function{   $('a[title="Project New America (Earth-2: Post-Crisis)"]').attr("title", "Project: New America (Earth-2: Post-Crisis)"); },0);*/

/*if((mw.config.get("wgNamespaceNumber") == 2 || mw.config.get("wgNamespaceNumber") == 202) && $('#profile-top').length > 0 && mw.config.get("wgAction") == "view"){ if(!$('body').hasClass('mw-wiki-user-page') && !$('body').hasClass('mw-social-profile-page')){ $('body').addClass('mw-social-profile-page'); }   $('#profile-top').append($('.profile-actions')); $('#firstHeading').html($('#firstHeading').html.replace('User:', '')); $('.profile-actions').html($('.profile-actions').html.replace(/ \| /g,'')); if($('a[href*="Special:UploadAvatar"]').length > 0){ $('.profile-actions a[href*="Special:UploadAvatar"]').replaceWith($('a[rel="discussion"]')); }else{ $('.profile-actions').prepend($('a[rel="discussion"]')); } $('a[rel="discussion"]').html($('a[rel="discussion"]').html.replace(' Discussion ', ' Talk Page ')); $('a[rel="discussion"]').attr('title', $('a[rel="discussion"]').attr('title').replace('Discussion about the content page', mw.config.get("wgPageName").replace("User:", "").replace("User_profile:","").replace(/_/g, ' ') + "'s talk page")); $('#profile-top').prepend($('#mw-content .wds-button-group')); $('#profile-title-container').replaceWith(' ' + mw.config.get("wgPageName").replace('User:', ).replace('User_profile:', ).replace(/_/g,' ') +' ');

$.when(mw.loader.using(["mediawiki.api"])).then(function { var userStatsparams = {		action: 'query',		list: 'users',		ususers: mw.config.get("wgPageName").replace('User:', ).replace('User_profile:',),		usprop: 'blockinfo|groups|editcount|registration',		format: 'json'	}, userStatsAPI = new mw.Api; userStatsAPI.get( userStatsparams ).done( function ( data ) { var users = data.query.users, u; for ( u in users ) { if(window.experimentalTags !== true){ if(users[ u ].blockexpiry !== undefined){ $('.hgroup').append(' Blocked '); }else{ if(mw.config.get("wgPageName").replace('User_profile:', 'User:') == "User:TheDemon08"){ $('.hgroup').append(' Founder '); } if(users[ u ].groups.includes('bureaucrat') && users[ u ].groups.includes('sysop')){ $('.hgroup').append(' Bureaucrat '); $('.hgroup').append(' Administrator '); }else if(users[ u ].groups.includes('bureaucrat')){ $('.hgroup').append(' Bureaucrat '); }else if(users[ u ].groups.includes('bot') && users[ u ].groups.includes('flow-bot')){ $('.hgroup').append(' Bot '); $('.hgroup').append('Structured Discussions bot '); }else if(users[ u ].groups.includes('bot')){ $('.hgroup').append(' Bot '); }else if(users[ u ].groups.includes('moderator') && users[ u ].groups.includes('sysop')){ $('.hgroup').append(' Administrator '); $('.hgroup').append(' Moderator '); }else if(users[ u ].groups.includes('sysop')){ $('.hgroup').append(' Administrator '); }else if(users[ u ].groups.includes('rollbacker') && users[ u ].groups.includes('moderator')){ $('.hgroup').append(' Moderator '); $('.hgroup').append(' Rollbacker '); }else if(users[ u ].groups.includes('moderator')){ $('.hgroup').append(' Moderator '); }else if(users[ u ].groups.includes('rollbacker')){ $('.hgroup').append(' Rollbacker '); } if(mw.config.get("wgPageName").replace('User_profile:', 'User:') == "User:TheDemon08"){ $('.hgroup').append('Team Lead: Titans '); }else if(mw.config.get("wgPageName").replace('User_profile:', 'User:') == "User:Universal_Omega"){ $('.hgroup').append('Team Lead: Stargirl '); }else if(mw.config.get("wgPageName").replace('User_profile:', 'User:') == "User:Zomlouis"){ $('.hgroup').append('Team Lead: The Flash (1990) '); }else if(mw.config.get("wgPageName").replace('User_profile:', 'User:') == "User:IC228"){ $('.hgroup').append('Team Lead: The Flash (2014) '); }else if(mw.config.get("wgPageName").replace('User_profile:', 'User:') == "User:Rman41"){ $('.hgroup').append('Team Lead: Superman Anthology '); } } }

$('#profile-right').after( '  ' + users[ u ].editcount + ' Edits since joining this wiki ' + mw.config.get("wgMonthNames")[new Date(users[ u ].registration).getMonth] + ' ' + new Date(users[ u ].registration).getDay + ', ' + new Date(users[ u ].registration).getFullYear + '  '); var bioParams = { action: 'parse', page: mw.config.get("wgPageName").replace('User_profile:', 'User:') + '/bio', format: 'json', prop: 'wikitext' }; var BioAPI = new mw.Api;

BioAPI.get(bioParams).done(function ( data ) {	$('.tally').after(' ' + data.parse.wikitext['*'] + ' '); });

} } ); get }); } */ $.urlParam = function (name) { var results = new RegExp("[?&]" + name + "=([^&#]*)").exec(     window.location.href    ); if (results == null) { return null; }   return decodeURI(results[1]) || 0; }; $.extend({    _urlVars: null,    getUrlVars: function  {      if ($._urlVars === null) {        var i,          j,          hash,          hashes = window.location.search            .slice(window.location.search.indexOf("?") + 1)            .split("&");        $._urlVars = {};        for (i = 0, j = hashes.length; i < j; i++) {          hash = hashes[i].split("=");          $._urlVars[hash[0]] = hash[1];        }      }      return $._urlVars;    },    getUrlVar: function (name) {      return $.getUrlVars[name];    },  }); mw.hook( 've.saveDialog.stateChanged' ).add( function { mw.loader.load('/w/index.php?title=MediaWiki:Standard Edit Summaries.js&action=raw&ctype=text/javascript'); }); mw.hook( 've.activationComplete' ).add( function {    $('.ve-activated .firstHeading').html($('title').html.replace(' - ' + mw.config.get("wgSiteName"), '')); var surface = ve.init.target.getSurface; }); window.getElementsByClassName = function (oElm, strTagName, oClassNames) { var arrReturnElements = []; if (!oElm) { return arrReturnElements; }   if (typeof oElm.getElementsByClassName == "function") { var arrNativeReturn = oElm.getElementsByClassName(oClassNames); if (strTagName == "*") { return arrNativeReturn; }     for (var h = 0; h < arrNativeReturn.length; h++) { if (         arrNativeReturn[h].tagName.toLowerCase == strTagName.toLowerCase        ) { arrReturnElements[arrReturnElements.length] = arrNativeReturn[h]; }     }      return arrReturnElements; }   var arrElements = strTagName == "*" && oElm.all ? oElm.all : oElm.getElementsByTagName(strTagName); var arrRegExpClassNames = []; if (typeof oClassNames == "object") { for (var i = 0; i < oClassNames.length; i++) { arrRegExpClassNames[arrRegExpClassNames.length] = new RegExp(         "(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"        ); }   } else { arrRegExpClassNames[arrRegExpClassNames.length] = new RegExp(       "(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"      ); }   var oElement; var bMatchesAll; for (var j = 0; j < arrElements.length; j++) { oElement = arrElements[j]; bMatchesAll = !0; for (var k = 0; k < arrRegExpClassNames.length; k++) { if (!arrRegExpClassNames[k].test(oElement.className)) { bMatchesAll = !1; break; }     }      if (bMatchesAll) { arrReturnElements[arrReturnElements.length] = oElement; }   }    return arrReturnElements; }; /*if(mw.config.get("wgCategories").length > 0 && mw.config.get("wgIsMainPage") !== true && mw.config.get("wgAction") == "view"){ $('#firstHeading').after(' in:  + mw.config.get("wgCategories") +  '); } */ window.BackToTopModern = true; window.BackToTopArrow = true; window.BackToTopSpeed = 200; window.BackToTopStart = 550; window.AjaxThreadDeleteConfig = { fastDelete: true, reason: "Deleting comment", };

var MessageBlock = { title: "Block", message: "You have been blocked due to a reason Please view your block log for more information about your block. Thanks.", };

window.AjaxBlock = { expiryTimes: { "2 hours": "2 hours", "1 day": "one day", "1 week": "a week", "2 months": "2m", never: "Never", },   blockReasons: { "Vandalism": "Vandalism", "Spam": "Spam", "Under the legal age": "COPPA", "Removing information/blanking articles": "Blanking", "Failing to comply with the File Policy": "File policy", "Inserting false information": "Inserting false information", "Removing content from pages": "Removing content from pages", "Inserting nonsense/gibberish into page(s)": "Inserting nonsense/gibberish into page(s)", "Intimidating behavior/harassment": "Intimidating behavior/harassment", "Uploading inappropriate images/videos": "Uploading inappropriate images/videos", "Spamming comments/forum threads": "Spamming comments/forum threads", "ToU violation": "Violation of Fandom's Terms of Use", "Abusing multiple accounts": "Multiaccounts", "Bot cooldown": "Bot cooldown (preventing harm)", },   check: { talk: true, autoBlock: true, override: true, }, };

window.category = ["Candidates for deletion", "Unused images"]; window.reason = "Housekeeping"; window.quickDeleteDelay = "800";

window.fdButtons = [ {     summary: "Housekeeping", label: "Housekeeping", },   {      summary: "Vandalism", label: "Vandalism", },   {      summary: "Spam", label: "Spam", },   {      summary: "Low quality article; not really needed like this. ", label: "Low Quality", },   {      summary: "Copyright Violation", label: "Copyright", },   {      summary: "Marked for Deletion", label: "Marked for Deletion", }, ];

/*function UserNameReplace { if (     (typeof disableUsernameReplace != "undefined" && disableUsernameReplace) ||     mw.config.get("wgUserName") == null    ) return; $("span.insertusername").text(mw.config.get("wgUserName")); } $(UserNameReplace);*/

mw.loader.using(["mediawiki.jqueryMsg", "mediawiki.api"], function {  $.when(mw.loader.using(["mediawiki.api"])).then(function  { return new mw.Api .get({       action: "query",        meta: "siteinfo",        siprop: "fileextensions",        format: "json",      }) .then(function (data) { var extensions = data.query.fileextensions,		e; var FileExtensions = [];	for ( e in extensions ) {     FileExtensions.push(extensions[e].ext);

} mw.config.set({'wgFileExtensions' :FileExtensions}); if(mw.config.get("wgUserGroups").includes("autoconfirmed") ||   mw.config.get("wgUserGroups").includes("confirmed") === true){ mw.loader.load('/w/index.php?title=MediaWiki:MultiUpload.js&action=raw&ctype=text/javascript'); } }); });  // Have categories added to images from upload description if (mw.config.get("wgCanonicalSpecialPageName") === "Upload") { if (!$.getUrlVar("wpForReUpload")) jQuery(function ($) {       "use strict";        var $desc = $("#wpUploadDescription");        if ($desc.val) {          return; // If not empty then don't do anything (i.e. error message confirm page)        }

var params = { action: "parse", page: "Template:Default Upload Summary", format: "json", prop: "wikitext", };       var api = new mw.Api;

api.get(params).done(function (data) {         return $desc.val(data.parse.wikitext["*"]);        });

if (window.location.href.indexOf("wpForReUpload") > -1) { return; } else { function verifyLicense { if (!$("#wpLicense").val) { window.alert("Licensing must be complete."); return false; }         }          $desc.closest("form").submit(verifyLicense); }     });  }  new mw.Api    .get({ action: "query", titles: [mw.config.get("wgPageName")], })   .then( function (ret) { $.each(ret.query.pages, function {          if (this.missing == "") {            if ( mw.config.get("wgNamespaceNumber") == 0 && ($.urlParam("action") == "edit" ||               $.urlParam("veaction") == "edit" ||                $.urlParam("veaction") == "editsource") ) {             var ParseParams = {                action: "parse",                page: "Template:AutoNewPageButtons",                format: "json",              };              var ParseAPI = new mw.Api;

ParseAPI.get(ParseParams).done(function (data) {               $(".firstHeading").before(data.parse.text["*"]);                $(".AutoNewPageButtons").replaceWith( " " +                   $(".AutoNewPageButtons") .html .replace(                       /Template:AutoNewPageButtons/g,                        mw.config.get("wgPageName")                      ) );               $('a[href*="&preload="]').attr("target", "_self");              }); }         } else { return; }       });      },      function (error) {        return;      }    ); // end image upload form var PollRailParams = { action: "parse", page: "Template:PollRailModule", format: "json", }; var PollRailAPI = new mw.Api;

PollRailAPI.get(PollRailParams).done(function (data) {   $("#mw-related-navigation").append(data.parse.text["*"]);  }); //Custom page styles based on shows //There is nothing in MediaWiki:Series Themes.css that could possibly violate tos as I have been accused of. There is nothing there that hides anything, certantly not ads! If there is, I am sorry, it will be fixed, but at least re-approve everything. //Ads show for me even with these styles on. I do not know what you mean by they are hidden by it, so I am resubmitting this.

//Batman: Classic TV Series if ($("aside").hasClass("pi-theme-Batman_-Classic-TV-Series")) { $(document.body).addClass("Batman-Classic-TV-Series-Article"); } //The Green Hornet if ($("aside").hasClass("pi-theme-The-Green-Hornet")) { $(document.body).addClass("The-Green-Hornet-Article"); } //The Flash (1990) if ($("aside").hasClass("pi-theme-The-Flash-_1990")) { $(document.body).addClass("The-Flash-1990-Article"); } //Birds of Prey if ($("aside").hasClass("pi-theme-Birds-of-Prey")) { $(document.body).addClass("Birds-of-Prey-Article"); } //Smallville if ($("aside").hasClass("pi-theme-Smallville")) { $(document.body).addClass("Smallville-Article"); } //Arrow if ($("aside").hasClass("pi-theme-Arrow")) { $(document.body).addClass("Arrow-Article"); } //Arrow - Blood Rush if ($("aside").hasClass("pi-theme-Blood-Rush")) { $(document.body).addClass("Arrow-Article"); } //Arrow - Year One if ($("aside").hasClass("pi-theme-Year-One")) { $(document.body).addClass("Arrow-Article"); } //Arrow - Arrow: Hitting the Bullseye if ($("aside").hasClass("pi-theme-Arrow_-Hitting-the-Bullseye")) { $(document.body).addClass("Arrow-Article"); } //The Flash (2014) if ($("aside").hasClass("pi-theme-The-Flash-_2014")) { $(document.body).addClass("The-Flash-2014-Article"); } //The Flash (2014) - Stretched Scene if ($("aside").hasClass("pi-theme-Stretched-Scene")) { $(document.body).addClass("The-Flash-2014-Article"); } //The Flash (2014) - Chronicles of Cisco if ($("aside").hasClass("pi-theme-Chronicles-of-Cisco")) { $(document.body).addClass("The-Flash-2014-Article"); } //The Flash (2014) - Chasing Lightning if ($("aside").hasClass("pi-theme-Chasing-Lightning")) { $(document.body).addClass("The-Flash-2014-Article"); } //Constantine if ($("aside").hasClass("pi-theme-Constantine")) { $(document.body).addClass("Constantine-Article"); } //Constantine - John Con Noir if ($("aside").hasClass("pi-theme-John-Con-Noir")) { $(document.body).addClass("Constantine-Article"); } //Constantine - Constantine: The Legend Continues if ($("aside").hasClass("pi-theme-Constantine_-The-Legend-Continues")) { $(document.body).addClass("Constantine-Article"); } //Vixen if ($("aside").hasClass("pi-theme-Vixen")) { $(document.body).addClass("Vixen-Article"); } //Vixen: The Movie if ($("aside").hasClass("pi-theme-Vixen_-The-Movie")) { $(document.body).addClass("Vixen-Article"); } //Supergirl if ($("aside").hasClass("pi-theme-Supergirl")) { $(document.body).addClass("Supergirl-Article"); } //DC's Legends of Tomorrow if ($("aside").hasClass("pi-theme-DC_s-Legends-of-Tomorrow")) { $(document.body).addClass("Legends-of-Tomorrow-Article"); } //Mr. Parker's Cul-De-Sac if ($("aside").hasClass("pi-theme-Mr_-Parker_s-Cul-De-Sac")) { $(document.body).addClass("Mr-Parkers-Cul-De-Sac-Article"); } //DC's Legends of Tomorrow - DC's Legends of Tomorrow: Their Time Is Now if (   $("aside").hasClass("pi-theme-DC_s-Legends-of-Tomorrow_-Their-Time-Is-Now")  ) { $(document.body).addClass("Legends-of-Tomorrow-Article"); } //Lucifer if ($("aside").hasClass("pi-theme-Lucifer")) { $(document.body).addClass("Lucifer-Article"); } //Freedom Fighters: The Ray if ($("aside").hasClass("pi-theme-Freedom-Fighters_-The-Ray")) { $(document.body).addClass("Freedom-Fighters_-The-Ray-Article"); } //Freedom Fighters: The Ray (Movie) if ($("aside").hasClass("pi-theme-Freedom-Fighters_-The-Ray-_Movie")) { $(document.body).addClass("Freedom-Fighters-The-Ray-Article"); } //Black Lightning if ($("aside").hasClass("pi-theme-Black-Lightning")) { $(document.body).addClass("Black-Lightning-Article"); } //Titans if ($("aside").hasClass("pi-theme-Titans")) { $(document.body).addClass("Titans-Article"); } //Swamp Thing if ($("aside").hasClass("pi-theme-Swamp-Thing")) { $(document.body).addClass("Swamp-Thing-Article"); } //Doom Patrol if ($("aside").hasClass("pi-theme-Doom-Patrol")) { $(document.body).addClass("Doom-Patrol-Article"); } //Batwoman if ($("aside").hasClass("pi-theme-Batwoman")) { $(document.body).addClass("Batwoman-Article"); } //Stargirl if ($("aside").hasClass("pi-theme-Stargirl")) { $(document.body).addClass("Stargirl-Article"); } //Stargirl - Stargirl Aftershow if ($("aside").hasClass("pi-theme-Stargirl-Aftershow")) { $(document.body).addClass("Stargirl-Article"); } //Superman & Lois if ($("aside").hasClass("pi-theme-Superman-_-Lois")) { $(document.body).addClass("Superman-and-Lois-Article"); } //Green Arrow and the Canaries if ($("aside").hasClass("pi-theme-Green-Arrow-and-the-Canaries")) { $(document.body).addClass("Green-Arrow-and-the-Canaries-Article"); } //Green Lantern if ($("aside").hasClass("pi-theme-Green-Lantern")) { $(document.body).addClass("Green-Lantern-Article"); } //Superman: The Motion Picture Anthology if ($("aside").hasClass("pi-theme-Superman_-The-Motion-Picture-Anthology")) { $(document.body).addClass("Superman-The-Motion-Picture-Anthology-Article"); } //Batman: The Motion Picture Anthology if ($("aside").hasClass("pi-theme-Batman_-The-Motion-Picture-Anthology")) { $(document.body).addClass("Batman-The-Motion-Picture-Anthology-Article"); } //Arrowverse if ($("aside").hasClass("pi-theme-Arrowverse")) { $(document.body).addClass("Arrowverse-Article"); } //Arrowverse - Crisis Aftermath if ($("aside").hasClass("pi-theme-Crisis-Aftermath")) { $(document.body).addClass("Arrowverse-Article"); } //DC Extended Universe if ($("aside").hasClass("pi-theme-DC-Extended-Universe")) { $(document.body).addClass("DC-Extended-Universe-Article"); } //DC Extended Universe - DC Films Presents: The Dawn of the Justice League if (   $("aside").hasClass( "pi-theme-DC-Films-Presents_-The-Dawn-of-the-Justice-League" ) ) {    $(document.body).addClass("DC-Extended-Universe-Article"); } //Default (to prevent the other background from loading first) $(document.body).removeClass( "skin-timeless" ).addClass( "DC-Multiverse-Wiki-Body" ); });

$('#cs-body-edit-field').attr('placeholder', 'Please be respectful to other users and administrators.'); if(mw.config.get("wgCategories" ) < 1){ $('.catlinks').css('display', 'none'); } //mw.loader.load( '/w/index.php?title=MediaWiki:HighlightGroups.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/w/index.php?title=MediaWiki:PageTools.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/w/index.php?title=MediaWiki:FastDelete.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/w/index.php?title=MediaWiki:MarkBlocked.js&action=raw&ctype=text/javascript' ); if($('#profile-top').length > 0 === false){ mw.loader.load( '/w/index.php?title=MediaWiki:PageRenameAuto-Update.js&action=raw&ctype=text/javascript' ); } mw.loader.load( '/w/index.php?title=MediaWiki:CategoryRenameAuto-Update.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/w/index.php?title=MediaWiki:EditConflictAlert.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/w/index.php?title=MediaWiki:AjaxUndo.js&action=raw&ctype=text/javascript' ); /*mw.loader.load( '/w/index.php?title=MediaWiki:MisspelledPage.js&action=raw&ctype=text/javascript' );*/ mw.loader.load( '/w/index.php?title=MediaWiki:AddCategories.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/w/index.php?title=MediaWiki:AjaxEdit.js&action=raw&ctype=text/javascript' ); /*mw.loader.load( '/w/index.php?title=MediaWiki:AjaxRC.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/w/index.php?title=MediaWiki:MassEdit.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/w/index.php?title=MediaWiki:MassProtect.js&action=raw&ctype=text/javascript' ); mw.loader.load( '/w/index.php?title=MediaWiki:MassDelete.js&action=raw&ctype=text/javascript' ); //mw.loader.load( '/w/index.php?title=MediaWiki:QuickDelete.js&action=raw&ctype=text/javascript' );*/

var waitForPageTools = function(selector, callback) { if ($(selector).length) { callback; } else { setTimeout(function {     waitForPageTools(selector, callback);    }, 100); } };

waitForPageTools('#cosmos-actionsList-list', function { if($('#ca-edit').length > 0 === true){ if($('#profile-top').length > 0 === false){   mw.loader.load( '/w/index.php?title=MediaWiki:AjaxRedirect.js&action=raw&ctype=text/javascript' ); } if(window.ViewSource === true){    mw.loader.load( '/w/index.php?title=MediaWiki:ViewSource.js&action=raw&ctype=text/javascript' );  } } }); $(function {    'use strict';

if (window.wikitextEditor) { return; }   window.wikitextEditor = { mode: 'none' };

if (['submit', 'edit'].indexOf(mw.config.get('wgAction')) !== -1) { // CodeMirror if ($('#wpTextbox1 + .CodeMirror').length > 0) { window.wikitextEditor = { get mode { return 'codemirror'; },               get text { return $('#wpTextbox1').val; },               set text(t) { $('#wpTextbox1').val(t); },               get summary { return $('#wpSummary').val; },               set summary(text) { $('#wpSummary').val(text); },               get minorEdit { return $('#wpMinoredit').attr('checked') && true; },               set minorEdit(v) { if (v) { $('#wpMinoredit').attr('checked', 'checked'); } else { $('#wpMinoredit').removeAttr('checked'); }               },                submit: function  { $('#wpSave').click; },               showPreview: function  { $('#wpPreview').click; },               showDiff: function  { $('#wpDiff').click; },               get selectionStart { return $('#wpTextbox1').textSelection('getCaretPosition'); },               set selectionStart(pos) { var end = $('#wpTextbox1').textSelection('getCaretPosition', {startAndEnd:true})[1]; $('#wpTextbox1').textSelection('setSelection', {                       start: pos,                        end: end                    }); },               get selectionEnd { return $('#wpTextbox1').textSelection('getCaretPosition', {startAndEnd:true})[1]; },               set selectionEnd(pos) { var start = $('#wpTextbox1').textSelection('getCaretPosition'); $('#wpTextbox1').textSelection('setSelection', {                       start: start,                        end: pos                    }); },               get selectionText { return $('#wpTextbox1').textSelection('getSelection'); },               set selectionText(text) { $('#wpTextbox1').textSelection('encapsulateSelection', {                       replace: true,                        peri: text,                    }); },           };            mw.hook('editorapi.ready').fire(window.wikitextEditor); } else { var textbox = document.getElementById('wpTextbox1'); window.wikitextEditor = { get mode { if (window.wikEd && wikEd.useWikEd) { return 'wikEd'; } else { return 'wikitext'; }               },                get text { if (window.wikEd && wikEd.useWikEd) { wikEd.UpdateTextarea; }                   return $('#wpTextbox1').val; },               set text(t) { $('#wpTextbox1').val(t); if (window.wikEd && wikEd.useWikEd) { wikEd.UpdateFrame; }               },                get summary { return $('#wpSummary').val; },               set summary(text) { $('#wpSummary').val(text); },               get minorEdit { return $('#wpMinoredit').attr('checked') && true; },               set minorEdit(v) { if (v) { $('#wpMinoredit').attr('checked', 'checked'); } else { $('#wpMinoredit').removeAttr('checked'); }               },                submit: function  { $('#wpSave').click; },               showPreview: function  { $('#wpPreview').click; },               showDiff: function  { $('#wpDiff').click; },               get selectionStart { // TODO: WikEd支援. 後面selectionEnd同. return textbox.selectionStart; },               set selectionStart(pos) { textbox.selectionStart = pos; },               get selectionEnd { return textbox.selectionEnd; },               set selectionEnd(pos) { textbox.selectionEnd = pos; },               get selectionText { if (window.wikEd && wikEd.useWikEd) { var obj = {}; wikEd.GetText(obj, 'selection, cursor'); return obj.selection.plain || ''; } else { return textbox.value.substring(textbox.selectionStart, textbox.selectionEnd); }               },                set selectionText(text) { if (window.wikEd && wikEd.useWikEd) { wikEd.EditButton(null, null, null, function (obj) {                           wikEd.GetText(obj, 'selection, cursor');                            if (obj.selection.plain !== '') {                                obj.changed = obj.selection;                            } else {                                obj.changed = obj.cursor;                            }                            obj.changed.plain = text;                            obj.changed.keepSel = true;                            return;                        }); } else { textbox.setRangeText(text); }               },            };            mw.hook('editorapi.ready').fire(window.wikitextEditor); }   } else if (window.editorapi && window.editorapi.useViewMode) { var submitForm = function (options) { $('') .attr('action', mw.util.getUrl(mw.config.get('wgPageName'), {action: 'submit'})) .attr('enctype', 'multipart/form-data') .append($('').val(options.text || ),                   $('<input name="wpSummary">').val(options.summary || ),                    '<input name="wpMinoredit" type="checkbox" value="1"' + (options.minorEdit ? ' checked="checked"' : '') + '>',                   '<input name="format" value="text/x-wiki">',                    '<input name="wpAutoSummary" value="hashhashhashhash">',                    '<input name="model" value="wikitext">',                    '<input name="wpEditToken" value="' + mw.user.tokens.get('editToken') + '">',                    '<input name="wpUltimateParam" value="1">',                    '<input name="' + (options.button || 'wpSave') + '" type="submit" value="1">',                    '<input name="mode" value="text">') .appendTo('body').submit; };

var e = { mode: 'view', text: null, summary: '', minorEdit: false, submit: function { submitForm({                   text: this.text,                    summary: this.summary,                    minorEdit: this.minorEdit,                    button: 'wpSave',                }); },           showPreview: function  { submitForm({                   text: this.text,                    summary: this.summary,                    minorEdit: this.minorEdit,                    button: 'wpPreview',                }); },           showDiff: function  { submitForm({                   text: this.text,                    summary: this.summary,                    minorEdit: this.minorEdit,                    button: 'wpDiff',                }); },           selectionStart: 0, selectionEnd: 0, get selectionText { return this.text.substring(this.selectionStart, this.selectionEnd); },           set selectionText(text) { this.text = this.text.substring(0, this.selectionStart) + text + this.text.substring(this.selectionEnd); },       };

$.ajax({           url: mw.util.wikiScript('api'),            data: {                action: 'query',                prop: 'revisions',                rvprop: 'content',                titles: mw.config.get('wgPageName'),                format: 'json',            },            dataType: 'json',            type: 'POST',            success: function (data) {                if (data.query) {                    var pages = data.query.pages;                    for (var pageid in pages) {                        var page = pages[pageid];                        if (e.text === null && !('missing' in page)) {                            e.text = page.revisions[0]['*'];                        }                    }                }            }        });

window.wikitextEditor = e;       mw.hook('editorapi.ready').fire(window.wikitextEditor); }

(function {        var data2text = function (data) {            var r = [];            if (data) {                for (var i=0; i<data.length; i++) {                    if (typeof data[i] === 'string') {                        r.push(data[i]);                    } else if (data[i] && data[i].type === '/paragraph') {                        r.push('\n');                    }                }                return r.join();            } else {                return ;            }        };

var pendingSummary = ''; var pendingMinoredit = false; var pendingAction = ''; var addedHook = false;

mw.hook('ve.activationComplete').add(function {            var surface = ve.init.target.getSurface;            var surfaceModel = surface.getModel;

var processed = false; var addHook = function { if (!addedHook) { mw.hook('ve.saveDialog.stateChanged').add(function {                       if (ve.init.target.saveDialog && !processed) {                            var dialog = ve.init.target.saveDialog;                            dialog.setEditSummary(pendingSummary || '');                            dialog.checkboxesByName.wpMinoredit.setSelected(pendingMinoredit && true);

setTimeout(function {                                if (!ve.init.target.saveDialog) { return; }                                switch (pendingAction) {                                    case 'submit':                                        dialog.executeAction('save');                                        break;                                    case 'diff':                                        dialog.executeAction('review');                                        break;                                    case 'preview':                                        dialog.executeAction('preview');                                        break;                                }                            }, 500); processed = true; }                   });                    addedHook = true;                }            };

// FIXME: HACK var keepSel = false; var lastSel;

window.wikitextEditor = { get mode { if (surface.getMode === 'visual') { return 'visual'; } else { return 'wikitext2017'; }               },                get text { if (surface.getMode === 'visual') { return null; }                   var data = surfaceModel.documentModel.data; if (data && data.data) { return data2text(data.data); } else { return ''; }               },                set text(text) { if (surface.getMode === 'visual') { return; }                   var rangeToRemove = new ve.Range(0, surfaceModel.documentModel.getLength); var fragment = surfaceModel.getLinearFragment(rangeToRemove); fragment.insertContent(text); },               get summary { if (ve.init.target.saveDialog) { return ve.init.target.saveDialog.editSummaryInput.$input.val; } else { return pendingSummary || ''; }               },                set summary(text) { if (ve.init.target.saveDialog) { ve.init.target.saveDialog.setEditSummary(text); } else { pendingSummary = text; addHook; }               },                get minorEdit { if (ve.init.target.saveDialog) { return ve.init.target.saveDialog.checkboxesByName.wpMinoredit.selected; } else { return pendingMinoredit && true; }               },                set minorEdit(v) { if (ve.init.target.saveDialog) { ve.init.target.saveDialog.checkboxesByName.wpMinoredit.setSelected(v && true); } else { pendingMinoredit = v && true; addHook; }               },                submit: function  { if (ve.init.target.saveDialog) { if (!ve.init.target.saveDialog.visible) { ve.init.target.saveDialog.open.then(function {                               ve.init.target.saveDialog.executeAction('save');                            }); } else { ve.init.target.saveDialog.executeAction('save'); }                   } else { pendingAction = 'submit'; addHook; ve.init.target.toolbarSaveButton.emit('click'); }               },                showPreview: function  { if (ve.init.target.saveDialog) { if (!ve.init.target.saveDialog.visible) { ve.init.target.saveDialog.open.then(function {                               ve.init.target.saveDialog.executeAction('preview');                            }); } else { ve.init.target.saveDialog.executeAction('preview'); }                   } else { pendingAction = 'preview'; addHook; ve.init.target.toolbarSaveButton.emit('click'); }               },                showDiff: function  { if (ve.init.target.saveDialog) { if (!ve.init.target.saveDialog.visible) { ve.init.target.saveDialog.open.then(function {                               ve.init.target.saveDialog.executeAction('review');                            }); } else { ve.init.target.saveDialog.executeAction('review'); }                   } else { pendingAction = 'diff'; addHook; ve.init.target.toolbarSaveButton.emit('click'); }               },                get selectionStart { var selection = surfaceModel.getSelection; if (selection instanceof ve.dm.LinearSelection) { return selection.getRange.start; } else { return null; }               },                set selectionStart(pos) { var selection = surfaceModel.getSelection; if (selection instanceof ve.dm.LinearSelection) { surfaceModel.setLinearSelection(new ve.Range(pos, selection.getRange.end)); }               },                get selectionEnd { var selection = surfaceModel.getSelection; if (selection instanceof ve.dm.LinearSelection) { return selection.getRange.end; } else { return null; }               },                set selectionEnd(pos) { var selection = keepSel ? lastSel : surfaceModel.getSelection; if (selection instanceof ve.dm.LinearSelection) { surfaceModel.setLinearSelection(new ve.Range(selection.getRange.start, pos)); }               },                get selectionText { var selection = surfaceModel.getSelection; if (selection instanceof ve.dm.LinearSelection) { var fragment = surfaceModel.getLinearFragment(selection.getRange); return data2text(fragment.getData); } else { return ''; }               },                set selectionText(text) { var selection = keepSel ? lastSel : surfaceModel.getSelection; if (selection instanceof ve.dm.LinearSelection) { var fragment = surfaceModel.getLinearFragment(selection.getRange); fragment.insertContent(text); }               },                set keepSelection(v) { if (v) { keepSel = true; lastSel = surfaceModel.getSelection; } else { keepSel = false; }               }            };            mw.hook('editorapi.ready').fire(window.wikitextEditor); });   });

}); }); // ***************************************************** // * 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 = ""; }   // calculate the diff

if (diff % 60 == 1) { var left = (diff % 60) + " second "; } else { left = (diff % 60) + " seconds "; }   diff = Math.floor(diff / 60); if (diff % 60 == 1) { left = (diff % 60) + " minute " + left; } else { if (diff > 0) left = (diff % 60) + " minutes " + left; }

diff = Math.floor(diff / 60); if (diff % 24 == 1) { left = (diff % 24) + " hour " + left; } else { if (diff > 0) left = (diff % 24) + " hours " + left; }   diff = Math.floor(diff / 24); if (diff == 1) { left = diff + " day " + left; } else { 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   } } $(checktimers);