User:Euphoria/common.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
Content deleted Content added
fix
Cleanup
Tag: Blanked
 
(62 intermediate revisions by the same user not shown)
Line 1: Line 1:

//<nowiki>
mw.loader.using('mediawiki.util', function () {
if (mw.config.get('wgPageName').startsWith('User:Euphoria/TestVfD/')) {
// Add "Close as delete"
mw.util.addPortletLink(
'p-cactions',
'#',
'Close as delete',
'ca-close-delete',
'Close this VfD as delete'
).addEventListener('click', function (e) {
e.preventDefault();
insertClosure('delete');
});

// Add "Close as keep"
mw.util.addPortletLink(
'p-cactions',
'#',
'Close as keep',
'ca-close-keep',
'Close this VfD as keep'
).addEventListener('click', function (e) {
e.preventDefault();
insertClosure('keep');
});

// Add "Close as no consensus"
mw.util.addPortletLink(
'p-cactions',
'#',
'Close as no consensus',
'ca-close-nc',
'Close this VfD as no consensus'
).addEventListener('click', function (e) {
e.preventDefault();
insertClosure('no consensus');
});

function insertClosure(action) {
var topText = '{{subst:vt|' + action + '. --~~~~}}\n\n';
var bottomText = '\n\n{{subst:vb}}';

// Access the edit box
var textbox = document.getElementById('wpTextbox1');
if (!textbox) {
alert('Edit box not found!');
return;
}

// Insert templates at top and bottom
textbox.value = topText + textbox.value + bottomText;

// Prefill summary
document.getElementById('wpSummary').value = 'Closed as ' + action;
}
}
});
//</nowiki>

Latest revision as of 07:52, 3 October 2025