User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
fix |
fix |
||
| Line 81: | Line 81: | ||
const link = $(heading).find('a').first(); |
const link = $(heading).find('a').first(); |
||
if (!link.length) { |
if (!link.length) { |
||
mw.notify('Cannot find target page link!', {title: 'VfDcloser', type: 'error', timeout: |
mw.notify('Cannot find target page link!', {title: 'VfDcloser', type: 'error', timeout: 3000}); |
||
setTimeout(() => location.reload(), 3000); |
|||
return; |
return; |
||
} |
} |
||
const targetPage = link.attr('title') || link.text().trim(); |
const targetPage = link.attr('title') || link.text().trim(); |
||
if (!targetPage) { |
if (!targetPage) { |
||
mw.notify('Cannot determine target page title!', {title: 'VfDcloser', type: 'error', timeout: |
mw.notify('Cannot determine target page title!', {title: 'VfDcloser', type: 'error', timeout: 3000}); |
||
setTimeout(() => location.reload(), 3000); |
|||
return; |
return; |
||
} |
} |
||
| Line 96: | Line 99: | ||
const talkPage = 'Talk:' + targetPage; |
const talkPage = 'Talk:' + targetPage; |
||
// Check if talk page exists |
// Check if talk page exists |
||
api.get({action: 'query', titles: talkPage, format: 'json'}).done(data => { |
api.get({action: 'query', titles: talkPage, format: 'json'}).done(data => { |
||
const talkPages = data.query.pages; |
const talkPages = data.query.pages; |
||
| Line 104: | Line 107: | ||
api.postWithToken('csrf', {action: 'delete', title: talkPage, reason: 'Parent page deleted via VfD'}) |
api.postWithToken('csrf', {action: 'delete', title: talkPage, reason: 'Parent page deleted via VfD'}) |
||
.done(() => { |
.done(() => { |
||
mw.notify('Discussion closed. Page and talk page deleted.', {title: 'VfDcloser', type: 'success', timeout: |
mw.notify('Discussion closed. Page and talk page deleted.', {title: 'VfDcloser', type: 'success', timeout: 3000}); |
||
location.reload(); |
setTimeout(() => location.reload(), 3000); |
||
}).fail(err => mw.notify('Error deleting talk page: ' + JSON.stringify(err), {title: 'VfDcloser', type: 'error', timeout: 5000})); |
}).fail(err => mw.notify('Error deleting talk page: ' + JSON.stringify(err), {title: 'VfDcloser', type: 'error', timeout: 5000})); |
||
} else { |
} else { |
||
mw.notify('Discussion closed. Page deleted.', {title: 'VfDcloser', type: 'success', timeout: |
mw.notify('Discussion closed. Page deleted.', {title: 'VfDcloser', type: 'success', timeout: 3000}); |
||
location.reload(); |
setTimeout(() => location.reload(), 3000); |
||
} |
} |
||
}); |
}); |
||
| Line 161: | Line 164: | ||
minor: true |
minor: true |
||
}).done(() => { |
}).done(() => { |
||
mw.notify('Discussion closed. Page and talk page updated.', {title: 'VfDcloser', type: 'success', timeout: |
mw.notify('Discussion closed. Page and talk page updated.', {title: 'VfDcloser', type: 'success', timeout: 3000}); |
||
location.reload(); |
setTimeout(() => location.reload(), 3000); |
||
}).fail(err => mw.notify('Error editing talk page: ' + JSON.stringify(err), {title: 'VfDcloser', type: 'error', timeout: 5000})); |
}).fail(err => mw.notify('Error editing talk page: ' + JSON.stringify(err), {title: 'VfDcloser', type: 'error', timeout: 5000})); |
||
}); |
}); |
||