User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
fix |
Cleanup Tag: Blanked |
||
| (61 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/')) { |
|||
function addClosureButton(label, action) { |
|||
mw.util.addPortletLink( |
|||
'p-cactions', |
|||
'#', |
|||
label, |
|||
'ca-close-' + action.replace(/\s+/g, '-'), |
|||
'Close this VfD as ' + action |
|||
).addEventListener('click', function (e) { |
|||
e.preventDefault(); |
|||
redirectToEdit(action); |
|||
}); |
|||
} |
|||
// Add buttons |
|||
addClosureButton('Close as delete', 'delete'); |
|||
addClosureButton('Close as keep', 'keep'); |
|||
addClosureButton('Close as no consensus', 'no consensus'); |
|||
function redirectToEdit(action) { |
|||
var page = mw.config.get('wgPageName'); |
|||
var topText = '{{subst:vt|' + action + '. --~~~~}}\n\n'; |
|||
var bottomText = '\n\n{{subst:vb}}'; |
|||
var summary = 'Closed as ' + action; |
|||
// Build edit URL with prefill |
|||
var editUrl = mw.util.getUrl(page, { |
|||
action: 'edit', |
|||
prefill: topText + bottomText, |
|||
summary: summary |
|||
}); |
|||
// Redirect to edit page |
|||
window.location.href = editUrl; |
|||
} |
|||
} |
|||
}); |
|||
//</nowiki> |
|||