Jump to content

User:Lilac Soul/sign.js

From Wikipedia, the free encyclopedia
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.
// <pre>
// <nowiki>
function doSign(n) {
	text = document.editform.wpTextbox1.value;
	date = new Date();
        document.editform.wpSummary.value += ' -comment by [[User:Lilac Soul|Lilac Soul]]';
	switch(n) {
        case 'short':
                insertTags('','',' ~~~~');
                document.getElementById('wpPreview').click();
                break;
        case 'long':
                insertTags('','',' {{subst:User:Lilac Soul/plainsig}} ~~~~~');
                document.getElementById('wpWatchthis').click();
                document.getElementById('wpPreview').click();
                break;
        case 'short direct':
                insertTags('','',' ~~~~');
		document.editform.submit();
                break;
        case 'long direct':
                insertTags('','',' {{subst:User:Lilac Soul/plainsig}} ~~~~~');
                document.getElementById('wpWatchthis').click();

		document.editform.submit();
                break;
	}
 
 
}


addOnloadHook(function() {
		if ( mw.config.get('wgCanonicalNamespace')  in { "Talk":'', "User_talk":'' } ) {
                if (document.editform) {
			var stabs = document.getElementById( 'p-cactions' ).getElementsByTagName( 'ul' )[0];
			addlimenu(stabs, "sign", "sign" );	
			addPortletLink("sign", "javascript:doSign('short')", "short", "short", "Add short signature", "");
			addPortletLink("sign", "javascript:doSign('long')", "long", "long", "Add long signature", "");
			addPortletLink("sign", "javascript:doSign('short direct')", "short direct", "short direct", "Add short signature and save immediately", "");
			addPortletLink("sign", "javascript:doSign('long direct')", "long direct", "long direct", "Add long signature and save immediately", "");		
		}
                }
	});
// </nowiki>
// </pre>