Jump to content

User:Technical 13/SandBox/EmailHelper.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Technical 13 (talk | contribs) at 15:54, 4 December 2014 (Notes about highjacking send button and wrap the whole thing in nowiki tags). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<nowiki>
if(mw.config.get("wgCanonicalSpecialPageName") === "Emailuser"){
	function parseEmail(){
		var wikiTimestamp = new Date();
		$('#mw-input-wpText').val($('#mw-input-wpText').val().replace(/\[\[(.*?)(\|.*?)?\]\]/gi, "\(- http://en.wikipedia.org/wiki/$1 -\)"));
		$('#mw-input-wpText').val($('#mw-input-wpText').val().replace(/~{3,4}/gi, mw.user.options.get('nickname')));
	}
	function sendEmail(){
		/* This will allow me to post the {{YGM}} template on the recievers talk page when clicking send */
	}

	$("label[for='mw-input-wpCCMe']").after('<input type="checkbox" checked="checked" value="1" id="YGM" />&nbsp;<label for="YGM">Leave {{<a href="/wiki/Template:You%27ve_got_mail">You\'ve got mail</a>}} on talkpage.</label>');
	/* Will need to highjack the send button here and create my own replacement send button the runs onClick="sendEmail()" */
	$('span.mw-htmlform-submit-buttons').append('<input class="mw-htmlform-parse" value="Preview" onClick="parseEmail()" type="button"></input>');
	$('span.mw-htmlform-submit-buttons').append('<input class="mw-htmlform-reset" type="reset" value="Reset"></input>');
}
//</nowiki>