User:Sonicwave/common.js

// User:KnightMiner/autosign.js mw.loader.load( '/index.php?title=User:KnightMiner/autosign.js&action=raw&ctype=text/javascript' );

// https://terraria.gamepedia.com/MediaWiki:Gadget-utcClock.js

var lang = function ( message ) { return "Click to purge cache for current page"; }

var linkPurge = mw.config.get( 'wgScript' ) + '?title=' + encodeURIComponent( mw.config.get( 'wgPageName' ) ) + '&action=purge';

var clockStyle = 'font-weight:bolder; color:#fff; font-size:150%;';

window.showTime = function { var now = new Date; var hh = now.getUTCHours; var mm = now.getUTCMinutes; var ss = now.getUTCSeconds; var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss ); $('.dateNode').text( time ); var ms = now.getUTCMilliseconds; setTimeout( function {		showTime;	}, 1100 - ms ); }

$(function {	$('.netbar-box.right:first').before('  ');	showTime; });

// https://help.gamepedia.com/MediaWiki:Gadget-multiupload.js

mw.loader.using(['site']).then(function {	i18n = {		multiupload: "Upload multiple files:",		yes: "Yes",		no: "No",		sourcefiles: "Source files:",		uploadfiles: "Upload files",		nofiles: "Please select some files first.",		nolicense: "Please select a valid license first.",		summary: "Summary",		license: "License",		uploading: "Uploading files...",		uploaded: "Uploaded:",		failed: "Failed:",		done: "Done."	};	if (mw.config.get("wgCanonicalSpecialPageName")!=="Upload") return;		$("#wpUploadFile").parent.parent.addClass("regularFileSelect");	$("tr.regularFileSelect").before(' '+i18n.multiupload+'   '+i18n.yes+'   '+i18n.no+'  ');	$("tr.regularFileSelect").after(''+i18n.sourcefiles+'   '); $("input[name='wpUpload']").addClass("regularFileSelect"); $("#wpDestFile").parent.parent.addClass("regularFileSelect"); $("#wpIgnoreWarning").parent.parent.addClass("regularFileSelect"); $("span.mw-htmlform-submit-buttons").append(''); $("input[name='multipleFiles']").change(function{		if (this.value===i18n.yes) {			$(".regularFileSelect").hide;			$(".multipleFileSelect").show;		}		else {			$(".regularFileSelect").show;			$(".multipleFileSelect").hide;		}	}); $("#multiFileSubmit").click(function {		files = $("#multiupload")[0].files;		if (files.length === 0) {			alert(i18n.nofiles);			return false;		}		if ($("#wpLicense option:selected").val === "") {			alert(i18n.nolicense);			return false;		}		summary = $("#wpUploadDescription").val;		if (summary !== "") summary = "== "+i18n.summary+" ==\n"+summary;		license = "== "+i18n.license+" ==\n"+$("#wpLicense option:selected").prop("title");		text = summary + "\n" + license;		watch = "preferences";		if ($("#wpWatchthis").is(":checked")) watch = "watch";		else watch = "nochange";		curFile = 0;		$("#firstHeading").text(i18n.uploading);		$("#mw-content-text").html(" "+i18n.uploaded+"  "+i18n.failed+"  ");		function gNF {			if(curFile>files.length) {				$("#mw-content-text").append(" "+i18n.done+" ");				return;			}	       if(files[curFile] === undefined) {                curFile++; gNF; return; }			$.ajax({url:'/api.php',data:{action:'query',meta:'tokens',format:'json'},dataType:'json'}).done(function(data) {				fd = new FormData;				fd.append("action","upload");				fd.append("token",data.query.tokens.csrftoken);				fd.append("filename",files[curFile].name);				fd.append("file",files[curFile]);				fd.append("text",text);				fd.append("watchlist",watch);				fd.append("ignorewarnings",1);				fd.append("format","json");				$.ajax({ url:'/api.php', method:'POST', data:fd, cache:false, contentType:false, processData:false, type:'POST' }).done(function(d){ if (d.error == undefined) { $("#mw-content-text > ul").append('<a href="'+d.upload.imageinfo.descriptionurl+'" target="_blank">'+d.upload.filename+'</a></li>'); }		     		else { $("#multiUploadFailed ul").append('<li>'+files[curFile].name+'</li>'); $("#multiUploadFailed").show; }					curFile++; gNF; }).fail(function(d) { $("#multiUploadFailed ul").append('<li>'+files[curFile].name+'</li>'); $("#multiUploadFailed").show; curFile++; gNF; });		   });		}		gNF; }); });

// https://terraria.gamepedia.com/MediaWiki:Gadget-redirect-modifier.js

$(function {	$("a,a *").click(function(event) { if (!event.altKey) return; h = $(event.target).attr("href"); if (h.indexOf("?")==-1) h+="?redirect=no"; else h+= "&redirect=no"; $(event.target).attr("href", h); location.href = h;	}); });