User:Rigel Kent/common.js

/* Any JavaScript here will be loaded for all users on every page load. */ importArticles({   type: "script",    articles: [        "w:c:dev:Countdown/code.js"    ] });

/*Instagram Button*/ (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src="//x.instagramfollowbutton.com/follow.js";s.parentNode.insertBefore(g,s);}(document,"script"));

/* Username replace feature * Inserts viewing user's name into * Put text inside the spans to be viewed by logged out users * Originally by Splarka, then by Spang, * This (jQuery) version by wikia:User:Joeyaa, written to be backwards compatible */ if (wgUserName != 'null') { $('.insertusername').html(wgUserName); }

/* for Template:MusicPlay */ $(function {	// File:FILENAME 	function MusicPlay {		if ([2, 3, 10, 500].indexOf(mw.config.get("wgNamespaceNumber")) > -1 && $.cookie("embedmusic") != "disabled") { // namespace: ["User", "User talk", "Template", "User blog"], also MusicPlay function not disabled by the client			// file names array (includes the File: prefix)			var titles = [];

// all elements that require $("span.MusicPlay").each(function {				var slash = $(this).html.replace(/_/g," ").split("/"); // for dealing with old syntax, at least for now				$(this).html(slash.length == 1 ? slash[0] : "File:" + decodeURIComponent(slash[slash.length-1]));				var a = encodeURIComponent($(this).html);				if (titles.indexOf(a) == -1) {					titles.push(a);				}				$(this).attr("data-src", a);			}); $.getJSON("/api.php?action=query&format=json&prop=imageinfo&iiprop=mime|metadata|url&titles=" + titles.join("|") + "&cb=" + new Date.getTime, function(data) {				var a = data.query.pages;				for (var pageid in a) {					// if file exists					if (pageid > 0) {						// if is .ogg						if (a[pageid].imageinfo[0].mime == "application/ogg") {							var embed =								$(' ').attr({ "data": a[pageid].imageinfo[0].url, "type": "application/ogg", "height": "0", "width": "0", "class": "musictemplate MusicPlay" });							/*								could use for looping, if specified:								a[pageid].imageinfo[0].metadata.[i/* 'i' has property 'length'*\/].value							*/							$('span[data-src="' + encodeURIComponent(a[pageid].title.replace(/&/g,"&amp;")) + '"].MusicPlay').replaceWith(embed);						}					} else {						// file doesn't exist- modify 'span.MusicPlay' element						$('span[data-src="' + encodeURIComponent(a[pageid].title) + '"].MusicPlay').each(function { var errorFilename = a[pageid].title.replace(/"/g,"\\");							$(this).html(								''							);							console.error('MusicPlay Error: couldn\'t find file named "' + errorFilename + '"');						});					}				}			});		}	}	if (mw.config.get("wgAction") == "edit") {		// when ?action=edit		$(window).on("EditPageAfterRenderPreview", function {			MusicPlay;		});	} else if ($("span.MusicPlay").length > 0) {		// not in the editor but 'span.MusicPlay' exists		MusicPlay;	} });