« MediaWiki:Gadget-PaStec.js » : différence entre les versions

Contenu supprimé Contenu ajouté
Gratus (discuter | contributions)
m ajout exception
Le parseur JS de ResourceLoader, jsminplus.php (version 1.4) ne supporte pas le mot clef « continue » comme nom de propriété
Ligne 272 :
PaSdone : "Opération terminée",
 
// Modèles
DeleteTemplate : "{{Suppression}}",
DeleteTemplateNI : "<noinclude>/n{{suppression|note=ok}}/n</noinclude>",
Ligne 413 :
 
/* </source>
 
== Styles CSS ==
 
<source lang=javascript> */
 
Ligne 492 :
 
/* </source>
 
== Chargement et appel des personnalisations ==
 
<source lang=javascript> */
 
Ligne 509 :
 
window.PaStec_Load = function(func){
if(typeof(func) === "function"){
mw.loader.using(["site", "user", "user.groups","mediawiki.util","mediawiki.api"], function(){ $( function(){
PaStec_getCustomParams();
func();
});});
}
};
 
/* </source>
 
== Fonctions utilitaires ==
 
=== Ajax ===
 
<source lang=javascript> */
 
Ligne 587 :
 
/* </source>
 
=== Edition d'une page (1) ===
 
<source lang=javascript> */
 
Ligne 624 :
+ '&rvprop=timestamp|content'
+ '&titles=' + encodeURIComponent(page);
PaStec_ajax.http({
retry:3,
url: request,
onSuccess: PaStec_doEditpage,
onFailure: PaStec_failureAlert,
page: page,
comment: comment,
pattern: pattern,
replace: replace
});
Ligne 669 :
headers['Content-Type'] = 'application/x-www-form-urlencoded';
PaStec_ajax.http({
retry: 3,
url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?format=xml&action=edit&nocreate=1',
method: "POST",
headers: headers,
data: requestEditData,
onFailure: PaStec_failureAlert,
onSuccess:PaStec_confirmExecuted
});
Ligne 683 :
 
/* </source>
 
=== Edition d'une page (2) ===
 
<source lang=javascript> */
 
Ligne 699 :
PaStec_ajax.http({
retry:3,
url: request,
onSuccess: PaStec_doEditpage2,
onFailure: PaStec_failureAlert,
page : page,
comment: comment,
pattern: pattern,
replace: replace
});
Ligne 757 :
headers['Content-Type'] = 'application/x-www-form-urlencoded';
PaStec_ajax.http({
retry:3,
url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?format=xml&action=edit',
method: "POST",
headers: headers,
data: requestEditData,
onFailure: PaStec_failureAlert,
onSuccess:PaStec_confirmExecuted
});
Ligne 771 :
 
/* </source>
 
=== Renommage d'une page ===
 
<source lang=javascript> */
 
Ligne 786 :
PaStec_ajax.http({
retry : 3,
url : request,
onSuccess : PaStec_movePageStep2,
onFailure : PaStec_failureAlert,
title : title,
reason : reason,
newtitle : newtitle
Ligne 812 :
PaStec_ajax.http({
retry : 3,
url : request,
onSuccess : PaStec_confirmExecuted,
onFailure : PaStec_failureAlert,
method : "POST",
headers : headers,
data : requestData
});
Ligne 822 :
 
/* </source>
 
=== Suppression d'une page ===
 
<source lang=javascript> */
 
Ligne 837 :
PaStec_ajax.http({
retry : 3,
url : request,
onSuccess : PaStec_deletePageStep2,
onFailure : PaStec_failureAlert,
title : title,
reason : reason
});
Ligne 860 :
PaStec_ajax.http({
retry : 3,
url : request,
onSuccess : PaStec_confirmExecuted,
onFailure : PaStec_failureAlert,
method : "POST",
headers : headers,
data : requestData
});
Ligne 870 :
 
/* </source>
 
=== Divers ===
 
<source lang=javascript> */
 
Ligne 893 :
window.PaStec_failureAlert = function(xmlreq, data) {
alert(URLFailed.split("$1").join(data.page));
};
 
window.PaStec_confirmExecuted = function(xmlreq, data) {
Ligne 913 :
document.title = "*" + document.title;
}
};
 
// escape regexp :
window.PaStec_RegEscape = function(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
};
 
window.PaStec_Plural = function(Text){
var PluralRegExp = new RegExp("\\{\\{PLURAL[^\\}]+\\}\\}", "ig");
var Matches = Text.match(PluralRegExp);
if(Matches!=null){
Ligne 939 :
}
return Text;
};
 
String.prototype.PaStec_ucFirst = function () {
return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
};
 
String.prototype.PaStec_lcFirst = function () {
return this.substr(0,1).toLowerCase() + this.substr(1,this.length);
};
 
//Fonctions de manipulation de pages
Ligne 954 :
var nsnb = mw.config.get('wgNamespaceNumber');
return ((nsnb-1)===0 ? "" : mw.config.get( 'wgFormattedNamespaces' )[(nsnb-1)] + ":" ) + mw.config.get( 'wgTitle' ).replace(/\/Suppression$/, "");
};
 
window.PaStec_getDiscussionPageName = function(){
return mw.config.get( 'wgPageName' ).replace(/\/Suppression$/, "");
};
 
window.PaStec_UserIsIP = function(user) {
Ligne 966 :
else if (regexpIP6.exec(user)) return "V6";
else return false;
};
 
window.PaStec_createUserLink = function(user) {
Ligne 972 :
if (PaStec_UserIsIP(user)) prefix = "Special:Contributions/";
return PaStec_createLink({page:(prefix+user), text:user});
};
 
window.PaStec_createProjectLink = function(project){
var prefix = mw.config.get( 'wgFormattedNamespaces' )[103] + ":";
return PaStec_createLink({page:(prefix+project), text:project});
};
 
window.PaStec_getNamespaceInfoFromPage = function(Page, ToReturn){
if(!ToReturn || !Page) ToReturn = false;
Ligne 1 002 :
if(ToReturn==="PageName") return PageName;
return NamespaceNumber;
};
 
window.PaStec_createLink = function(Args){
Ligne 1 013 :
+ '>'+(Args.text ? Args.text : Args.page )+'</a>';
return Link;
};
 
window.PaStec_getDateFromTimestamp = function(ts){
Ligne 1 019 :
ts = ts.split("-");
return (ts[2] + "/" + ts[1] + "/" + ts[0]);
};
 
/* </source>
 
== Lien pour les non-sysop pour demander une SI ==
 
<source lang=javascript> */
 
Ligne 1 060 :
Span.appendChild(select);
H.appendChild(Span);
};
 
window.PaStec_deletepageAction = function(motif) {
Ligne 1 068 :
}
PaStec_editPage(
page,
"<",
PaStec_Texts.AskSIpage_Template.split("$reason").join(motif).split("$page").join(page)+"\n",
PaStec_Texts.AskSIpageComment.split("$reason").join(motif).split("$page").join(page)
);
PaStec_editPage(
PaStec_Texts.SIPageName,
">",
"\n" + PaStec_Texts.AskSImain_Template.split("$reason").join(motif).split("$page").join(page),
PaStec_Texts.AskSImainComment.split("$reason").join(motif).split("$page").join(page)
);
alert (PaStec_Texts.AskSICheckContribs);
};
 
/* </source>
 
== Liens pour consulter les PaS ou initier la PaS de la page courante ==
 
<source lang=javascript> */
 
Ligne 1 095 :
var text = "#"+PastDate.getDate()+"_"+ months[PastDate.getMonth()];
return text;
};
 
window.PaStec_LeftPanelLinks = function() {
var a = document.getElementById("p-navigation");
if(a){
Ligne 1 107 :
var NSnumber = mw.config.get( 'wgNamespaceNumber');
if(NSnumber % 2 == 0) NSnumber = (NSnumber+1);
initURL = initURL.split("$1").join(encodeURIComponent(mw.config.get('wgFormattedNamespaces')[NSnumber]+":"+Title));
b[0].innerHTML = b[0].innerHTML
+ '<li><span id="n-pas7" title="'+PaStec_Texts.PaStodo1Title+'">'
Ligne 1 119 :
+ '<li><span id="n-pasi" title="'+PaStec_Texts.InitPaSTitle+'">'
+ '<a href="//fr.wikipedia.org/w/index.php?title='+initURL+'">'+PaStec_Texts.InitPaSText+'</a>'
+ '</span></li>';
}
}
}
};
 
Ligne 1 128 :
 
/* </source>
 
== Menu de la sous-page <code>/Suppression</code> ==
 
=== Fonctions annexes ===
 
==== Création d'un nouvel onglet ====
 
<source lang=javascript> */
 
Ligne 1 140 :
var MainFieldSet = document.getElementById("PaStec_MainContainer");
var Buttons = document.getElementById("PaStec_PanelButtons");
if(!MainFieldSet || !Buttons) return false;
var button = PaStec_CreateInput("PaStec_"+type+"Input", PaStec_Texts[type], "button", false, false, PaStec_ToggleMenuPanel);
button.id = "PaStec_"+type+"Input";
button.className = "PaStec_Input";
button.style.background = PaStec_ButtonColors[type];
if(mainbutton){
button.style.fontWeight = "bold";
Ligne 1 153 :
fieldset.id = "PaStec_"+type+"Fieldset";
fieldset.className = "PaStec_Fieldset";
var legend = document.createElement('legend');
legend.innerHTML = PaStec_Texts[(type+"Legend")];
fieldset.appendChild(legend);
Ligne 1 173 :
MainFieldSet.appendChild(fieldset);
return PanelContent;
};
 
/* </source>
 
==== Sélection d'un onglet ====
 
<source lang=javascript> */
 
Ligne 1 196 :
}
}
};
 
/* </source>
 
==== Gestion de la hauteur des onglets ====
 
<source lang=javascript> */
 
Ligne 1 224 :
if(PaStec_SetMenuPanelHeightsTimeout) clearTimeout(PaStec_SetMenuPanelHeightsTimeout);
PaStec_SetMenuPanelHeightsTimeout = setTimeout("PaStec_SetMenuPanelHeights()", 500);
};
 
/* </source>
 
==== Redimensionnement du menu ====
 
<source lang=javascript> */
 
Ligne 1 236 :
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
return is_ie;
};
 
window.PaStec_GetMousePosition = function(event){
Ligne 1 247 :
}
return {"X": Mouse_X, "Y": Mouse_Y};
} ;
 
window.PaStec_GetScreenHeight = function(){
Ligne 1 259 :
}
return ScreenHeight;
};
 
 
Ligne 1 293 :
Element.style.height = NewHeight + 'px';
}
}
};
document.body.onmouseup = function(event) {
document.body.onmousemove = null;
document.body.onmouseup = null;
$(document.body).removeClass("MouseMoveFunctionRunning");
};
};
anchorNode.style.display = "";
};
/* </source>
 
==== Affichage/Masquage du menu ====
 
<source lang=javascript> */
 
window.PaStec_ShowHideMenu = function(show){
var Menu = document.getElementById("PaStec_MainFieldset");
if(!Menu) return;
Ligne 1 317 :
$(Menu).addClass("MenuHidden");
}
};
 
/* </source>
 
==== Récupération de la liste des auteurs ====
 
<source lang=javascript> */
 
Ligne 1 331 :
if (!rvcontinue) rvcontinue = "";
var page = PaStec_getPageName();
var APIlimit = ( PaStec_UserCanDo("apihighlimit") ? 5000 : 500);
var request = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?format=xml&action=query'
+ '&prop=revisions&rvprop=user|timestamp'
Ligne 1 339 :
+ '&continue=';
PaStec_ajax.http({retry:3,url: request, onSuccess:PaStec_getArticleAuthorsRunning, CallBack:callback, onFailure: PaStec_failureAlert});
};
 
window.PaStec_getArticleAuthorsRunning = function(Req, data) {
Ligne 1 351 :
else PaStec_Creator = user;
if(typeof PaStec_Authors[user] === "undefined"){
PaStec_Authors[user] = {};
PaStec_Authors[user].last = PaStec_getDateFromTimestamp(rev.getAttribute("timestamp"));
PaStec_Authors[user].editcount = 1;
Ligne 1 371 :
PaStec_getArticleBotAuthors(authorlist, data.CallBack);
}
};
 
window.PaStec_getArticleBotAuthors = function(authorlist, callback){
Ligne 1 391 :
'&list=users&usprop=groups&ususers='+thisauthorlist.join("|");
PaStec_ajax.http({retry:3,url: URL, onSuccess:PaStec_getArticleBotAuthorsRunning, CallBack:callback, furtherauthors:newauthorlist, onFailure: PaStec_failureAlert});
};
 
window.PaStec_getArticleBotAuthorsRunning = function(Req, data){
Ligne 1 404 :
}
PaStec_getArticleBotAuthors(data.furtherauthors, data.CallBack);
};
 
window.PaStec_getArticleMaybeBotAuthors_Remaining = 0;
Ligne 1 421 :
PaStec_ajax.http({retry:3,url: request, onSuccess:PaStec_getArticleMaybeBotAuthorsRunning, CallBack:callback, user:user, onFailure: PaStec_failureAlert});
}
};
 
window.PaStec_getArticleMaybeBotAuthorsRunning = function(Req, data){
Ligne 1 432 :
PaStec_getArticleMaybeBotAuthors_Remaining--;
if(PaStec_getArticleMaybeBotAuthors_Remaining === 0) data.CallBack();
};
 
window.PaStec_getAuthorType = function(user){
Ligne 1 442 :
if(types.length >0) return " "+types.join(" ");
return "";
};
 
/* </source>
 
==== Récupération de la liste des projets ====
 
<source lang=javascript> */
 
Ligne 1 463 :
+ '&continue=';
PaStec_ajax.http({retry:3,url: request, onSuccess:PaStec_getArticleProjectsRunning, CallBack:callback, onFailure: PaStec_failureAlert});
};
 
window.PaStec_getArticleProjectsRunning = function(Req, data){
Ligne 1 470 :
for(var a=0,l=Templates.length;a<l;a++){
var title = Templates[a].getAttribute("title");
if(title.match(/Modèle:Portail /) !== null){
title = title.replace(/Modèle:Portail /, "").PaStec_ucFirst();
if(PaStec_Projects.indexOf(title) === -1) PaStec_Projects.push(title);
Ligne 1 480 :
PaStec_getArticleProjects(tlcontinue, data.callback);
} else {
data.CallBack();
}
};
 
/* </source>
 
==== Récupération des pages liées et des pages de la catégorie ====
 
<source lang=javascript> */
 
Ligne 1 500 :
}
return NSList;
};
 
window.PaStec_GetWhatlinkshere_Addpage = function(title, type){
if(PaStec_WhatlinkshereLists[type].indexOf(title)===-1) PaStec_WhatlinkshereLists[type].push(title);
};
 
window.PaStec_ClearDiff = function(type){
Ligne 1 521 :
return Diff;
}
};
 
window.PaStec_GetWhatlinkshere = function(Page, Continues, redirectrequest){
Ligne 1 551 :
einamespace : (Array.isArray(PaStec_WLH_EIDefaultNamespaces) ? PaStec_WLH_EIDefaultNamespaces : Namespaces),
eititle : Page
};
if(isfile){
queryopt.iulimit = APILimit;
Ligne 1 566 :
if(Continues && Continues.iucontinue) queryopt.iucontinue = Continues.iucontinue;
if(Continues && Continues.cmcontinue) queryopt.cmcontinue = Continues.cmcontinue;
queryopt.["continue"] = "";
var api = new mw.Api();
api.get(queryopt).then( function(data) {
Ligne 1 581 :
PaStec_GetWhatlinkshere(thispagetitle, false, true);
}else{
PaStec_GetWhatlinkshere_Addpage(thispagetitle, "links");
}
}
Ligne 1 590 :
for(var a=0,l=EI;a<l;a++){
var thispagetitle = AllEI[a].title;
PaStec_GetWhatlinkshere_Addpage(thispagetitle, "embeddedin");
}
}
Ligne 1 598 :
for(var a=0,l=IU;a<l;a++){
var thispagetitle = AllIU[a].title;
PaStec_GetWhatlinkshere_Addpage(thispagetitle, "imageusage");
}
}
Ligne 1 606 :
for(var a=0,l=CM;a<l;a++){
var thispagetitle = AllCM[a].title;
PaStec_GetWhatlinkshere_Addpage(thispagetitle, "categorymembers");
}
}
var RequeteContinue = {};
var ContinueNode = data.["continue"];
var MustContinue = false;
if(ContinueNode){
Ligne 1 636 :
}
});
};
 
window.PaStec_CreateWhatlinkshereList = function(ListsToCreate, Container){
Ligne 1 650 :
Container.appendChild(FORM);
}
};
 
window.PaStec_UpdateWhatlinkshereLists = function(){
Ligne 1 661 :
for(a=0,l=Nodes.length;a<l;a++){
var FORM = Nodes[a];
var UL = FORM.getElementsByTagName('ul')[0];
if(!UL){
UL = document.createElement('ul');
Ligne 1 694 :
newli.appendChild(input);
}
}
}
}
};
 
/* </source>
 
==== Suggestions ====
 
<source lang=javascript> */
 
Ligne 1 722 :
return false;
};
return Link;
};
 
window.PaStec_Suggestions_Zindex = 5000;
Ligne 1 734 :
if(!id) return false;
return parseInt(id.replace(/[^0-9]/g, ""));
};
window.PaStec_getSuggestions = function(input){
var ID = PaStec_getSuggestionID(input);
Ligne 1 757 :
if(type === "user") PaStec_getUserSuggestions(ID);
if(type === "project") PaStec_getProjectSuggestions(ID);
};
 
window.PaStec_showSuggestions = function(titles, Index){
Ligne 1 776 :
if(titles.length < TailleListe) TailleListe = titles.length;
var listh = TailleListe * 20 ;
List.style.height = listh + "px" ;
List.size = TailleListe;
while(List.firstChild) List.removeChild(List.firstChild);
for(var i = 0,l=titles.length;i<l;i++){
Ligne 1 784 :
opt.onclick = function(){
PaStec_SuggestionReplace(PaStec_getSuggestionID(this.parentNode));
};
opt.value = titles[i];
List.appendChild(opt) ;
Ligne 1 792 :
var NewValue = PaStec_formatTextValue(Text.value);
if(titles[0].indexOf(NewValue) !== 0) PaStec_getSuggestions(Text);
};
 
window.PaStec_KeypressedOnSuggestionList = function(e){
Ligne 1 798 :
if (e.keyCode != 13) return;
PaStec_SuggestionReplace(PaStec_getSuggestionID(this));
};
 
window.PaStec_SuggestionReplace = function(Index){
Ligne 1 821 :
text = text.PaStec_ucFirst();
return text;
};
 
window.PaStec_getPageSuggestions = function(Index){
Ligne 1 839 :
apfilterredir : 'nonredirects',
apprefix : text,
"continue" : ""
};
var api = new mw.Api();
api.get(queryopt).then( function(data) {
Ligne 1 852 :
PaStec_showSuggestions(titles, Index);
});
} ;
 
window.PaStec_getUserSuggestions = function(Index){
Ligne 1 870 :
auexcludegroup : 'bot',
auprefix : text,
"continue" : ""
};
var api = new mw.Api();
api.get(queryopt).then( function(data) {
Ligne 1 883 :
PaStec_showSuggestions(titles, Index);
});
};
 
window.PaStec_getProjectSuggestions = function(Index){
Ligne 1 902 :
apnamespace : 103,
apprefix : text,
"continue" : ""
};
var api = new mw.Api();
api.get(queryopt).then( function(data) {
Ligne 1 918 :
PaStec_showSuggestions(titles, Index);
});
} ;
 
/* </source>
 
==== Autres ====
 
<source lang=javascript> */
 
Ligne 1 962 :
};
return Link;
};
 
window.PaStec_DisableForms = function(Container){
Ligne 1 970 :
Forms[a].onsubmit = function(){ return false; };
}
};
 
/* </source>
 
=== Création du menu ===
 
==== Création des onglets ====
 
Ligne 1 993 :
"PaSDelete" : function(){
var PanelContent = PaStec_CreateNewMenuPanel("PaSDelete", true);
if(!PanelContent) return;
var ReasonForm = document.createElement('form');
var ReasonInput = PaStec_CreateInput("reason", PaStec_Texts.PaSDeleteReasonDef, "text");
Ligne 2 116 :
OL.appendChild(Page1LI);
OL.appendChild(Page2LI);
var MoreLi = document.createElement('li');
MoreLi.appendChild(PaStec_CreateAddItemLink("pages"));
OL.appendChild(MoreLi);
Ligne 2 260 :
var foundbot = false;
for(var user in PaStec_Authors){
var UserLi = document.createElement('li');
var userinfos = PaStec_Authors[user];
$(UserLi).addClass("author");
Ligne 2 269 :
var typetext = PaStec_getAuthorType(user);
var editcount = userinfos.editcount;
var LabelText = PaStec_Texts.NbEdits ;
LabelText = LabelText.split("$user").join(PaStec_createUserLink(user) + typetext);
LabelText = LabelText.split("$creator").join(PaStec_Texts.Creator);
LabelText = LabelText.split("$edits").join(editcount);
LabelText = LabelText.split("$last").join(PaStec_Authors[user].last);
LabelText = PaStec_Plural(LabelText);
var Checked = true;
Ligne 2 280 :
UserLi.appendChild(PaStec_CreateInput("user", user, "checkbox", Checked, Disabled));
UserLi.appendChild(document.createTextNode(" "));
UserLi.appendChild(PaStec_CreateLabel("user", LabelText));
UserListOL.appendChild(UserLi);
}
var MoreLi = document.createElement('li');
MoreLi.appendChild(PaStec_CreateAddItemLink("user"));
UserListOL.appendChild(MoreLi);
Ligne 2 341 :
for(var a=0,l=Projects.length;a<l;a++){
var Project = Projects[a];
var ProjectLi = document.createElement('li');
ProjectLi.appendChild(PaStec_CreateInput("project", Project, "checkbox", true));
ProjectLi.appendChild(document.createTextNode(" "));
ProjectLi.appendChild(PaStec_CreateLabel("project", PaStec_createProjectLink(Project)));
ProjectListOL.appendChild(ProjectLi);
}
var MoreLi = document.createElement('li');
MoreLi.appendChild(PaStec_CreateAddItemLink("project"));
ProjectListOL.appendChild(MoreLi);
Ligne 2 389 :
 
/* </source>
 
==== Mise en place du menu ====
 
Ligne 2 408 :
var ShowHideLinks = ""
+ PaStec_createLink({url:"javascript:PaStec_ShowHideMenu(true);", text:PaStec_Texts.PaSLegendShow,classes:["showmenu"]})
+ PaStec_createLink({url:"javascript:PaStec_ShowHideMenu(false);",text:PaStec_Texts.PaSLegendHide,classes:["hidemenu"]});
var docLink = PaStec_createLink({url:PaStec_Texts.DocURL,text:PaStec_Texts.DocText});
Legend.innerHTML = PaStec_Texts.PaSLegend.split("$1").join(PaStec_Texts.ScriptName).split("$2").join(docLink).split("$3").join(ShowHideLinks);
Ligne 2 420 :
TalkHeader.appendChild(Fieldset);
for(var func in PaStec_CreateMenuPanelFunctions){
if(typeof(PaStec_CreateMenuPanelFunctions[func]) === "function" && ( func === "PaSWelcome" || PaStec_Enabled[func] === true || PaStec_DebugMode === true) )
PaStec_CreateMenuPanelFunctions[func]();
}
Ligne 2 432 :
true
);
PaStec_DisableForms();
PaStec_ToggleMenuPanel();
PaStec_SetMenuPanelHeightsTimeout = setTimeout("PaStec_SetMenuPanelHeights()", 500);
PaStec_GetWhatlinkshere();
if(PaStec_AutoHideMenu) PaStec_ShowHideMenu(false);
}
};
 
PaStec_Load(PaStec_CreatePaSMenu);
Ligne 2 444 :
 
/* </source>
 
=== Validation du menu ===
 
Ligne 2 473 :
{ name : "reason", mandatory : 1 },
{ name : "pages", mandatory : 2 },
{ name : "makerequest", mandatory : 0 },
],
"PaSMove" : [
Ligne 2 534 :
if(searchedname) return null;
return Params;
};
 
window.PaStec_StringEscape = function(str){
return "'" + (""+str).replace(/\\/g, '\\\\').replace(/[\\]+n/g, '\\n').replace(/'/g, "\\'") + "'";
};
 
window.PaStec_ObjectToString = function(obj){
Ligne 2 551 :
str += items.join(",")+"}";
return str;
};
 
window.PaStec_fillControl = function(type, text){
var Control = document.getElementById("PaStec_Panel"+type+"Control");
if(Control) Control.innerHTML = (text || "");
};
 
window.PaStec_ValidateDone = function(type, text){
PaStec_fillControl(type, (text +"<br><small>"+ PaStec_Texts.running +"</small><br><small>"+ PaStec_Texts.maybeerror+"</small>"));
};
 
window.PaStec_GetCheckedParamsInMenuPanel = function(type){
Ligne 2 569 :
for(var a=0,l=MandForm.length;a<l;a++) $(MandForm).removeClass("mandatory");
var NeededParams = PaStec_ValidateNeededParams[type];
var ParamsFound = PaStec_GetParamsInMenuPanel(Menu);
// alert( type + "\n" + PaStec_ObjectToString(ParamsFound) );
var errorsfound = false;
Ligne 2 583 :
if(!paramfound) error = true;
if(mandatory > 1 && typeof(paramfound) === "string") error = true;
else if(mandatory > 1 && typeof(paramfound) === "object" && paramfound.length < 2) error = true;
else if(mandatory === 1 && typeof(paramfound) === "string" && paramfound === "") error = true;
if(error){
errorsfound = true;
Ligne 2 591 :
while(Form && Form.tagName && Form.tagName.toLowerCase() !== "form") Form = Form.parentNode;
if(Form && !$(Form).hasClass("mandatory")) $(Form).addClass("mandatory");
}
}
if(errorsfound){
Ligne 2 598 :
}
return ParamsFound;
};
 
window.PaStec_RunningRequests = null;
Ligne 2 612 :
PaStec_ValidateFunctions[type](type, Params);
}
};
 
/* </source>
 
==== Fonctions de requêtes principales ====
 
Ligne 2 623 :
 
/* </source>
 
===== Clôture en suppression =====
 
<source lang=javascript> */
 
"PaSDelete" : function(type, Params){ // ["reason", "action", "redirects"]
PaStec_preventEditConflict(function() {
var page = PaStec_getPageName();
Ligne 2 642 :
if(typeof(redirects)==="string") redirects = [ redirects ];
for(var a=0,l=redirects.length;a<l;a++){
PaStec_deletePage(redirects[a], PaStec_Texts.DelRedirComment.split("$1").join(delpage));
}
}
Ligne 2 648 :
}else if(Params.action === "AskSI"){
PaStec_editPage(
page,
PaStec_DeleteTemplateRegExp,
PaStec_Texts.AskSIpage_Template.split("$reason").join("[["+delpage+"]]"),
PaStec_Texts.AskSIpageComment.split("$reason").join("[["+delpage+"]]")
);
PaStec_editPage(
PaStec_Texts.SIPageName,
">",
"\n"+PaStec_Texts.PASaskSITemplate.split("$page").join(page).split("$delpage").join(delpage),
PaStec_Texts.PASaskSIComment.split("$page").join(page).split("$delpage").join(delpage)
Ligne 2 667 :
 
/* </source>
 
===== Clôture suite à SI =====
 
Ligne 2 681 :
PaStec_Texts.SIPaSTemplate+"\n\n"+PaStec_Texts.SIPaSTarget,
PaStec_Texts.SIPaSComment.split("$1").join(mw.config.get('wgPageName'))
);
PaStec_updatePaSMainPage(PaStec_Texts.SIMainType);
if(Params.action === "DelRedir" && Params.redirects){
if(typeof(redirects)==="string") redirects = [ redirects ];
for(var a=0,l=redirects.length;a<l;a++){
PaStec_deletePage(redirects[a], PaStec_Texts.DelRedirComment.split("$1").join(mw.config.get('wgPageName')));
}
}
Ligne 2 703 :
 
/* </source>
 
===== Déwikification =====
 
Ligne 2 713 :
 
/* </source>
 
===== Clôture en conservation =====
 
Ligne 2 722 :
PaStec_editPage(
PaStec_getPageName(),
PaStec_DeleteTemplateRegExp,
"",
PaStec_Texts.PASkeepPageComment.split("$page").join(PaStec_getPageName()).split("$delpage").join(mw.config.get('wgPageName'))
Ligne 2 739 :
 
/* </source>
 
===== Clôture en fusion =====
 
Ligne 2 759 :
var bandeau = PaStec_Texts.MergeTemplate.split("$1").join(firstpages.join("]], [[")).split("$2").join(lastpage).split("$reason").join(Params.reason);
PaStec_editPage(
mw.config.get('wgPageName'),
PaStec_Texts.MergePaSTarget,
bandeau+"\n\n"+PaStec_Texts.MergePaSTarget,
PaStec_Texts.MergePaSComment.split("$1").join(delpage)
);
Ligne 2 767 :
if(Params.makerequest) {
PaStec_editPage(
PaStec_Texts.DoMergeMainPageName,
">",
"\n"+PaStec_Texts.DoMergeMainPageTemplate.split("$1").join(firstpages.join("]], [[:")).split("$2").join(lastpage).split("$3").join(delpage),
PaStec_Texts.DoMergeMainPageComment.split("$1").join(firstpages.join("]], [[")).split("$2").join(lastpage).split("$3").join(delpage)
);
var thispage, otherpages, MergeComment;
Ligne 2 778 :
otherpages = ArrDeleteEl(allpages, a);
if(a === 0){
MergeComment = PaStec_Texts.DoMergePage1Comment.split("$1").join(otherpages.join("]], [[")).split("$2").join(delpage);
PaStec_editPage(
thispage,
PaStec_DeleteTemplateRegExp,
MergeTemplate,
MergeComment
Ligne 2 788 :
MergeComment = PaStec_Texts.DoMergePagesComment.split("$1").join(otherpages.join("]], [[")).split("$2").join(delpage);
PaStec_editPage(
thispage,
"<",
MergeTemplate + "\n",
MergeComment
);
Ligne 2 803 :
 
/* </source>
 
===== Clôture en renommage =====
 
Ligne 2 814 :
PaStec_editPage(
PaStec_getPageName(),
PaStec_DeleteTemplateRegExp,
"",
PaStec_Texts.MovePageComment.split("$1").join(PaStec_getPageName()).split("$2").join(mw.config.get('wgPageName'))
Ligne 2 829 :
'#REDIRECTION [['+Params.newtitle+']]',
PaStec_Texts.RedirectCorrComment.split("$1").join(Params.newtitle).split("$2").join(mw.config.get('wgPageName'))
);
}
}
Ligne 2 836 :
PaStec_editPage(
PaStec_Texts.MovePageName,
">",
"\n"+PaStec_Texts.MoveMainTemplate.split("$old").join(PaStec_getPageName()).split("$new").join(Params.newtitle).split("$delpage").join(mw.config.get('wgPageName')),
PaStec_Texts.MoveMainPageComment
Ligne 2 848 :
 
/* </source>
 
===== Clôture en redirection =====
 
Ligne 2 874 :
'#REDIRECTION [['+Params.target+']]',
PaStec_Texts.RedirectCorrComment.split("$1").join(Params.target).split("$2").join(mw.config.get('wgPageName'))
);
}
}
Ligne 2 885 :
 
/* </source>
 
===== Initialisation d'une PaS =====
 
Ligne 2 902 :
PaStec_Texts.PaSMainPageName,
target,
target+"\n"+PaStec_Texts.KirMainTemplate.split("$page").join(page).split("$definition").join(Params.definition),
PaStec_Texts.KirMainComment.split("$page").join(page).split("$delpage").join(mw.config.get('wgPageName'))
);
PaStec_editPage2(
page,
PaStec_AdmitTemplateRegExp,
"",
PaStec_Texts.KirPageComment
);
Ligne 2 916 :
 
/* </source>
 
===== Avertissement utilisateur =====
 
Ligne 2 937 :
 
/* </source>
 
===== Avertissement projet =====
 
Ligne 3 005 :
 
/* </source>
 
===== Message =====
 
Ligne 3 015 :
for(var a=0,l=target.length;a<l;a++){
PaStec_editPage(
target[a],
">",
"\n"+PaStec_Texts.MessageTemplate.split("$1").join(Params.message),
PaStec_Texts.MessageComment
Ligne 3 026 :
 
/* </source>
 
==== Fonctions de requêtes secondaires ====
 
Ligne 3 061 :
if(typeof(Callbacks.onredirect)==="function") Callbacks.onredirect(redirecttarget);
}
return;
}
if(typeof(Callbacks.onrealpage)==="function") return Callbacks.onrealpage();
Ligne 3 069 :
 
/* </source>
 
===== Mise à jour de la PaS =====
 
Ligne 3 085 :
 
/* </source>
 
===== Mise à jour de la page centrale ([[Wikipédia:Page à supprimer]]) =====
 
Ligne 3 093 :
PaStec_editPage(
PaStec_Texts.PaSMainPageName,
new RegExp(PaStec_Texts.PASstoreRegExp.split("$escpage$").join(PaStec_RegEscape(PaStec_getPageName()))),
PaStec_Texts.PASstoreTemplate.split("$type").join(type),
PaStec_Texts.PASstoreComment.split("$page").join(PaStec_getPageName()).split("$type").join(type).split("$delpage").join(mw.config.get('wgPageName'))
Ligne 3 100 :
 
/* </source>
 
===== Fonctions pour la déwikification =====
 
Ligne 3 114 :
var Fieldset = document.getElementById("PaStec_"+type+"Fieldset");
if(!Fieldset) return;
var OldLink = document.getElementById("currentdiff_"+type);
if(OldLink) $(OldLink).addClass("modified");
var Form = $.makeArray( $(Fieldset).find("form.PaStec_Whatlinkshere_links"))[0];
Ligne 3 128 :
}
}
};
 
window.PaStec_CheckThisPage = function(Link){
Ligne 3 138 :
var type = parent.id.split("PaStec_").join("").split("Fieldset").join("");
PaStec_GetThisDiff(Link, type, Page);
};
 
window.PaStec_getParentForm = function(el){
Ligne 3 144 :
while(parent && parent.tagName.toLowerCase() !== "form"){ parent = parent.parentNode; }
return parent;
};
 
window.PaStec_getElementWithId = function(elementId, elementTagName, elementParentNode){
if(!elementParentNode) elementParentNode = document.body;
if (elementParentNode.getElementById) return elementParentNode.getElementById(elementId);
var TheElement = false;
var Elements = elementParentNode.getElementsByTagName(elementTagName);
Ligne 3 160 :
}
}
elementcount++;
}
if(!TheElement) return null;
return TheElement;
};
 
window.PaStec_CanValidate = false;
Ligne 3 216 :
var DiffDiv = document.createElement('div');
DiffDiv.innerHTML = '<span class="error">'+PaStec_Texts.running+'</span>';
Diff.appendChild(DiffDiv);
var Params = PaStec_GetParamsInMenuPanel(PaStec_getParentForm(TextArea));
var ParamsInURL = [];
Ligne 3 227 :
url : PaStec_getParentForm(TextArea).getAttribute("action")+"&wpDiff=1",
method : "POST",
headers : {'Content-Type':'application/x-www-form-urlencoded'},
data : ParamsInURL,
complete : function(diffReq){
Ligne 3 243 :
Diff.appendChild(SummaryDiv);
DiffDiv = document.createElement('div');
Diff.appendChild(DiffDiv);
var Content = PaStec_getElementWithId("mw-content-text", "div", DiffElement);
DiffDiv.innerHTML = Content.innerHTML;
DiffElement.parentNode.removeChild(DiffElement);
var TitleInput = document.createElement('input')
Ligne 3 259 :
});
}});
};
 
window.PaStec_ValidateThisDiff = function(type){
Ligne 3 289 :
PaStec_actionsLeft++;
PaStec_ajax.http({
retry:3,
url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?format=xml&action=edit',
method: "POST",
headers: headers,
data: requestEditData,
onFailure: PaStec_failureAlert,
onSuccess:function(Req, data){
PaStec_confirmExecuted(Req, data);
Ligne 3 301 :
});
PaStec_ValidateDone(type, PaStec_Texts.UnwikifyHeader.split("$1").join(Params.wpTitle));
};
 
window.PaStec_TextUwikify = function(Datas, type){
Ligne 3 330 :
var FileTag = "__FILENAME__";
var REGEXP = PaStec_CreateFileRegExp(linktocheck);
var matches = text.match(REGEXP);
if(matches !== null){
for(var m=0,mlen=matches.length;m<mlen;m++){
Ligne 3 337 :
// --------------------------------------------------------------------------------------- Images dans infobox ou autre modèle
var REGEXPTemplate = new RegExp("=( )*"+FileTag+"( )*[^\\|\\}\n]*[\n\\|\\}]{1}", "g");
var matchesT = text.match(REGEXPTemplate);
if(matchesT !== null){
filedelete = true;
Ligne 3 381 :
}else{
if(galstart && !galend) textisgallery = true;
if(!galstart && galend) textisgallery = false;
continue;
}
Ligne 3 392 :
// --------------------------------------------------------------------------------------- Images "thumb"
var REGEXPThumbStart = new RegExp("\\[\\["+FileTag,"g");
var matchesTh = text.match(REGEXPThumbStart);
if(matchesTh !== null){
filedelete = true;
Ligne 3 408 :
thispart = thispart.substring(NextClosure+2);
NextClosure = thispart.indexOf("]]");
NextLinkStart = thispart.indexOf("[[");
}
if(NextLinkStart === -1 || NextLinkStart > NextClosure) thispart = thispart.substring(NextClosure+2);
Ligne 3 414 :
thispart = FileTag + thispart;
thispart = thispart.split(FileTag+"\n").join("");
thispart = thispart.split(FileTag).join("");
textsplit[a] = thispart;
}
Ligne 3 447 :
Title = (PaStec_CaseSensitive ? PaStec_CreateRegExp(Title) : "("+PaStec_CreateRegExp(Title.PaStec_ucFirst())+"|"+PaStec_CreateRegExp(Title.PaStec_lcFirst())+")" );
return (new RegExp("\\[\\[( |_)*" + NS + Title + "( |_)*(\\|[^\\]]*)?\\]\\]", "g"));
};
 
window.PaStec_CreateFileRegExp = function(File){
Ligne 3 456 :
Title = (PaStec_CaseSensitive ? PaStec_CreateRegExp(Title) : "("+PaStec_CreateRegExp(Title.PaStec_ucFirst())+"|"+PaStec_CreateRegExp(Title.PaStec_lcFirst())+")" );
return (new RegExp(NSString+Title, "g"));
};
 
window.PaStec_CreateCatRegExp = function(Cat){
Ligne 3 464 :
Title = (PaStec_CaseSensitive ? PaStec_CreateRegExp(Title) : PaStec_CreateRegExp(Title.PaStec_ucFirst())+"|"+PaStec_CreateRegExp(Title.PaStec_lcFirst()) );
return (new RegExp("(\\s?)\\[\\[( |_)*("+NS+")( |_)*:( |_)*(" + Title + ")( |_)*(\\|[^\\]]*)?\\]\\]", "g"));
};
 
window.PaStec_CreateRegExp = function(Page){
return Page.replace(/([\\\^\$\*\+\?\.\|\{\}\[\]\(\)])/g, "\\$1");
};
 
/* </source> */