User:Euphoria/common.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Cleanup Tag: Blanked |
tɛst |
||
| Line 1: | Line 1: | ||
// [[User:YourName/common.js]] helper for VfD closures |
|||
mw.loader.using('mediawiki.util', function () { |
|||
if (mw.config.get('wgPageName').startsWith('Wikiquote:Votes_for_deletion/')) { |
|||
// 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 + '. --[[User:Euphoria|Euphoria]] ([[User talk:Euphoria|talk]]) 07:08, 25 September 2025 (UTC)}}\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; |
|||
} |
|||
} |
|||
}); |
|||
Revision as of 07:08, 25 September 2025
// [[User:YourName/common.js]] helper for VfD closures
mw.loader.using('mediawiki.util', function () {
if (mw.config.get('wgPageName').startsWith('Wikiquote:Votes_for_deletion/')) {
// 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 + '. --[[User:Euphoria|Euphoria]] ([[User talk:Euphoria|talk]]) 07:08, 25 September 2025 (UTC)}}\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;
}
}
});