User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
fix |
Cleanup Tag: Blanked |
||
| (65 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
// [[User:Euphoria/common.js]] helper for VfD closures |
|||
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 + '. --[[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; |
|||
} |
|||
} |
|||
}); |
|||