//<source lang=javascript>//<pre>//<nowiki>
// --------------------------------------------------------------------------------------------
// Textes
window.ForcePurge_Text_Purge = "Purger";
window.ForcePurge_Text_Done = "Purge terminée";
window.ForcePurge_Text_AlertEditTryAgain = "Problème !\n\nRéessayer ?";
// --------------------------------------------------------------------------------------------
// Ajout du lien "Purger"
window.ForcePurge_AddLink = function(){
var OngletsCactions = document.getElementById('p-cactions');
if(OngletsCactions){
var CactionsUl = OngletsCactions.getElementsByTagName('ul');
CactionsUl.innerHTML += '<li><a href="javascript:ForcePurge_CheckCategory();">'+ForcePurge_Text_Purge+'</a></li>';
$(OngletsCactions).removeClass("emptyPortlet");
}
}
// --------------------------------------------------------------------------------------------
// Listage des pages
window.ForcePurge_CheckCategory = function(NewCategory, Continue){
if(!NewCategory) NewCategory = new Array();
if(!Continue) Continue='';
var APILimit = ( ((mw.config.get('wgUserGroups').indexOf("sysop")!=-1)||(mw.config.get('wgUserGroups').indexOf("bot")!=-1)) ? 4999 : 499);
var NouvelleRequete = new XMLHttpRequest()
var AdresseRequete = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml&action=query&list=categorymembers&cmlimit='+APILimit+'&cmtitle=' + encodeURIComponent(mw.config.get('wgPageName')) + Continue;
NouvelleRequete.open("GET", AdresseRequete, true);
NouvelleRequete.onreadystatechange = function() {
if(NouvelleRequete.readyState == 4 && NouvelleRequete.status == 200) {
var ObjetXML = NouvelleRequete.responseXML;
var Pages = ObjetXML.getElementsByTagName('cm');
for(a=0;a<Pages.length;a++){
var PageTitle = Pages.getAttribute('title');
var PageNS = Pages.getAttribute('ns');
if(PageNS!="14") NewCategory.push(PageTitle);
}
var AutreRequeteNecessaire = ObjetXML.getElementsByTagName('query-continue');
if(AutreRequeteNecessaire){
var AutreRequeteContinue = '&cmcontinue=' + encodeURIComponent(AutreRequeteNecessaire.getElementsByTagName('categorymembers').getAttribute('cmcontinue'));
ForcePurge_CheckCategory(NewCategory, AutreRequeteContinue);
}else{
ForcePurge_Purge(NewCategory, 0);
}
}
}
NouvelleRequete.send(null);
}
// --------------------------------------------------------------------------------------------
// Purge
window.ForcePurge_Purge = function(CategoryMembers, Position){
var Page = CategoryMembers;
if(!Page){
alert(ForcePurge_Text_Done);
window.location.reload();
}
var url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(Page) + '&action=edit§ion=0';
var NouvelleRequete = new XMLHttpRequest();
NouvelleRequete.open("GET", url, true);
NouvelleRequete.onreadystatechange = function() {
if(NouvelleRequete.readyState != 4) return;
while(document.body.firstChild){ RenommageCategorie_DeleteElement(document.body.firstChild);}
var ElementTraitement = document.createElement('div');
document.body.appendChild(ElementTraitement);
ElementTraitement.innerHTML = NouvelleRequete.responseText;
var action = document.getElementById("editform").action;
var boundary = '--------123xyz';
var data = '';
data += '--' + boundary + '\nContent-Disposition: form-data; name="wpTextbox1"\n\n' + document.getElementById("wpTextbox1").value + '\n'
data += '--' + boundary + '\nContent-Disposition: form-data; name="wpSection"\n\n' + document.editform.wpSection.value + '\n'
data += '--' + boundary + '\nContent-Disposition: form-data; name="wpSummary"\n\n' + document.getElementById("wpSummary").value + '\n'
data += '--' + boundary + '\nContent-Disposition: form-data; name="wpMinoredit"\n\n' + document.editform.wpMinoredit.value + '\n'
data += '--' + boundary + '\nContent-Disposition: form-data; name="wpStarttime"\n\n' + document.editform.wpStarttime.value + '\n'
data += '--' + boundary + '\nContent-Disposition: form-data; name="wpEdittime"\n\n' + document.editform.wpEdittime.value + '\n'
data += '--' + boundary + '\nContent-Disposition: form-data; name="wpEditToken"\n\n' + document.editform.wpEditToken.value + '\n'
var ajaxSubmit = new XMLHttpRequest();
ajaxSubmit.open('POST', action, true);
ajaxSubmit.setRequestHeader('Content-Type', 'multipart/form-data; boundary='+boundary);
ajaxSubmit.onreadystatechange = function(){
if (ajaxSubmit.readyState != 4) return;
while(document.body.firstChild){RenommageCategorie_DeleteElement(document.body.firstChild);}
var ElementTraitementBis = document.createElement('div');
document.body.appendChild(ElementTraitementBis);
ElementTraitementBis.innerHTML = ajaxSubmit.responseText;
if(!document.getElementById("editform")){
ForcePurge_Purge(CategoryMembers, (Position+1));
}else{
var DeuxiemeEssai = confirm(ForcePurge_Text_AlertEditTryAgain);
if(DeuxiemeEssai) ForcePurge_Purge(CategoryMembers, Position);
else window.location.reload();
}
}
ajaxSubmit.send(data + '--' + boundary);
}
NouvelleRequete.send(null);
}
// --------------------------------------------------------------------------------------------
// Lancement
if(mw.config.get('wgNamespaceNumber')==14){
$(ForcePurge_AddLink);
}
//</nowiki></pre></source>