×
Create a new article
Write your page title here:
We currently have 3,602 articles on DC Multiverse Wiki. Type your article name above or create one of the articles listed here!



    DC Multiverse Wiki

    MediaWiki:Cosmos.js: Difference between revisions

    Content added Content deleted
    (Remove now-unnecessary AdminLinks delimiter override that is now in the AdminLinks extension directly)
    m (Text replacement - "/wiki/" to "/")
    Line 10: Line 10:
    window.JSloaded = true;
    window.JSloaded = true;
    if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == 'UpdateProfile' ) {
    if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == 'UpdateProfile' ) {
    $( '.page-Special_UpdateProfile div.profile-update:nth-of-type(1) > .profile-update-title' ).append( '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/wiki/User:' + mw.config.get( "wgUserName" ) + '/bio?action=edit">Edit Bio</a>' );
    $( '.page-Special_UpdateProfile div.profile-update:nth-of-type(1) > .profile-update-title' ).append( '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/User:' + mw.config.get( "wgUserName" ) + '/bio?action=edit">Edit Bio</a>' );
    }
    }



    Revision as of 20:27, 17 May 2023

    /* All JavaScript here will be loaded for users of the Cosmos skin */
    $( function () {
    	if ( window.JSloaded ) {
    		return;
    	}
    
    	$( "#discord-widget" ).html( '<iframe src="https://discord.com/widget?id=726169892071407737&theme=dark" width="100%" height="500" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>' );
    
    
    	window.JSloaded = true;
    	if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == 'UpdateProfile' ) {
    		$( '.page-Special_UpdateProfile div.profile-update:nth-of-type(1) > .profile-update-title' ).append( '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="/User:' + mw.config.get( "wgUserName" ) + '/bio?action=edit">Edit Bio</a>' );
    	}
    
    	mw.config.set( {
    		'wgAjaxLicensePreview': true
    	} );
    
    	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( '<p>You do not have permission to view admin links, for the following reason:</p><div class="permissions-errors"><p>You are not allowed to execute the action you have requested.</p>' );
    	}
    
    	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' );
    		}
    
    		if ( mw.config.get( "wgPageName" ).replace( 'User_profile:', 'User:' ) == "User:TheDemon08" ) {
    			$( '.hgroup' ).append( '<span class="tag tag-founder">Founder</span>' );
    			$( '.hgroup' ).append( '<span class="tag tag-team_lead_titans">Team Lead: Titans</span>' );
    		} else if ( mw.config.get( "wgPageName" ).replace( 'User_profile:', 'User:' ) == "User:Universal_Omega" ) {
    			$( '.hgroup' ).append( '<span class="tag tag-team_lead_stargirl">Team Lead: Stargirl</span>' );
    		} else if ( mw.config.get( "wgPageName" ).replace( 'User_profile:', 'User:' ) == "User:IC228" ) {
    			$( '.hgroup' ).append( '<span class="tag tag-team_lead_the_flash_2014">Team Lead: The Flash (2014)</span>' );
    		} else if ( mw.config.get( "wgPageName" ).replace( 'Userfile:', 'User:' ) == "User:MysticalmanJoe" ) {
    			$( '.hgroup' ).append( '<span class="tag tag-team_lead_arrow">Team Lead: Arrow</span>' );	
    		} else if ( mw.config.get( "wgPageName" ).replace( 'User_profile:', 'User:' ) == "User:Rman41" ) {
    			$( '.hgroup' ).append( '<span class="tag tag-team_lead_superman_anthology">Team Lead: Superman Anthology</span>' );
    		}
    	}
    
    	$.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 ];
    		},
    	} );
    	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;
    	};
    	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.loader.using( [ "mediawiki.jqueryMsg", "mediawiki.api" ], function () {
    		if ( mw.config.get( "wgUserGroups" ).includes( "autoconfirmed" ) === true && mw.config.get( 'wgPageName' ) == 'Special:MultiUpload' ) {
    			$.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
    						} );
    
    						mw.loader.load( '/w/index.php?title=MediaWiki:MultiUpload.js&action=raw&ctype=text/javascript' );
    					} );
    			} );
    		}
    
    		if ( mw.config.get( "wgUserGroups" ).includes( "autoconfirmed" ) === true && mw.config.get( 'wgPageName' ) == 'Special:MassEdit' ) {
    			mw.loader.load( '/w/index.php?title=MediaWiki:MassEdit.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 );
    					}
    				} );
    		}
    		if ( mw.config.get( "wgArticleId" ) == 0 ) {
    			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(
    						"<center>" +
    						$( ".AutoNewPageButtons" )
    						.html()
    						.replace(
    							/Template:AutoNewPageButtons/g,
    							mw.config.get( "wgPageName" )
    						)
    					);
    					$( 'a[href*="&preload="]' ).attr( "target", "_self" );
    				} );
    			}
    		} else {
    			return;
    		}
    	} );
    } );
    
    // *****************************************************
    // * Experimental javascript countdown timer (Splarka) *
    // * Version 0.0.3                                     *
    // *****************************************************
    //
    // Usage example:
    //  <span class="countdown" style="display:none;">
    //  Only <span class="countdowndate">January 01 2007 00:00:00 PST</span> until New years.
    //  </span>
    //  <span class="nocountdown">Javascript disabled.</span>
    
    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 );
    
    /*mw.config.set( 'wgCosmosSearchClient', {
    	fetchByTitle: function ( query, domain, limit ) {
    		limit = 6;
    
    		var xhr = fetch( 'https://' + domain + '/w/api.php?format=json&action=query&generator=prefixsearch&prop=pageprops|pageimages|extracts&redirects=&ppprop=displaytitle&piprop=thumbnail&pithumbsize=200&pilimit=' + limit + '&gpssearch=' + query + '&gpsnamespace=0&gpslimit=' + limit + '&exchars=60&exintro=false&exlimit=' + limit + '&explaintext=true&formatversion=2' )
    			.then( function ( resp ) {
    				return resp.json();
    			} ).then( function ( json ) {
    				if ( json.query && json.query.pages ) {
    					( json.query.pages ).forEach( function ( page ) {
    						if ( page.extract ) {
    							page.description = page.extract;
    
    							delete( page.extract );
    						}
    
    						if ( page.pageprops && page.pageprops.displaytitle ) {
    							page.title = ( page.pageprops.displaytitle ).replace( /<\/?[^>]+(>|$)/g, '' );
    
    							delete( page.pageprops.displaytitle );
    						}
    
    						if ( page.thumbnail && page.thumbnail.source ) {
    							page.thumbnail.url = page.thumbnail.source;
    
    							delete( page.thumbnail.source );
    						}
    					} );
    				}
    
    				if ( json.query && json.query.pages ) {
    					return {
    						results: json.query.pages
    					}
    				} else {
    					return {
    						results: []
    					}
    				}
    			} );
    		return {
    			fetch: xhr,
    			abort: function () {}
    		}
    	}
    } );*/
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • IC228 • 4 hours ago
  • IC228 • 15 hours ago
  • IC228 • 1 day ago
  • IC228 • 1 day ago
  • Welcome to the DC Multiverse Wiki


    Cookies help us deliver our services. By using our services, you agree to our use of cookies.