User:Ahecht/sandbox/Scripts/sandbox.js

/* function disambigYear { var wpTextbox = document.getElementById("wpTextbox1"); wpTextbox.value = "" + mw.config.values.wgPageName +" may refer to:\n\n*" + mw.config.values.wgPageName + " (number)\n*AD "+mw.config.values.wgPageName+"\n*"+mw.config.values.wgPageName+" BC\n\n"; document.getElementById("wpSummary").value = ""; return false; }

$.when( mw.loader.using('mediawiki.util'), $.ready ).then( function {    mw.util.addPortletLink( 'p-tb', '', 'Disambig Year', 'dy-tb', 'Create redirect from Year',null,null);	document.getElementById("dy-tb").getElementsByTagName("a")[0].setAttribute('onclick', 'disambigYear;return false;'); } );

/* function replyTool { window.location.href = "https:" + mw.config.values.wgServer + mw.config.values.wgScript + "?title=" + mw.config.values.wgPageName + "&dtenable=1"; return false; }

/* function jqueryUIDemo { dldiv = document.createElement("div"); $( dldiv ).attr({			title: "Dialog title",		} ).append( 			$(document.createElement("form")).append( $(document.createElement("div")).append(					$(document.createElement("input")).attr({ type: "radio", id: "option-1", name: "radio-1", value: 1, checked: true }),					$(document.createElement("label")).attr({ for: "option-1" }).text("Option 1")				), $(document.createElement("div")).append(					$(document.createElement("input")).attr({ type: "radio", id: "option-2", name: "radio-1", value: 2 }),					$(document.createElement("label")).attr({ for: "option-2" }).text("Option 2")				) )		).dialog({			modal: true,			buttons: {				OK: function {					console.log( $('input[name="radio-1"]:checked').val );					$(this).dialog('close');				}			}		}); } // "R from middle name" function unnecessary { var wpTextbox = document.getElementById("wpTextbox1"); wpTextbox.value = wpTextbox.value.replace(/(.*)[\s\S]*/, "#REDIRECT $1\n\n\n\n#REDIRECT Talk:$1"); document.getElementById("wpSummary").value = wpTextbox.value.split('\n')[0]; return false; }

// Hide User: and User talk: function hideUser { document.querySelectorAll('a[title^="User:"],a[title^="User talk:"]').forEach(function(myItem) {myItem.parentElement.style.display = "none";}); return false; }

// Remove -- before signature $(document).ready( function { 	if( (/talk|project|wikipedia/i.test(mw.config.get('wgCanonicalNamespace'))) && (/action=edit/i.test(window.location.href)) ) {		var tildes = ""+"";		$( '#wpTextbox1' ).parent.keyup(function { i=$( '#wpTextbox1' ).textSelection('getContents').indexOf("--" + tildes); if (i > -1) { $( '#wpTextbox1' ).textSelection('setSelection', { start: i, end: i+6 }). textSelection('encapsulateSelection', { peri: tildes, replace: true }); }		} );	} } );

if(mw.config.get('wgNamespaceNumber')==118) {$.when( mw.loader.using('mediawiki.util'), $.ready ).then( function {mw.util.addPortletLink( 'p-navigation', 'https://iw.toolforge.org/randomincategory/Pending_AfC_submissions%26server%3Den.wikipedia.org%26namespace%3D2!118%26type%3Dpage', 'Random draft', 'n-randomdraft', null, null, '#n-randompage');});}