User:DR/test.js: Difference between revisions
From Test Wiki
Content deleted Content added
No edit summary Tag: Reverted |
restore Tags: Manual revert Reverted |
||
| Line 4: | Line 4: | ||
$('#firstHeading').text('MassDelete'); |
$('#firstHeading').text('MassDelete'); |
||
var |
var pagesTextarea = new OO.ui.MultilineTextInputWidget({ |
||
placeholder: 'Category name (optional)', |
|||
id: 'categoryInput', |
|||
style: 'margin: 10px 0; padding: 5px;' |
|||
}), |
|||
fetchCategoryButton = new OO.ui.ButtonWidget({ |
|||
label: 'Fetch Pages from Category', |
|||
flags: ['progressive'], |
|||
style: 'margin: 10px 0; padding: 5px;' |
|||
}), |
|||
pagesTextarea = new OO.ui.MultilineTextInputWidget({ |
|||
placeholder: 'Enter list of pages (one per line)', |
placeholder: 'Enter list of pages (one per line)', |
||
autosize: true, |
autosize: true, |
||
rows: 10 |
rows: 10 |
||
style: 'margin-top: 10px;' |
|||
}), |
}), |
||
reasonInputField = new OO.ui.TextInputWidget({ |
reasonInputField = new OO.ui.TextInputWidget({ |
||
placeholder: 'Reason for deletion' |
placeholder: 'Reason for deletion' |
||
style: 'margin-top: 10px;' |
|||
}), |
}), |
||
deleteTalkPagesCheckbox = new OO.ui.CheckboxInputWidget({ |
deleteTalkPagesCheckbox = new OO.ui.CheckboxInputWidget({ |
||
| Line 29: | Line 17: | ||
previewButton = new OO.ui.ButtonWidget({ |
previewButton = new OO.ui.ButtonWidget({ |
||
label: 'Preview Deletion', |
label: 'Preview Deletion', |
||
flags: ['primary'] |
flags: ['primary'] |
||
style: 'margin-top: 10px;' |
|||
}), |
}), |
||
startButton = new OO.ui.ButtonWidget({ |
startButton = new OO.ui.ButtonWidget({ |
||
| Line 36: | Line 23: | ||
icon: 'alert', |
icon: 'alert', |
||
flags: ['primary', 'progressive'], |
flags: ['primary', 'progressive'], |
||
disabled: true |
disabled: true |
||
style: 'margin-top: 10px;' |
|||
}), |
}), |
||
cancelButton = new OO.ui.ButtonWidget({ |
cancelButton = new OO.ui.ButtonWidget({ |
||
label: 'Cancel', |
label: 'Cancel', |
||
flags: ['primary', 'destructive'], |
flags: ['primary', 'destructive'], |
||
href: 'https:' + mw.config.get('wgServer') |
href: 'https:' + mw.config.get('wgServer') |
||
style: 'margin-top: 10px;' |
|||
}), |
}), |
||
logContainer = $("<div>").hide(); |
logContainer = $("<div>").hide(); |
||
var labels = { |
var labels = { |
||
categoryLabel: $('<p>').text('Category name (optional)').css('font-weight', 'bold'), |
|||
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'), |
||
| Line 55: | Line 39: | ||
$('#mw-content-text').append( |
$('#mw-content-text').append( |
||
labels.categoryLabel, categoryInputField.$element, fetchCategoryButton.$element, |
|||
labels.pagesLabel, pagesTextarea.$element, |
labels.pagesLabel, pagesTextarea.$element, |
||
labels.reasonLabel, reasonInputField.$element, |
labels.reasonLabel, reasonInputField.$element, |
||
| Line 172: | Line 155: | ||
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"); |
|||
var existingPages = pagesTextarea.getValue().trim(); |
|||
if (existingPages) { |
|||
pagesTextarea.setValue(existingPages + "\n" + pages); |
|||
} else { |
|||
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 226: | Line 167: | ||
}); |
}); |
||
fetchCategoryButton.on('click', fetchCategoryMembers); |
|||
previewButton.on('click', previewDeleting); |
previewButton.on('click', previewDeleting); |
||
startButton.on('click', startDeleting); |
startButton.on('click', startDeleting); |
||