User:DR/test.js: Difference between revisions
From Test Wiki
Content deleted Content added
upd Tag: Reverted |
No edit summary Tag: Reverted |
||
| Line 14: | Line 14: | ||
deleteTalkPagesCheckbox = new OO.ui.CheckboxInputWidget({ |
deleteTalkPagesCheckbox = new OO.ui.CheckboxInputWidget({ |
||
selected: false |
selected: false |
||
}), |
|||
categoryInputField = new OO.ui.TextInputWidget({ |
|||
placeholder: 'Category name (optional)', |
|||
id: 'categoryInput' |
|||
}), |
|||
fetchCategoryButton = new OO.ui.ButtonWidget({ |
|||
label: 'Fetch Pages from Category', |
|||
flags: ['progressive'] |
|||
}), |
}), |
||
previewButton = new OO.ui.ButtonWidget({ |
previewButton = new OO.ui.ButtonWidget({ |
||
| Line 35: | Line 43: | ||
pagesLabel: $('<p>').text('Pages to Delete:').css('font-weight', 'bold'), |
pagesLabel: $('<p>').text('Pages to Delete:').css('font-weight', 'bold'), |
||
reasonLabel: $('<p>').text('Reason:').css('font-weight', 'bold'), |
reasonLabel: $('<p>').text('Reason:').css('font-weight', 'bold'), |
||
deleteTalkPagesLabel: $('<p>').text('Delete associated talk pages').css('font-weight', 'bold') |
deleteTalkPagesLabel: $('<p>').text('Delete associated talk pages').css('font-weight', 'bold'), |
||
categoryLabel: $('<p>').text('Category name (optional)').css('font-weight', 'bold') |
|||
}; |
}; |
||
| Line 42: | Line 51: | ||
labels.reasonLabel, reasonInputField.$element, |
labels.reasonLabel, reasonInputField.$element, |
||
labels.deleteTalkPagesLabel, deleteTalkPagesCheckbox.$element, |
labels.deleteTalkPagesLabel, deleteTalkPagesCheckbox.$element, |
||
labels.categoryLabel, categoryInputField.$element, |
|||
fetchCategoryButton.$element, |
|||
'<br/>', |
'<br/>', |
||
previewButton.$element, |
previewButton.$element, |
||
| Line 155: | Line 166: | ||
processNextPage(); |
processNextPage(); |
||
} |
|||
function fetchCategoryMembers() { |
|||
var category = categoryInputField.getValue().trim(); |
|||
if (category === "") { |
|||
showAlert("Please enter a category name."); |
|||
return; |
|||
} |
|||
var params = { |
|||
action: 'query', |
|||
list: 'categorymembers', |
|||
cmtitle: 'Category:' + category, |
|||
cmlimit: 'max', |
|||
format: 'json' |
|||
}; |
|||
$.ajax({ |
|||
url: mw.util.wikiScript('api'), |
|||
data: params, |
|||
dataType: 'json', |
|||
success: function(data) { |
|||
if (data.query && data.query.categorymembers.length > 0) { |
|||
var pages = data.query.categorymembers.map(function(member) { |
|||
return member.title; |
|||
}).join("\n"); |
|||
pagesTextarea.setValue(pages); |
|||
showAlert("Fetched " + data.query.categorymembers.length + " pages from category: " + category); |
|||
} else { |
|||
showAlert("No pages found in the category: " + category); |
|||
} |
|||
}, |
|||
error: function(xhr, status, error) { |
|||
showAlert("Error fetching category members: " + error); |
|||
} |
|||
}); |
|||
} |
} |
||
| Line 167: | Line 215: | ||
}); |
}); |
||
fetchCategoryButton.on('click', fetchCategoryMembers); |
|||
previewButton.on('click', previewDeleting); |
previewButton.on('click', previewDeleting); |
||
startButton.on('click', startDeleting); |
startButton.on('click', startDeleting); |
||