User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
Tooltip added |
mw.notify |
||
Line 3:
const pagePrefix = 'User:Euphoria/TestVfD';
// Only run on relevant pages in view mode
if (!mw.config.get('wgPageName').startsWith(pagePrefix) || mw.config.get('wgAction') !== 'view') return;
Line 9 ⟶ 10:
const heading = this;
// Skip
if ($(heading).closest('.vfd').length) return;
// Skip
if (!$(heading).find('a').length) return;
Line 27 ⟶ 28:
const btn = document.createElement('button');
btn.textContent = actionObj.name.charAt(0).toUpperCase(); // D/K/N
//
btn.style.width = '16px';
btn.style.height = '16px';
Line 50 ⟶ 51:
if (!confirm('Are you sure you want to close as ' + actionObj.name + '?')) return;
const api = new mw.Api();
//
api.get({
action: 'query',
Line 72 ⟶ 71:
const discussionNewContent = topText + content.trim() + bottomText;
//
api.postWithToken('csrf', {
action: 'edit',
Line 82 ⟶ 81:
const link = $(heading).find('a').first();
if (!link.length) {
location.reload();
return;
Line 89 ⟶ 88:
if (actionObj.name === 'delete') {
// Delete target article and talk page
api.postWithToken('csrf', {action: 'delete', title: targetPage, reason: '[[' + mw.config.get('wgPageName') + ']]'})
.done(()
}).fail(err => mw.notify('Error deleting page: ' + JSON.stringify(err), {title:
} else {
// Keep / No consensus: update target and talk page
api.get({
action: 'query',
Line 154 ⟶ 147:
minor: true
}).done(() => {
location.reload();
}).fail(err =>
});
}).fail(err =>
});
}
}).fail(err =>
});
});
| |||