Utilisateur:Dr Brains/LiveRC/HotCatsMulti.js
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./*
--------------------------------------------------------------------------------------
---------LLLL---------III--------------------------RRRRRRRRRR--------CCCCC------------
---------LLLL---------III--------------------------RRRRRRRRRRRR----CCCCCCCCC----------
---------LLLL--------------------------------------RRR------RRR---CCC-----CCC---------
---------LLLL---------III--VV-----VV--EEEEEEEEE----RRR------RRR--CCC------------------
---------LLLL---------III---VV---VV---EEE----------RRRRRRRRRRR---CCC------------------
---------LLLL---------III---VV---VV---EEEEEE-------RRRRRRRRRR----CCC------------------
---------LLLL---------III----VV-VV----EEEEEE-------RRR-----RRR----CCC-----CCC---------
---------LLLLLLLLLLL--III----VVVVV----EEE----------RRR------RRR----CCCCCCCCC----------
---------LLLLLLLLLLL--III-----VVV-----EEEEEEEEE----RRR-------RRR-----CCCCC------------
--------------------------------------------------------------------------------------
'''Extension de LiveRC'''
// Permet d'améliorer la prévisualisation avec les fonctions de HotCatsMulti
* Licence : ...?
* Documentation :
* Auteur : [[:fr:User:Dr Brains]]
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
<syntaxhighlight lang=javascript> */
if (typeof(lrcHooks)!="undefined") { // DÉBUT IF
///////////////////////// VARIABLES ////////////////////////////////////////////////////////
//// PARAMÈTRES PERSONNALISABLES ////
var lrcHotCatsVariables = {
HC_MinoreditState : "1", // Modification mineure ( -1 = défaut ; 0 = jamais ; 1 = toujours )
HC_WatchthisState : "nochange", // Suivre la page modifiée ( "watch", "unwatch", "preferences", "nochange" )
HC_docURL : "//fr.wikipedia.org/wiki/Projet:JavaScript/Notices/HotCatsMulti#Fonctionnement", // Lien vers la documentation
HC_NoCatTemplate : "À catégoriser",
HC_suggestion_delay : 200, // Délai avant les suggestions, en ms
HC_list_size : 10, // Taille de la liste déroulante (en items)
HC_list_items : 50, // Nombre de catégories suggérées lors de la recherche (maximum autorisé : 4999 pour les sysop et les bots, 499 pour les autres utilisateurs)
HC_list_down : false, // Permet d'afficher la liste de suggestion vers le bas
HC_autocommit : true, // Permet d'enregistrer automatiquement la modification
HC_AutoMulti : false, // Activation automatique du mode "multi"
HC_ShowLegend : false, // Afficher de la légende
HC_ShowInline : false, // Afficher sur une seule ligne
HC_SkipRecap : false // Ne pas afficher le récapitulatif
}
//// TEXTES ////
lrcTexts["HC_MultiLinkText"] = "(±)";
lrcTexts["HC_MultiLinkTitle"] = "Modifier plusieurs catégories";
lrcTexts["HC_MultiInputOK"] = "Valider";
lrcTexts["HC_MultiInputCancel"] = "Annuler";
lrcTexts["HC_Minoredit"] = "Édition mineure";
lrcTexts["HC_Watchthis"] = "Suivre cette page";
lrcTexts["HC_RadioNoChange"] = "Pas de changement";
lrcTexts["HC_RadioDefault"] = "Préférences";
lrcTexts["HC_RadioYes"] = "Oui";
lrcTexts["HC_RadioNo"] = "Non";
lrcTexts["HC_LabelText"] = "Légende";
lrcTexts["HC_LabelTitle"] = "Voir la page d’aide (nouvelle fenêtre)";
lrcTexts["HC_DefaultSortText"] = "(D)";
lrcTexts["HC_DefaultSortTitle"] = "Ajouter/modifier/supprimer la clef de tri principale";
lrcTexts["HC_RemoveLinkText"] = "(–)";
lrcTexts["HC_RemoveLinkTitle"] = "Supprimer la catégorie";
lrcTexts["HC_RemoveConfirm"] = "Voulez-vous vraiment supprimer la catégorie";
lrcTexts["HC_ModifyLinkText"] = "(±)";
lrcTexts["HC_ModifyLinkTitle"] = "Modifier la catégorie";
lrcTexts["HC_AddLinkText"] = "(+)";
lrcTexts["HC_AddLinkTitle"] = "Ajouter une catégorie";
lrcTexts["HC_ParentTitle"] = "Suggérer les catégories-mères";
lrcTexts["HC_ParentText"] = "↑";
lrcTexts["HC_DaughterTitle"] = "Suggérer les catégories-filles";
lrcTexts["HC_DaughterText"] = "↓";
lrcTexts["HC_InputOK"] = "OK";
lrcTexts["HC_InputCancel"] = "Annuler";
lrcTexts["HC_RecapTitle"] = 'Récapitulatif :';
lrcTexts["HC_RecapRemove"] = 'Catégories à supprimer';
lrcTexts["HC_RecapModify"] = 'Catégories à modifier';
lrcTexts["HC_RecapAdd"] = 'Catégories à ajouter';
lrcTexts["HC_RecapSort"] = 'Clef de tri globale';
lrcTexts["HC_AlertProblem1"] = "Impossible de trouver la catégorie « $1 » - elle est peut-être incluse via un modèle.";
lrcTexts["HC_AlertProblem2"] = "La catégorie « $1 » est déjà présente.";
lrcTexts["HC_AlertProblem3"] = "Plusieurs occurrences de la catégorie « $1 » trouvées.";
UnTranslatedTexts["HC_ResumeScript"] = "[[Projet:JavaScript/Notices/HotCatsMulti|HotCatsMulti]] : ";
// Paramètres de personnalisation
lrcParamDesc["DesclrcHotCatsVariables"] = "Paramètres de l’extension HotCats";
lrcParamDesc["DesclrcHotCatsVariables_short"] = "HotCats";
lrcParamDesc["DescHC_MinoreditState"] = "Modification mineure";
lrcParamDesc["DescHC_WatchthisState"] = "Suivre la page modifiée";
lrcParamDesc["DescHC_suggestion_delay"] = "Délai avant les suggestions, en ms";
lrcParamDesc["DescHC_list_size"] = "Nombre d’items dans la liste déroulante";
lrcParamDesc["DescHC_list_items"] = "Nombre de catégories suggérées lors de la recherche";
lrcParamDesc["DescHC_docURL"] = "Lien vers la documentation";
lrcParamDesc["DescHC_list_down"] = "Permet d’afficher la liste de suggestion vers le bas";
lrcParamDesc["DescHC_autocommit"] = "Permet d’enregistrer automatiquement la modification";
lrcParamDesc["DescHC_AutoMulti"] = "Activation automatique du mode \"multi\"";
lrcParamDesc["DescHC_ShowLegend"] = "Afficher de la légende";
lrcParamDesc["DescHC_ShowInline"] = "Afficher sur une seule ligne";
lrcParamDesc["DescHC_SkipRecap"] = "Ne pas demander de confirmation";
lrcParamDesc["DescHC_MultiLinkText"] = "[HotCatsMulti] Texte du lien pour modifier plusieurs catégories";
lrcParamDesc["DescHC_MultiLinkTitle"] = "[HotCatsMulti] Infobulle du lien pour modifier plusieurs catégories";
lrcParamDesc["DescHC_MultiInputOK"] = "[HotCatsMulti] Texte du bouton de validation";
lrcParamDesc["DescHC_MultiInputCancel"] = "[HotCatsMulti] Texte du bouton d’annulation";
lrcParamDesc["DescHC_Minoredit"] = "[HotCatsMulti] Infobulle pour boutons \"Édition mineure\"";
lrcParamDesc["DescHC_Watchthis"] = "[HotCatsMulti] Infobulle pour boutons \"Suivre cette page\"";
lrcParamDesc["DescHC_RadioNoChange"] = "[HotCatsMulti] Infobulle pour boutons : Pas de changement";
lrcParamDesc["DescHC_RadioDefault"] = "[HotCatsMulti] Infobulle pour boutons : Préférences";
lrcParamDesc["DescHC_RadioYes"] = "[HotCatsMulti] Infobulle pour boutons : Oui";
lrcParamDesc["DescHC_RadioNo"] = "[HotCatsMulti] Infobulle pour boutons : Non";
lrcParamDesc["DescHC_LabelText"] = "[HotCatsMulti] Titre de la légende";
lrcParamDesc["DescHC_LabelTitle"] = "[HotCatsMulti] Infobulle du lien vers la page de documentation";
lrcParamDesc["DescHC_DefaultSortText"] = "[HotCatsMulti] Texte du lien pour ajouter/modifier/supprimer la clef de tri principale";
lrcParamDesc["DescHC_DefaultSortTitle"] = "[HotCatsMulti] Infobulle du lien pour ajouter/modifier/supprimer la clef de tri principale";
lrcParamDesc["DescHC_RemoveLinkText"] = "[HotCatsMulti] Texte du lien pour supprimer la catégorie";
lrcParamDesc["DescHC_RemoveLinkTitle"] = "[HotCatsMulti] Infobulle du lien pour supprimer la catégorie";
lrcParamDesc["DescHC_RemoveConfirm"] = "[HotCatsMulti] Confirmation de suppression de catégorie";
lrcParamDesc["DescHC_ModifyLinkText"] = "[HotCatsMulti] Texte du lien pour modifier la catégorie";
lrcParamDesc["DescHC_ModifyLinkTitle"] = "[HotCatsMulti] Infobulle du lien pour modifier la catégorie";
lrcParamDesc["DescHC_AddLinkText"] = "[HotCatsMulti] Texte du lien pour ajouter une catégorie";
lrcParamDesc["DescHC_AddLinkTitle"] = "[HotCatsMulti] Infobulle du lien pour ajouter une catégorie";
lrcParamDesc["DescHC_ParentTitle"] = "[HotCatsMulti] Infobulle du bouton pour suggérer les catégories-mères";
lrcParamDesc["DescHC_ParentText"] = "[HotCatsMulti] Texte du bouton pour suggérer les catégories-mères";
lrcParamDesc["DescHC_DaughterTitle"] = "[HotCatsMulti] Infobulle du bouton pour suggérer les catégories-filles";
lrcParamDesc["DescHC_DaughterText"] = "[HotCatsMulti] Texte du bouton pour suggérer les catégories-filles";
lrcParamDesc["DescHC_InputOK"] = "[HotCatsMulti] Texte du bouton de validation";
lrcParamDesc["DescHC_InputCancel"] = "[HotCatsMulti] Texte du bouton d’annulation";
lrcParamDesc["DescHC_RecapTitle"] = "[HotCatsMulti] Titre du récapitulatif";
lrcParamDesc["DescHC_RecapRemove"] = "[HotCatsMulti] Section \"Catégories à supprimer\" du récapitulatif";
lrcParamDesc["DescHC_RecapModify"] = "[HotCatsMulti] Section \"Catégories à modifier\" du récapitulatif";
lrcParamDesc["DescHC_RecapAdd"] = "[HotCatsMulti] Section \"Catégories à ajouter\" du récapitulatif";
lrcParamDesc["DescHC_RecapSort"] = "[HotCatsMulti] Section \"Clef de tri globale\" du récapitulatif";
lrcParamDesc["DescHC_AlertProblem1"] = "[HotCatsMulti] Alerte \"Impossible de trouver la catégorie « $1 » - elle est peut-être incluse via un modèle.\"";
lrcParamDesc["DescHC_AlertProblem2"] = "[HotCatsMulti] Alerte \"La catégorie « $1 » est déjà présente.\"";
lrcParamDesc["DescHC_AlertProblem3"] = "[HotCatsMulti] Alerte \"Plusieurs occurrences de la catégorie « $1 » trouvées.\"";
lrcParamDesc["DescHC_ResumeScript"] = "[HotCatsMulti] HotCats : Début du résumé de modif";
lrcParamDesc["DescHC_NoCatTemplate"] = "[HotCatsMulti] Modèle pour pages sans catégorie";
//// VARIABLES NON PERSONNALISABLES ////
LiveRC_Config["HotCats"] = new Array();
LiveRC_Config["HotCats"]["Matrix"] = {
Span : new Array(),
CatLink : new Array(),
CatLinkIsRed : new Array(),
RemoveLink : new Array(),
ModifyLink : new Array(),
Form : new Array(),
Text : new Array(),
List : new Array(),
Exist : new Array(),
CatName : new Array(),
Sort : new Array()
};
LiveRC_Config["HotCats"]["Multi_Edit"] = false ;
LiveRC_Config["HotCats"]["suggest_running"] = 0 ;
LiveRC_Config["HotCats"]["running"] = 0 ;
LiveRC_Config["HotCats"]["last_v"] = "" ;
LiveRC_Config["HotCats"]["last_key"] = "";
LiveRC_Config["HotCats"]["OldDefaultSort"] = "";
LiveRC_Config["HotCats"]["OldPageContent"] = false;
LiveRC_Config["HotCats"]["Form_Index"] = 1000;
LiveRC_Config["HotCats"]["NewCatsIndex"] = 2000;
LiveRC_Config["HotCats"]["CurrentPage"] = false;
LiveRC_Config["HotCats"]["WatchStatus"] = false;
LiveRC_Config["HotCats"]["MinorEditStatus"] = false;
LiveRC_Config["HotCats"]["IsEditMode"] = false;
LiveRC_Config["HotCats"]["CaseSensitive"] = false;
LiveRC_Config["HotCats"]["HiddenCatsLinkID"] = "mw-hidden-cats-link"; // ID du lien pour les catégories cachées
LiveRC_Config["HotCats"]["ChangesToDo"] = {
RemovedCategories : false,
ModifiedCategories_from : false,
ModifiedCategories_to : false,
AddedCategories : false,
DefaultSort : false
};
// Messages système
LiveRC_addNeededMessages("pagecategorieslink");
LiveRC_addNeededMessages("categories");
LiveRC_addNeededMessages("pagecategories");
LiveRC_addNeededMessages("red-link-title");
// Mots magiques
LiveRC_addNeededMagicWord("defaultsort")
var lrcHotCatsVariables_Custom = new Array();
var Custom_lrcHotCatsVariables = new Array();
function LiveRC_getHotCatsVariables(id){
if(typeof(lrcHotCatsVariables_Custom[id])!="undefined") return lrcHotCatsVariables_Custom[id];
if(typeof(Custom_lrcHotCatsVariables[id])!="undefined") return Custom_lrcHotCatsVariables[id];
return lrcHotCatsVariables[id];
}
///////////////////////// LANCEMENT ////////////////////////////////////////////////////////
mw.loader.load('//fr.wikipedia.org/w/index.php?title=MediaWiki:Gadget-LiveRC.js/Extensions/HotCatsMulti.css&action=raw&ctype=text/css', 'text/css');
function lrcRunHotCatsMulti(data){
LiveRC_Config["HotCats"]["IsEditMode"] = false;
LiveRC_Config["HotCats"]["Multi_Edit"] = false
LiveRC_Config["HotCats"]["WatchStatus"] = LiveRC_getHotCatsVariables("HC_WatchthisState");
LiveRC_Config["HotCats"]["MinorEditStatus"] = LiveRC_getHotCatsVariables("HC_MinoreditState");
var Preview = document.getElementById("livePreview");
if(!Preview || !data) return;
LiveRC_Config["HotCats"]["CurrentPage"] = data.page
lrcHotCats_getOldPageContent(LiveRC_Config["HotCats"]["CurrentPage"], true);
for(var El in LiveRC_Config["HotCats"]["Matrix"]){
while(LiveRC_Config["HotCats"]["Matrix"][El].length!=0) LiveRC_Config["HotCats"]["Matrix"][El].pop();
}
for(var El in LiveRC_Config["HotCats"]["ChangesToDo"]){
LiveRC_Config["HotCats"]["ChangesToDo"][El] = false;
}
var catlinks = getElementWithId("catlinks", "div", Preview);
if(!catlinks){
catlinks = document.createElement("div");
catlinks.id = "catlinks";
catlinks.className = "catlinks";
catlinks = Preview.appendChild(catlinks);
}else{
$(catlinks).removeClass("catlinks-allhidden");
}
if(mw.config.get('wgAction')=="edit") Custom_lrcHotCatsVariables["list_down"] = true;
var catline = getElementWithId('mw-normal-catlinks', "div", catlinks);
if ( !catline || catline == null || typeof catline == 'undefined' ){
catline = catlinks.insertBefore(document.createElement("div"), catlinks.firstChild);
catline.id = "mw-normal-catlinks";
}
lrcHotCats_append_firstlink(catline);
lrcHotCats_modify_existing(catline);
lrcHotCats_append_add_span(catline);
lrcHotCats_append_multiedit_span(catline);
}
function lrcHotCats_AvoidEditMode(){
LiveRC_Config["HotCats"]["IsEditMode"] = false;
}
function lrcHotCats_getCatCase(){
if( LiveRC_Config["MediawikiNamespaces"]["14"]["case"] == "case-sensitive") LiveRC_Config["HotCats"]["CaseSensitive"] = true;
}
////////////////////////////////////////// HOOKS
LiveRC_AddHook("AfterPreviewArticle", lrcRunHotCatsMulti);
LiveRC_AddHook("AfterPreviewDiff", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewHistory", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewContribs", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewDeletedContribs", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewLog", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewFilter", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewMove", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewProtect", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewDelete", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewBlock", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewRevisiondelete", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewWhatlinkshere", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewFeedback", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterPreviewStabilization", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterOptions", lrcHotCats_getCatCase);
function defineCustomHotCatsVariable(textcode, HotCatsVariable){
if(typeof(lrcHotCatsVariables[textcode])!=="undefined") Custom_lrcHotCatsVariables[textcode] = HotCatsVariable;
}
LiveRC_AddHook("AfterFillParamPanel", function(){
LiveRC_ManageParams_Fill(lrcHotCatsVariables, "lrcHotCatsVariables", "defineCustomHotCatsVariable");
});
function lrcHotCats_TransformOptions(){
var InputsToTransform = new Array();
var WLOptions = [
{value:"nochange",text:lrcMakeText("HC_RadioNoChange")},
{value:"preferences",text:lrcMakeText("HC_RadioDefault")},
{value:"unwatch",text:lrcMakeText("HC_RadioNo")},
{value:"watch",text:lrcMakeText("HC_RadioYes")}
];
InputsToTransform["HC_WatchthisState"] = WLOptions;
var MEOptions = [
{value:"-1",text:lrcMakeText("HC_RadioDefault")},
{value:"0",text:lrcMakeText("HC_RadioNo")},
{value:"1",text:lrcMakeText("HC_RadioYes")}
];
InputsToTransform["HC_MinoreditState"] = MEOptions;
LiveRC_ManageParams_CheckInputsToTransform(InputsToTransform)
}
LiveRC_AddHook("AfterCreateParamPanel", lrcHotCats_TransformOptions);
//<syntaxhighlight lang=javascript><pre><nowiki>
// RÉCUPÉRATION CLEF DE TRI GLOBALE
function lrcHotCats_defaultSort_getOld(ID){
var Page = LiveRC_Config["HotCats"]["OldPageContent"];
for(var a=0;a<LiveRC_Config["MediawikiMagicwords"]["defaultsort"].length;a++){
var DefaultSortWord = LiveRC_Config["MediawikiMagicwords"]["defaultsort"][a];
if(Page.indexOf('{{'+DefaultSortWord)!=-1){
var AvantCle = Page.substring(0,Page.indexOf('{{'+DefaultSortWord));
var Cle = Page.split(AvantCle).join('');
Cle = Cle.substring(0,Cle.indexOf("}"));
Cle = Cle.substring((Cle.indexOf(":")+1),Cle.length);
LiveRC_Config["HotCats"]["OldDefaultSort"] = Cle;
var OldDefaultSpan = document.getElementById(ID);
if(OldDefaultSpan) OldDefaultSpan.innerHTML = Cle;
return;
}
}
}
// RÉCUPÉRATION CLEF DE TRI PARTICULIÈRE
function lrcHotCats_defaultSort_getOneOld(TargetCategory){
var Page = LiveRC_Config["HotCats"]["OldPageContent"];
var Key = "";
var CurrentKey = "";
var REGEXP = lrcHotCats_CreateRegExp(TargetCategory);
var matches = Page.match(REGEXP);
if (matches != null && matches.length == 1){
CurrentKey = Page.replace(REGEXP, "DEFAULTKEYstart$2DEFAULTKEYend");
if((CurrentKey.indexOf("DEFAULTKEYstart")!=-1)&&(CurrentKey.indexOf("DEFAULTKEYend")!=-1)){
var Before = CurrentKey.split("DEFAULTKEYstart")[0]+"DEFAULTKEYstart";
var After = "DEFAULTKEYend"+CurrentKey.split("DEFAULTKEYend")[1];
CurrentKey = CurrentKey.split(Before).join("");
CurrentKey = CurrentKey.split(After).join("");
if(CurrentKey.indexOf('|')!=-1) Key = CurrentKey;
}
}
return Key;
}
// RÉCUPÉRATION DU CONTENU ACTUEL DE LA PAGE PREVISUALISEE (asynchrone ou synchrone)
function lrcHotCats_getOldPageContent(Page, Mode){
var URL = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + encodeURIComponent(Page) + '&action=raw';
wpajax.http({ url: URL,
async : Mode,
onSuccess: lrcHotCats_UpdateOldPageContent
});
}
function lrcHotCats_UpdateOldPageContent(Req, data){
try{
LiveRC_Config["HotCats"]["OldPageContent"] = Req.responseText;
}catch(e){
LiveRC_Config["HotCats"]["OldPageContent"] = "";
}
lrcHotCats_defaultSort_getOld("OldDefaultSortSpan");
return LiveRC_Config["HotCats"]["OldPageContent"];
}
///////////////////////// TRANSFORMATIONS ////////////////////////////////////////////////////////
// CRÉATION DU LIEN "CATÉGORIES"
function lrcHotCats_append_firstlink( catline, plural) {
if (!catline.firstChild ){
var a = document.createElement('a');
a.href = mw.config.get('wgServer')+mw.config.get('wgArticlePath').split('$1').join(lrcGetMediawikiMessage("pagecategorieslink"));
a.title = lrcGetMediawikiMessage("categories", true);
a.appendChild(document.createTextNode(lrcHotCats_PLURAL(lrcGetMediawikiMessage("pagecategories", true), plural)));
catline.appendChild(a);
catline.appendChild(document.createTextNode(' : '));
}else{
catline.firstChild.title = lrcGetMediawikiMessage("categories", true);
}
}
// MODIFICATION DE LA BARRE DE CATÉGORIES
function lrcHotCats_modify_existing( catline) {
var ul = catline.getElementsByTagName ( "ul" )[0];
if(!ul){ // ( Mediawiki < 1.18 )
var spans = catline.getElementsByTagName ( "span" );
for ( var i = 0, l= spans.length; i < l ; i++ ) {
lrcHotCats_modify_span ( spans[i], i ) ;
}
return;
}
var lis = ul.getElementsByTagName ( "li" ) ;
for ( var i = 0, l= lis.length; i < l ; i++ ) {
var li = lis[i];
var cat_link = li.getElementsByTagName('a')[0];
var span = document.createElement('span');
li.appendChild(span);
span.appendChild(cat_link);
lrcHotCats_modify_span ( span, i ) ;
}
}
// AJOUT DES LIENS (–) ET (±)
function lrcHotCats_modify_span ( span, i ) {
var cat_link = span.getElementsByTagName('a')[0];
if(!cat_link) return;
cat_link.id = "CatLink_"+i;
var cat_title = cat_link.title;
if(!cat_title) return;
cat_title = cat_title.split(lrcGetNamespaceName(14)+':').join('');
cat_title = cat_title.replace(lrcGetMediawikiMessage("red-link-title").split('$1').join(''), "").split(" (live)").join("");
var sep1 = document.createTextNode ( " " ) ;
span.id = "lrcHotCats_Span_" + i ;
var a1 = document.createTextNode ( "(–)" ) ;
var remove_link = document.createElement ( "a" ) ;
var remove_id = "lrcHotCats_remove_" + i ;
remove_link.id = remove_id;
remove_link.href = "javascript:lrcHotCats_remove(\"" + cat_title + "\","+i+");" ;
remove_link.title = lrcMakeText("HC_RemoveLinkTitle")+" « "+cat_title+" »";
remove_link.appendChild ( a1 ) ;
span.appendChild ( sep1 ) ;
span.appendChild ( remove_link ) ;
var mod_id = "lrcHotCats_modify_" + i ;
var sep2 = document.createTextNode ( " " ) ;
var a2 = document.createTextNode ( "(±)" ) ;
var modify_link = document.createElement ( "a" ) ;
modify_link.id = mod_id ;
modify_link.href = "javascript:lrcHotCats_modify(\""+cat_title+"\"," + i + ");" ;
modify_link.title = lrcMakeText("HC_ModifyLinkTitle")+" « "+cat_title+" »";
modify_link.appendChild ( a2 ) ;
span.appendChild ( sep2 ) ;
span.appendChild ( modify_link ) ;
LiveRC_Config["HotCats"]["Matrix"].Span[i] = span;
LiveRC_Config["HotCats"]["Matrix"].CatLink[i] = cat_link;
LiveRC_Config["HotCats"]["Matrix"].CatLinkIsRed[i] = !!($(cat_link).hasClass("new"));
LiveRC_Config["HotCats"]["Matrix"].CatName[i] = cat_title;
LiveRC_Config["HotCats"]["Matrix"].RemoveLink[i] = remove_link;
LiveRC_Config["HotCats"]["Matrix"].ModifyLink[i] = modify_link;
}
// AJOUT DU LIEN (+)
function lrcHotCats_append_add_span(catline) {
var Spans = catline.getElementsByTagName('span');
var span_add = document.createElement('span');
var a_add = document.createElement ( "a" ) ;
var a_text = document.createTextNode ( lrcMakeText("HC_AddLinkText") ) ;
span_add.id = "lrcHotCats_add" ;
a_add.id = "lrcHotCats_addlink" ;
a_add.href = "javascript:lrcHotCats_add_new("+LiveRC_Config["HotCats"]["Form_Index"]+")" ;
a_add.title = lrcMakeText("HC_AddLinkTitle") ;
a_add.appendChild( a_text ) ;
span_add.appendChild( a_add ) ;
if(Spans[0]) catline.appendChild(document.createTextNode(' | '));
catline.appendChild(span_add);
LiveRC_Config["HotCats"]["Matrix"].Span[LiveRC_Config["HotCats"]["Form_Index"]] = span_add;
LiveRC_Config["HotCats"]["Form_Index"]++
}
///////////////////////// ÉDITION SIMPLE ////////////////////////////////////////////////////////
// FONCTION DE RETRAIT D'UNE CATÉGORIE
function lrcHotCats_remove( cat_title, Index ) {
if(!LiveRC_Config["HotCats"]["Multi_Edit"]){
var RemovedCategories = new Array();
var ModifiedCategories_from = new Array();
var ModifiedCategories_to = new Array();
var AddedCategories = new Array();
RemovedCategories.push(cat_title);
var TextRecap = lrcMakeText("HC_RemoveConfirm")+" « " + cat_title + " » ?";
var LaunchEditFunction = function(){
lrcHotCats_Edit(RemovedCategories, ModifiedCategories_from, ModifiedCategories_to, AddedCategories, LiveRC_Config["HotCats"]["OldDefaultSort"]);
}
if(LiveRC_getHotCatsVariables("HC_SkipRecap")){
LaunchEditFunction();
}else{
LiveRC_confirm(TextRecap, LaunchEditFunction);
}
}else{
var Span = LiveRC_Config["HotCats"]["Matrix"].Span[Index];
if($(Span).hasClass("AddedCatSpan")){
Span.parentNode.removeChild(Span);
}else{
var FirstLink = LiveRC_Config["HotCats"]["Matrix"].CatLink[Index];
var OldCat = LiveRC_Config["HotCats"]["Matrix"].CatName[Index];
FirstLink.innerHTML = OldCat;
FirstLink.title = lrcGetNamespaceName(14)+':'+OldCat;
FirstLink.href = mw.config.get('wgServer')+mw.config.get('wgArticlePath').split('$1').join(lrcGetNamespaceName(14)+':'+OldCat);
$(FirstLink).addClass('RemovedCategory');
$(FirstLink).removeClass("ModifiedCategory")
if(LiveRC_Config["HotCats"]["Matrix"].CatLinkIsRed[Index]){
if(!$(FirstLink).hasClass("new")) $(FirstLink).addClass("new");
}else{
$(FirstLink).removeClass("new");
}
}
lrcHotCats_Multi_CheckForChanges();
}
}
// MODIFICATION D'UNE CATÉGORIE
function lrcHotCats_modify ( catname, Index ) {
var link = LiveRC_Config["HotCats"]["Matrix"].CatLink[Index] ;
var span = LiveRC_Config["HotCats"]["Matrix"].Span[Index] ;
var Links = span.getElementsByTagName('a');
for(a=0;a<Links.length;a++){
Links[a].style.display = "none";
}
span.firstChild.style.display = "none" ;
lrcHotCats_create_new_span ( span , catname, Index ) ;
lrcHotCatsText_changed(Index);
}
// AJOUT D'UNE CATÉGORIE
function lrcHotCats_add_new (Index) {
var span_add = document.getElementById( "lrcHotCats_add" ) ;
span_add.getElementsByTagName('a')[0].style.display = "none";
lrcHotCats_create_new_span ( span_add , "", Index ) ;
}
// CRÉATION DU FORMULAIRE DE MODIFICATION OU D'AJOUT D'UNE CATÉGORIE
function lrcHotCats_create_new_span( thespan , init_text, Index ) {
var DefaultSort = lrcHotCats_defaultSort_getOneOld(init_text);
if($(thespan).hasClass( "AddedCatSpan" )) DefaultSort = LiveRC_Config["HotCats"]["Matrix"].Sort[Index];
LiveRC_Config["HotCats"]["Matrix"].CatName[Index] = init_text;
var form = document.createElement ( "form" ) ;
form.id = "lrcHotCats_form" + Index;
form.method = "post" ;
form.onsubmit = function () {
var FormIndex = lrcHotCats_getIndex(this);
lrcHotCats_ok(FormIndex);
return false;
} ;
form.style.display = "inline" ;
var text = document.createElement ( "input" ) ;
text.size = 40 ;
text.id = "lrcHotCats_text" + Index ;
text.type = "text" ;
text.value = init_text + DefaultSort ;
text.onkeyup = function () {
var FormIndex = lrcHotCats_getIndex(this);
window.setTimeout("lrcHotCatsText_changed("+FormIndex+");", LiveRC_getHotCatsVariables("HC_suggestion_delay") );
} ;
var list = document.createElement ( "select" ) ;
list.id = "lrcHotCats_list" + Index ;
list.style.display = "none" ;
list.onclick = function () {
var FormIndex = lrcHotCats_getIndex(this);
lrcHotCatsText_replace(FormIndex);
} ;
var exists = document.createElement ( "span" ) ;
exists.id = "lrcHotCats_exists" + Index ;
exists.className = "lrcHotCats_NoExists" ;
exists.innerMTML = lrcMakeIcon("SuggestNoExistIcon").split("$1").join("").split(" ").join(" ");
var ParentCats = document.createElement ( "input" ) ;
ParentCats.id = "lrcHotCats_parents" + Index ;
ParentCats.type = "button" ;
ParentCats.value = lrcMakeText("HC_ParentText") ;
ParentCats.title = lrcMakeText("HC_ParentTitle") ;
ParentCats.onclick = function(){
var FormIndex = lrcHotCats_getIndex(this);
lrcHotCatsText_changed(FormIndex, "UP");
}
var DaughterCats = document.createElement ( "input" ) ;
DaughterCats.id = "lrcHotCats_daughters" + Index ;
DaughterCats.type = "button" ;
DaughterCats.value = lrcMakeText("HC_DaughterText") ;
DaughterCats.title = lrcMakeText("HC_DaughterTitle") ;
DaughterCats.onclick = function(){
var FormIndex = lrcHotCats_getIndex(this);
lrcHotCatsText_changed(FormIndex, "DOWN");
}
var OK = document.createElement ( "input" ) ;
OK.id = "lrcHotCats_OK" + Index ;
OK.type = "button" ;
OK.value = lrcMakeText("HC_InputOK") ;
OK.onclick = function(){
var FormIndex = lrcHotCats_getIndex(this);
lrcHotCats_ok(FormIndex) ;
}
var cancel = document.createElement ( "input" ) ;
cancel.id = "lrcHotCats_cancel" + Index ;
cancel.type = "button" ;
cancel.value = lrcMakeText("HC_InputCancel") ;
cancel.onclick = function(){
var FormIndex = lrcHotCats_getIndex(this);
lrcHotCats_cancel(FormIndex) ;
}
form.appendChild ( text ) ;
form.appendChild ( list ) ;
form.appendChild ( exists ) ;
form.appendChild ( ParentCats ) ;
form.appendChild ( DaughterCats ) ;
form.appendChild ( OK ) ;
form.appendChild ( cancel ) ;
thespan.appendChild ( form ) ;
text.focus () ;
lrcHotCats_upDate_FormPositions();
LiveRC_Config["HotCats"]["Matrix"].Form[Index] = form;
LiveRC_Config["HotCats"]["Matrix"].Text[Index] = text;
LiveRC_Config["HotCats"]["Matrix"].List[Index] = list;
LiveRC_Config["HotCats"]["Matrix"].Exist[Index] = exists;
lrcHotCatsText_changed(Index);
}
// VALIDATION DU FORMULAIRE
function lrcHotCats_ok(Index) {
var Form = LiveRC_Config["HotCats"]["Matrix"].Form[Index];
var Input = LiveRC_Config["HotCats"]["Matrix"].Text[Index];
var TheSpan = LiveRC_Config["HotCats"]["Matrix"].Span[Index] ;
var CatLink = LiveRC_Config["HotCats"]["Matrix"].CatLink[Index];
var IfExist = LiveRC_Config["HotCats"]["Matrix"].Exist[Index];
var OldCatName = LiveRC_Config["HotCats"]["Matrix"].CatName[Index];
var OldDefaultSort = lrcHotCats_defaultSort_getOneOld(OldCatName);
var NewCatName = Input.value.ucFirst().replace(/\|.*/, "") ;
var NewDefaultSort = Input.value.ucFirst().split(NewCatName).join("");
LiveRC_Config["HotCats"]["Matrix"].Sort[Index] = NewDefaultSort;
if ( NewCatName == "" ) {
lrcHotCats_cancel(Index) ;
return ;
}
if(LiveRC_Config["HotCats"]["Multi_Edit"]==false){
if((OldCatName+OldDefaultSort)==(NewCatName+NewDefaultSort)) return;
var RemovedCategories = new Array();
var ModifiedCategories_from = new Array();
var ModifiedCategories_to = new Array();
var AddedCategories = new Array();
if ( TheSpan.id != "lrcHotCats_add" ) {
ModifiedCategories_from.push(OldCatName+OldDefaultSort);
ModifiedCategories_to.push(NewCatName+NewDefaultSort);
}else{
AddedCategories.push(NewCatName+NewDefaultSort);
}
lrcHotCats_Edit(RemovedCategories, ModifiedCategories_from, ModifiedCategories_to, AddedCategories, LiveRC_Config["HotCats"]["OldDefaultSort"]);
}else{
var Exist = $(IfExist).hasClass("lrcHotCats_Exists");
if(TheSpan.id!="lrcHotCats_add"){
CatLink.innerHTML = NewCatName;
CatLink.title = lrcGetNamespaceName(14)+':'+NewCatName;
CatLink.href = mw.config.get('wgServer') + mw.config.get('wgArticlePath').split('$1').join(lrcGetNamespaceName(14)+':'+NewCatName);
if((!$(CatLink).hasClass("AddedCategory"))&&(!$(CatLink).hasClass("ModifiedCategory"))) $(CatLink).addClass("ModifiedCategory");
if((OldCatName+OldDefaultSort)==(NewCatName+NewDefaultSort)){
$(CatLink).removeClass("ModifiedCategory");
}
$(CatLink).removeClass("RemovedCategory");
}else{
LiveRC_Config["HotCats"]["NewCatsIndex"]++
LiveRC_Config["HotCats"]["Matrix"].CatName[LiveRC_Config["HotCats"]["NewCatsIndex"]] = NewCatName;
LiveRC_Config["HotCats"]["Matrix"].Sort[LiveRC_Config["HotCats"]["NewCatsIndex"]] = NewDefaultSort;
var NewSpan = document.createElement('span');
NewSpan.id = "lrcHotCats_Span_"+LiveRC_Config["HotCats"]["NewCatsIndex"];
NewSpan.className = "AddedCatSpan";
CatLink = document.createElement('a');
CatLink.id = "CatLink_"+LiveRC_Config["HotCats"]["NewCatsIndex"];
CatLink.innerHTML = NewCatName;
CatLink.title = lrcGetNamespaceName(14)+':'+NewCatName;
CatLink.href = mw.config.get('wgServer') + mw.config.get('wgArticlePath').split('$1').join(lrcGetNamespaceName(14)+':'+NewCatName);
$(CatLink).addClass("AddedCategory");
var RemoveLink = document.createElement('a');
RemoveLink.innerHTML = lrcMakeText("HC_RemoveLinkText");
RemoveLink.id = "lrcHotCats_remove_"+LiveRC_Config["HotCats"]["NewCatsIndex"];
RemoveLink.title = lrcMakeText("HC_RemoveLinkTitle")+" « "+NewCatName+" »";
RemoveLink.href = "javascript:lrcHotCats_remove(\"" + NewCatName+ "\","+LiveRC_Config["HotCats"]["NewCatsIndex"]+");";
var ModifyLink = document.createElement('a');
ModifyLink.innerHTML = lrcMakeText("HC_ModifyLinkText");
ModifyLink.id = "lrcHotCats_modify_"+LiveRC_Config["HotCats"]["NewCatsIndex"];
ModifyLink.title = lrcMakeText("HC_ModifyLinkTitle")+" « "+NewCatName+" »";
ModifyLink.href = "javascript:lrcHotCats_modify(\""+NewCatName+"\","+LiveRC_Config["HotCats"]["NewCatsIndex"]+ ")";
NewSpan.appendChild(CatLink);
NewSpan.appendChild(document.createTextNode(" "));
NewSpan.appendChild(RemoveLink);
NewSpan.appendChild(document.createTextNode(" "));
NewSpan.appendChild(ModifyLink);
NewSpan.appendChild(document.createTextNode(" | "));
TheSpan.parentNode.insertBefore(NewSpan, TheSpan);
LiveRC_Config["HotCats"]["Matrix"].Span[LiveRC_Config["HotCats"]["NewCatsIndex"]] = NewSpan;
LiveRC_Config["HotCats"]["Matrix"].CatLink[LiveRC_Config["HotCats"]["NewCatsIndex"]] = CatLink;
LiveRC_Config["HotCats"]["Matrix"].RemoveLink[LiveRC_Config["HotCats"]["NewCatsIndex"]] = RemoveLink;
LiveRC_Config["HotCats"]["Matrix"].ModifyLink.push[LiveRC_Config["HotCats"]["NewCatsIndex"]] = ModifyLink;
}
if(!Exist){
$(CatLink).addClass("new");
}else{
$(CatLink).removeClass("new");
}
var Links = TheSpan.getElementsByTagName('a');
for(var a=0;a<Links.length;a++){
Links[a].style.display = "";
}
TheSpan.removeChild(Form);
lrcHotCats_Multi_CheckForChanges();
lrcHotCats_upDate_FormPositions();
if(TheSpan.id!="lrcHotCats_add"){
document.getElementById("lrcHotCats_modify_"+Index).focus();
}else{
document.getElementById("lrcHotCats_addlink").focus();
}
}
}
// ANNULATION DU FORMULAIRE
function lrcHotCats_cancel (Index) {
var Form = LiveRC_Config["HotCats"]["Matrix"].Form[Index];
var Input = LiveRC_Config["HotCats"]["Matrix"].Text[Index];
var TheSpan = LiveRC_Config["HotCats"]["Matrix"].Span[Index] ;
var CatLink = LiveRC_Config["HotCats"]["Matrix"].CatLink[Index];
var IfExist = LiveRC_Config["HotCats"]["Matrix"].Exist[Index];
var OldCatLink = LiveRC_Config["HotCats"]["Matrix"].RemoveLink[Index];
TheSpan.removeChild ( Form ) ;
var Links = TheSpan.getElementsByTagName('a');
for(a=0;a<Links.length;a++){
Links[a].style.display = "";
}
TheSpan.firstChild.style.display = "" ;
lrcHotCats_Multi_CheckForChanges();
lrcHotCats_upDate_FormPositions();
if(TheSpan.id!="lrcHotCats_add"){
document.getElementById("lrcHotCats_modify_"+Index).focus();
}else{
document.getElementById("lrcHotCats_addlink").focus();
}
}
///////////////////////// ÉDITION MULTIPLE ////////////////////////////////////////////////////////
// AJOUT DU LIEN (±)
function lrcHotCats_append_multiedit_span( CatLine ){
var FirstLink = CatLine.getElementsByTagName('a')[0];
var Span = document.createElement('span');
Span.id ='lrcHotCats_modify_multi_span';
var Link = document.createElement('a');
Link.id = "lrcHotCats_modify_multi_Link";
Link.innerHTML = lrcMakeText("HC_MultiLinkText");
Link.title = lrcMakeText("HC_MultiLinkTitle");
Link.href = "javascript:lrcHotCats_multiedit_createForm();";
Span.appendChild(Link);
FirstLink.parentNode.insertBefore(Span, FirstLink.nextSibling);
FirstLink.parentNode.insertBefore(document.createTextNode(" "), FirstLink.nextSibling);
var DefaultSortSpan = document.createElement('span');
DefaultSortSpan.id ='lrcHotCats_DefaultSort_span';
var DefaultSortLink = document.createElement('a');
DefaultSortLink.id = "lrcHotCats_DefaultSort_Link";
DefaultSortLink.innerHTML = lrcMakeText("HC_DefaultSortText");
DefaultSortLink.title = lrcMakeText("HC_DefaultSortTitle");
DefaultSortLink.href = "javascript:lrcHotCats_defaultSort_createForm();";
DefaultSortSpan.appendChild(DefaultSortLink);
var OldDefaultSortSpan = document.createElement('span');
OldDefaultSortSpan.style.display = "none";
OldDefaultSortSpan.id = "OldDefaultSortSpan";
DefaultSortSpan.appendChild(OldDefaultSortSpan);
$(DefaultSortSpan).insertAfter(Span);
$(document.createTextNode(" ")).insertAfter(Span);
if(LiveRC_getHotCatsVariables("HC_AutoMulti")) lrcHotCats_multiedit_createForm();
}
// CREATION DU FORMULAIRE "MULTI"
function lrcHotCats_multiedit_createForm(){
var OldForms = document.getElementById('mw-normal-catlinks').getElementsByTagName('form');
while(OldForms[0]) OldForms[0].parentNode.removeChild(OldForms[0]);
var OldLinks = document.getElementById('mw-normal-catlinks').getElementsByTagName('a');
for(var a=0;a<OldLinks.length;a++){
OldLinks[a].style.display="";
}
for(var a=0;a<LiveRC_Config["HotCats"]["Matrix"].CatLink.length;a++){
if(!LiveRC_Config["HotCats"]["Matrix"].CatLink[a]) continue;
if(LiveRC_Config["HotCats"]["Matrix"].CatLinkIsRed[a]){
if(!$(LiveRC_Config["HotCats"]["Matrix"].CatLink[a]).hasClass("new")) $(LiveRC_Config["HotCats"]["Matrix"].CatLink[a]).addClass("new");
}else{
$(LiveRC_Config["HotCats"]["Matrix"].CatLink[a]).removeClass("new");
}
}
var OldSpans = document.getElementById('mw-normal-catlinks').getElementsByTagName('span');
for(var a=0;a<OldSpans.length;a++){
if(OldSpans[a].id != 'OldDefaultSortSpan') OldSpans[a].style.display="";
}
if(!document.getElementById("lrcHotCats_addlink")) lrcHotCats_add_new ( document.getElementById("lrcHotCats_add") );
var Legend = "";
if(LiveRC_getHotCatsVariables("HC_ShowLegend")){
Legend = '<small>'
+ '<a href="'+LiveRC_getHotCatsVariables("HC_docURL")+'" title="'+lrcMakeText("HC_LabelTitle")+'" target="_blank" '
+ 'style="color:#002BB8;padding:0.2em;margin-left:'+(LiveRC_getHotCatsVariables("HC_ShowInline") ? 5 :100 )+'px;">'
+ ' <b>'+lrcMakeText("HC_LabelText")+'</b> :'
+ ' <span class="RemovedCategory">'+lrcMakeText("HC_RecapRemove")+'</span>'
+ ' <span class="ModifiedCategory">'+lrcMakeText("HC_RecapModify")+'</span>'
+ ' <span class="AddedCategory">'+lrcMakeText("HC_RecapAdd")+'</span>'
+ '</a>'
+ '</small>'
}
var BR = "";
if(!LiveRC_getHotCatsVariables("HC_ShowInline")) BR = "<br />";
var RadioBoxes = "";
var MinorValue = LiveRC_Config["HotCats"]["MinorEditStatus"];
var WatchValue = LiveRC_Config["HotCats"]["WatchStatus"];
var MinorOneChecked = ( (MinorValue=="-1") ? 'checked="checked" ' : '' );
var MinorTwoChecked = ( (MinorValue=="0") ? 'checked="checked" ' : '' );
var MinorThreeChecked = ( (MinorValue=="1") ? 'checked="checked" ' : '' );
var WatchOneChecked = ( (WatchValue=="preferences") ? 'checked="checked" ' : '' );
var WatchTwoChecked = ( (WatchValue=="unwatch") ? 'checked="checked" ' : '' );
var WatchThreeChecked = ( (WatchValue=="watch") ? 'checked="checked" ' : '' );
var WatchFourChecked = ( (WatchValue=="nochange") ? 'checked="checked" ' : '' );
RadioBoxes = '<span id="lrcHotCats_RadioBoxes">'
+ ' '
+ '<span style="border:1px dotted silver;padding:0.2em;padding-top:0.5em">'
+ '<label for="MinorEditStatus">'+lrcMakeText("HC_Minoredit")+'</label>'
+ ' '
+ '<input value="-1" type="radio" name="MinorEditStatus" '+MinorOneChecked+' style="cursor:pointer;" '
+ 'title="'+lrcMakeText("HC_Minoredit")+' : '+lrcMakeText("HC_RadioDefault")+'" />'
+ '<input value="0" type="radio" name="MinorEditStatus" '+MinorTwoChecked+' style="cursor:pointer;" '
+ 'title="'+lrcMakeText("HC_Minoredit")+' : '+lrcMakeText("HC_RadioNo")+'" />'
+ '<input value="1" type="radio" name="MinorEditStatus" '+MinorThreeChecked+' style="cursor:pointer;" '
+ 'title="'+lrcMakeText("HC_Minoredit")+' : '+lrcMakeText("HC_RadioYes")+'" />'
+ '</span>'
+ ' '
+ '<span style="border:1px dotted silver;padding:0.2em;padding-top:0.5em">'
+ '<label for="WatchStatus">'+lrcMakeText("HC_Watchthis")+'</label>'
+ ' '
+ '<input value="preferences" type="radio" name="WatchStatus" '+WatchOneChecked+' style="cursor:pointer;" '
+ 'title="'+lrcMakeText("HC_Watchthis")+' : '+lrcMakeText("HC_RadioDefault")+'" />'
+ '<input value="unwatch" type="radio" name="WatchStatus" '+WatchTwoChecked+' style="cursor:pointer;" '
+ 'title="'+lrcMakeText("HC_Watchthis")+' : '+lrcMakeText("HC_RadioNo")+'" />'
+ '<input value="watch" type="radio" name="WatchStatus" '+WatchThreeChecked+' style="cursor:pointer;" '
+ 'title="'+lrcMakeText("HC_Watchthis")+' : '+lrcMakeText("HC_RadioYes")+'" />'
+ '<input value="nochange" type="radio" name="WatchStatus" '+WatchFourChecked+' style="cursor:pointer;" '
+ 'title="'+lrcMakeText("HC_Watchthis")+' : '+lrcMakeText("HC_RadioNoChange")+'" />'
+ '</span>'
+ '</span>';
var Link = document.getElementById('lrcHotCats_modify_multi_Link');
var Span = Link.parentNode;
var Form = document.createElement('form');
Form.id = "lrcHotCats_modify_multi_form";
Form.style.display = "inline";
Form.innerHTML = ''
+ Legend
+ BR
+ '<input id="lrcHotCats_modify_multi_InputOK" type="button" disabled="disabled" '
+ 'value="'+lrcMakeText("HC_MultiInputOK")+'" '
+ 'onclick="lrcHotCats_multiedit_FormOK()" onselect="lrcHotCats_multiedit_FormOK()" />'
+ '<input id="lrcHotCats_modify_multi_InputCancel" type="button" '
+ 'value="'+lrcMakeText("HC_MultiInputCancel")+'" '
+ 'onclick="lrcHotCats_multiedit_CancelForm()" onselect="lrcHotCats_multiedit_CancelForm()" />'
+ RadioBoxes
+ BR
Span.appendChild(Form);
Link.style.display = "none";
LiveRC_Config["HotCats"]["Multi_Edit"] = true;
var LP = document.getElementById( 'livePreview' );
if(LP) LP.scrollTop = parseInt(LP.style.height.split("px").join(""));
document.getElementById("lrcHotCats_modify_multi_InputCancel").focus();
}
// ANNULATION DU FORMULAIRE "MULTI" + MODIFICATION DES LIENS, FONCTIONS ET IDS DE LA BARRE DE CATÉGORIES
function lrcHotCats_multiedit_CancelForm(){
var Link = document.getElementById('lrcHotCats_modify_multi_Link');
var Form = document.getElementById('lrcHotCats_modify_multi_form');
if(Link) Link.style.display = "inline";
var CatForms = document.getElementById('mw-normal-catlinks').getElementsByTagName('form');
while(CatForms[0]){
CatForms[0].parentNode.removeChild(CatForms[0]);
}
var CatSpans = document.getElementById('mw-normal-catlinks').getElementsByTagName('span');
var SpanToRemove = new Array();
for(var a=1;a<CatSpans.length;a++){
if($(CatSpans[a]).hasClass("AddedCatSpan")) SpanToRemove.push(CatSpans[a]);
}
for(var a=0;a<SpanToRemove.length;a++){
SpanToRemove[a].parentNode.removeChild(SpanToRemove[a]);
}
var CatLinks = document.getElementById('mw-normal-catlinks').getElementsByTagName('a');
for(var a=0;a<CatLinks.length;a++){
CatLinks[a].style.display = "inline";
$(CatLinks[a]).removeClass("RemovedCategory");
if($(CatLinks[a]).hasClass("ModifiedCategory")){
var Index = lrcHotCats_getIndex( CatLinks[a] )
var Parent = CatLinks[a].parentNode;
var OldCatName = LiveRC_Config["HotCats"]["Matrix"].CatName[Index];
var OldDefaultSort = lrcHotCats_defaultSort_getOneOld(OldCatName);
LiveRC_Config["HotCats"]["Matrix"].Sort[Index] = OldDefaultSort;
CatLinks[a].innerHTML = OldCatName;
CatLinks[a].title = lrcGetNamespaceName(14)+':'+OldCatName;
CatLinks[a].href = mw.config.get('wgServer')+mw.config.get('wgArticlePath').split('$1').join(lrcGetNamespaceName(14)+':'+OldCatName);
$(CatLinks[a]).removeClass("ModifiedCategory");
}
if($(CatLinks[a]).hasClass("ModifiedDefaultSort")){
var DefaultSortSpan = document.getElementById("OldDefaultSortSpan");
DefaultSortSpan.innerHTML = LiveRC_Config["HotCats"]["OldDefaultSort"];
$(CatLinks[a]).removeClass("ModifiedDefaultSort");
}
}
for(var a=0;a<LiveRC_Config["HotCats"]["Matrix"].CatLink.length;a++){
if(!LiveRC_Config["HotCats"]["Matrix"].CatLink[a]) continue;
if(LiveRC_Config["HotCats"]["Matrix"].CatLinkIsRed[a]){
if(!$(LiveRC_Config["HotCats"]["Matrix"].CatLink[a]).hasClass("new")) $(LiveRC_Config["HotCats"]["Matrix"].CatLink[a]).addClass("new");
}else{
$(LiveRC_Config["HotCats"]["Matrix"].CatLink[a]).removeClass("new");
}
}
LiveRC_Config["HotCats"]["Multi_Edit"] = false;
Link.focus();
}
// VALIDATION DU FORMULAIRE "MULTI" + LISTING DES CATÉGORIES À ENLEVER/MODIFIER/AJOUTER
function lrcHotCats_multiedit_FormOK(){
var RemovedCategories = new Array();
var ModifiedCategories_from = new Array();
var ModifiedCategories_to = new Array();
var AddedCategories = new Array();
var DefaultSort = LiveRC_Config["HotCats"]["OldDefaultSort"];
var CatLinks = document.getElementById('mw-normal-catlinks').getElementsByTagName('a');
for(var a=0;a<CatLinks.length;a++){
var Link = CatLinks[a];
var Index = lrcHotCats_getIndex( Link );
if($(Link).hasClass("RemovedCategory")){
var RemovedCat = (LiveRC_Config["HotCats"]["CaseSensitive"] ? Link.innerHTML : Link.innerHTML.ucFirst());
RemovedCategories.push(RemovedCat);
}
if($(Link).hasClass("ModifiedCategory")){
var NewCatName = (LiveRC_Config["HotCats"]["CaseSensitive"] ? Link.innerHTML : Link.innerHTML.ucFirst());
var OldCatName = LiveRC_Config["HotCats"]["Matrix"].CatName[Index];
var OldDefaultSort = lrcHotCats_defaultSort_getOneOld(OldCatName);
var NewDefaultSort = LiveRC_Config["HotCats"]["Matrix"].Sort[Index];
if((OldCatName+OldDefaultSort)!=(NewCatName+NewDefaultSort)){
ModifiedCategories_from.push((OldCatName+OldDefaultSort));
ModifiedCategories_to.push((NewCatName+NewDefaultSort));
}
}
if($(Link).hasClass("AddedCategory")){
var NewDefaultSort = LiveRC_Config["HotCats"]["Matrix"].Sort[Index];
var AddedCat = (LiveRC_Config["HotCats"]["CaseSensitive"] ? Link.innerHTML : Link.innerHTML.ucFirst());
AddedCategories.push(AddedCat+NewDefaultSort);
}
if($(Link).hasClass("ModifiedDefaultSort")){
var DefaultSortSpan = document.getElementById("OldDefaultSortSpan");
DefaultSort = DefaultSortSpan.innerHTML;
}
}
var TextrecapTitle = '<h6>' + lrcMakeText("HC_RecapTitle")+'</h6>';
var TextRecap = TextrecapTitle;
if(RemovedCategories[0]){
TextRecap += '<p>' + lrcMakeText("HC_RecapRemove")+' :</p><ul>'
for(var a=0;a<RemovedCategories.length;a++){
TextRecap += '<li> « '+RemovedCategories[a]+' »</li>';
}
TextRecap += '</ul>';
}
if(ModifiedCategories_to[0]){
TextRecap += '<p>' + lrcMakeText("HC_RecapModify")+' :</p><ul>'
for(var a=0;a<ModifiedCategories_to.length;a++){
TextRecap += '<li> « '+ModifiedCategories_from[a]+' » -> « '+ModifiedCategories_to[a]+' »</li>';
}
TextRecap += '</ul>';
}
if(AddedCategories[0]){
TextRecap += '<p>' + lrcMakeText("HC_RecapAdd")+' :</p><ul>'
for(var a=0;a<AddedCategories.length;a++){
TextRecap += '<li> « '+AddedCategories[a]+' »</li>';
}
TextRecap += '</ul>';
}
if(DefaultSort!=LiveRC_Config["HotCats"]["OldDefaultSort"]){
TextRecap += '<p>' + lrcMakeText("HC_RecapSort")+' :</p><ul>'
TextRecap += '<li> « '+LiveRC_Config["HotCats"]["OldDefaultSort"]+' » -> « '+DefaultSort+' »</li>';
TextRecap += '</ul>';
}
if(TextRecap == TextrecapTitle) return;
var RadioNameTexts = {"MinorEditStatus":"HC_Minoredit","WatchStatus":"HC_Watchthis"};
var RadioValueTexts = {"watch":"HC_RadioYes","unwatch":"HC_RadioNo","preferences":"HC_RadioDefault","nochange":"HC_RadioNoChange","1":"HC_RadioYes","0":"HC_RadioNo","-1":"HC_RadioDefault"};
var RadioBoxesSpan = document.getElementById("lrcHotCats_RadioBoxes");
if(RadioBoxesSpan){
var RadioBoxes = RadioBoxesSpan.getElementsByTagName('input');
for(var a=0;a<RadioBoxes.length;a++){
var Radio = RadioBoxes[a];
if(Radio.type!="radio") continue;
if(!Radio.checked) continue;
var BoxName = Radio.name;
var Value = Radio.value;
LiveRC_Config["HotCats"][BoxName] = Value;
TextRecap += "<p>"+lrcMakeText(RadioNameTexts[BoxName])+" :</p><ul>"
+ "<li>"+lrcMakeText(RadioValueTexts[Value]) + "</li>"
+"</ul>";
}
}
var LaunchEditFunction = function(){
lrcHotCats_Edit(RemovedCategories, ModifiedCategories_from, ModifiedCategories_to, AddedCategories, DefaultSort);
}
if(LiveRC_getHotCatsVariables("HC_SkipRecap")){
LaunchEditFunction();
}else{
LiveRC_confirm(TextRecap, LaunchEditFunction);
}
}
// VÉRIFICATION DES CHANGEMENTS EFFECTUÉS
function lrcHotCats_Multi_CheckForChanges(){
if(!LiveRC_Config["HotCats"]["Multi_Edit"]) return;
var CatLinks = document.getElementById('mw-normal-catlinks').getElementsByTagName('a');
var AnythingChanged = false;
for(var a=0;a<CatLinks.length;a++){
var Link = CatLinks[a];
if(($(Link).hasClass("RemovedCategory"))||($(Link).hasClass("ModifiedCategory"))||($(Link).hasClass("AddedCategory"))||($(Link).hasClass("ModifiedDefaultSort"))){
AnythingChanged = true;
}
}
var Input = document.getElementById('lrcHotCats_modify_multi_InputOK');
if(!Input) return;
if(AnythingChanged){
Input.disabled = "";
}else{
Input.disabled = "disabled";
}
}
///////////////////////// CLEFS DE TRI ////////////////////////////////////////////////////////
// CRÉATION FORMULAIRE CLEF DE TRI GLOBALE
function lrcHotCats_defaultSort_createForm(){
lrcHotCats_defaultSort_getOld("OldDefaultSortSpan");
var thespan = document.getElementById('lrcHotCats_DefaultSort_span');
var OldDefaultSort = thespan.getElementsByTagName('span')[0].innerHTML;
thespan.getElementsByTagName('a')[0].style.display = "none";
var form = document.createElement ( "form" ) ;
form.id = "lrcHotCats_form_Default";
form.method = "post" ;
form.onsubmit = function () {
lrcHotCats_Default_ok(this) ;
return false;
} ;
form.style.display = "inline" ;
var text = document.createElement ( "input" ) ;
text.size = 40 ;
text.id = "lrcHotCatsText.Default" ;
text.type = "text" ;
text.value = OldDefaultSort ;
var OK = document.createElement ( "input" ) ;
OK.type = "button" ;
OK.value = lrcMakeText("HC_InputOK") ;
OK.onclick = function(){
lrcHotCats_Default_ok(this.parentNode) ;
}
var cancel = document.createElement ( "input" ) ;
cancel.type = "button" ;
cancel.value = lrcMakeText("HC_InputCancel") ;
cancel.onclick = function(){
var Form = this.parentNode;
lrcHotCats_Default_Cancel(Form) ;
}
form.appendChild ( text ) ;
form.appendChild ( OK ) ;
form.appendChild ( cancel ) ;
thespan.appendChild ( form ) ;
lrcHotCats_upDate_FormPositions();
text.focus () ;
}
// ANNULATION FORMULAIRE CLEF DE TRI GLOBALE
function lrcHotCats_Default_Cancel(Form){
var Span = Form.parentNode;
Form.parentNode.getElementsByTagName('a')[0].style.display = "";
Form.parentNode.removeChild(Form) ;
if(LiveRC_Config["HotCats"]["Multi_Edit"]){
Span.getElementsByTagName('span')[0].innerHTML = LiveRC_Config["HotCats"]["OldDefaultSort"];
$(Span.getElementsByTagName('a')[0]).removeClass("ModifiedDefaultSort");
Span.getElementsByTagName('a')[0].style.display = "";
lrcHotCats_Multi_CheckForChanges();
}
document.getElementById("lrcHotCats_DefaultSort_Link").focus();
}
// VALIDATION FORMULAIRE CLEF DE TRI GLOBALE
function lrcHotCats_Default_ok(Form){
var Text = document.getElementById("lrcHotCatsText.Default");
var OldDefaultSort = LiveRC_Config["HotCats"]["OldDefaultSort"];
var NewDefaultSort = Text.value;
if(!LiveRC_Config["HotCats"]["Multi_Edit"]){
if(OldDefaultSort==NewDefaultSort){
lrcHotCats_Default_Cancel(Form)
return;
}else{
var RemovedCategories = new Array();
var ModifiedCategories_from = new Array();
var ModifiedCategories_to = new Array();
var AddedCategories = new Array();
var DefaultSort = NewDefaultSort ;
lrcHotCats_Edit(RemovedCategories, ModifiedCategories_from, ModifiedCategories_to, AddedCategories, DefaultSort);
}
}else{
if(OldDefaultSort==NewDefaultSort){
lrcHotCats_Default_Cancel(Form)
return;
}else{
var Span = Form.parentNode;
Span.getElementsByTagName('span')[0].innerHTML = Text.value;
var Link = Span.getElementsByTagName('a')[0]
Link.style.display = "";
$(Link).addClass("ModifiedDefaultSort");
Form.parentNode.removeChild(Form) ;
lrcHotCats_Multi_CheckForChanges();
lrcHotCats_upDate_FormPositions();
document.getElementById("lrcHotCats_DefaultSort_Link").focus();
}
}
}
///////////////////////// ÉDITION ////////////////////////////////////////////////////////
function lrcHotCats_Edit(RemovedCategories, ModifiedCategories_from, ModifiedCategories_to, AddedCategories, DefaultSort){
LiveRC_Config["HotCats"]["ChangesToDo"] = {
RemovedCategories : (RemovedCategories? RemovedCategories :false),
ModifiedCategories_from : (ModifiedCategories_from ? ModifiedCategories_from : false),
ModifiedCategories_to : (ModifiedCategories_to ? ModifiedCategories_to : false),
AddedCategories : (AddedCategories ? AddedCategories : false),
DefaultSort : (DefaultSort ? DefaultSort : false)
};
LiveRC_Config["HotCats"]["IsEditMode"] = true;
liveEdit(LiveRC_Config["HotCats"]["CurrentPage"]);
}
function lrcHotCats_DoEdit(){
var Preview = document.getElementById("livePreview");
if(!Preview || !LiveRC_Config["HotCats"]["IsEditMode"]) return;
var RemovedCategories = LiveRC_Config["HotCats"]["ChangesToDo"].RemovedCategories;
var ModifiedCategories_from = LiveRC_Config["HotCats"]["ChangesToDo"].ModifiedCategories_from;
var ModifiedCategories_to = LiveRC_Config["HotCats"]["ChangesToDo"].ModifiedCategories_to;
var AddedCategories = LiveRC_Config["HotCats"]["ChangesToDo"].AddedCategories;
var DefaultSort = LiveRC_Config["HotCats"]["ChangesToDo"].DefaultSort;
var prevent_autocommit = 0;
if(LiveRC_getHotCatsVariables("HC_autocommit")) getElementWithId("editform", "form", Preview).style.display = "none";
var OldText = getElementWithId("wpTextbox1", "textarea", Preview).value;
var summary = new Array();
for(var a=0;a<RemovedCategories.length;a++){
var OldCatName = RemovedCategories[a];
var OldCatNameUnsorted = OldCatName.replace(/\|.*/, "");
var REGEXP = lrcHotCats_CreateRegExp(OldCatName);
var matchesCatName = OldText.match(REGEXP);
if (matchesCatName != null && matchesCatName.length == 1) {
OldText = OldText.replace(REGEXP, "");
summary.push( " – [[" + lrcGetNamespaceName(14)+':'+OldCatNameUnsorted + "]]" ) ;
}else{
prevent_autocommit = 1
if(matchesCatNameUnsorted == null){
LiveRC_alert(lrcMakeText("HC_AlertProblem1").split('$1').join(OldCatNameUnsorted));
}else if(matchesCatNameUnsorted.length > 1){
LiveRC_alert(lrcMakeText("HC_AlertProblem3").split('$1').join(OldCatNameUnsorted));
}
}
}
if((RemovedCategories[0])&&((ModifiedCategories_from[0])||(AddedCategories[0]))) summary.push(" |");
for(var a=0;a<ModifiedCategories_from.length;a++){
var OldCatName = ModifiedCategories_from[a];
var OldCatNameUnsorted = OldCatName.replace(/\|.*/, "");
var NewCatName = ModifiedCategories_to[a];
var NewCatNameUnsorted = NewCatName.replace(/\|.*/, "");
var REGEXP_OLD = lrcHotCats_CreateRegExp(OldCatName);
var REGEXP_NEW = lrcHotCats_CreateRegExp(NewCatNameUnsorted);
var matchesOldCatName = OldText.match(REGEXP_OLD);
var matchesNewCatName = OldText.match(REGEXP_NEW);
if( ((matchesNewCatName == null)||(OldCatNameUnsorted==NewCatNameUnsorted)) && matchesOldCatName != null && matchesOldCatName.length == 1) {
OldText = OldText.replace(REGEXP_OLD, "$1[[" + lrcGetNamespaceName(14)+':'+NewCatName + "]]");
summary.push ( " ± [["+lrcGetNamespaceName(14)+':'+OldCatNameUnsorted+"]]->[["+lrcGetNamespaceName(14)+':'+ NewCatNameUnsorted+"]]");
}else{
prevent_autocommit = 1
if(matchesOldCatName == null){
LiveRC_alert(lrcMakeText("HC_AlertProblem1").split('$1').join(OldCatNameUnsorted));
}else if(matchesOldCatName.length > 1){
LiveRC_alert(lrcMakeText("HC_AlertProblem3").split('$1').join(OldCatNameUnsorted));
}else if((matchesNewCatName != null)&&(OldCatNameUnsorted!=NewCatNameUnsorted)){
LiveRC_alert(lrcMakeText("HC_AlertProblem2").split('$1').join(NewCatNameUnsorted));
}
}
}
if((AddedCategories[0])&&(ModifiedCategories_from[0])) summary.push(" |");
for(var a=0;a<AddedCategories.length;a++){
var NewCatName = AddedCategories[a];
var NewCatNameUnsorted = NewCatName.replace(/\|.*/, "");
var REGEXP = lrcHotCats_CreateRegExp(NewCatNameUnsorted);
var matchesCatNameUnsorted = OldText.match(REGEXP);
if (matchesCatNameUnsorted != null){
LiveRC_alert(lrcMakeText("HC_AlertProblem2").split('$1').join(NewCatNameUnsorted));
prevent_autocommit = 1
continue;
}
var re = new RegExp("\\[\\[(?:"+lrcGetNamespaceName(14)+"|Category):[^\\]]+\\]\\]", "ig")
var index = -1;
while (re.exec(OldText) != null) index = re.lastIndex;
var txt = "[[" + lrcGetNamespaceName(14)+':'+NewCatName + "]]" ;
if (index < 0) { // no category
var interWiki = new RegExp('^\\s*\\[\\[([a-z][a-z].?(x?-[^\\]]+)?|simple|tokipona):([^\\]]*)\\]\\]\\s*$');
var blank = new RegExp('^\\s*$');
var lines = OldText.split('\n');
var DebutModele = '';
var SuiteModele = '';
var FoundInterwiki = false;
for (var lineId = lines.length - 1; lineId >= 0; --lineId){
if (!interWiki.exec(lines[lineId]) && !blank.exec(lines[lineId])){
DebutModele = lines.slice(0, lineId + 1).join('\n');
SuiteModele = lines.slice(lineId + 1).join('\n');
break;
}
}
DebutModele = DebutModele + '\n\n';
while(SuiteModele.indexOf('\n\n')!=-1){
SuiteModele = SuiteModele.split("\n\n").join("\n");
}
SuiteModele = SuiteModele.replace(/^\n/, "");
OldText = DebutModele + txt + '\n\n' + SuiteModele;
}else{
OldText = OldText.substring(0, index) + '\n' + txt + OldText.substring(index);
}
summary.push ( " + [[" + lrcGetNamespaceName(14)+':'+NewCatNameUnsorted + "]]" ) ;
}
if((DefaultSort!=LiveRC_Config["HotCats"]["OldDefaultSort"])&&(DefaultSort!="undefined")){
var NewDefaultSort = "{{DEFAULTSORT:"+DefaultSort+"}}\n";
var HasDefaultSort = null;
for(var d=0;d<LiveRC_Config["MediawikiMagicwords"]["defaultsort"].length;d++){
if(OldText.indexOf(LiveRC_Config["MediawikiMagicwords"]["defaultsort"][d])!=-1) HasDefaultSort = LiveRC_Config["MediawikiMagicwords"]["defaultsort"][d];
}
if(HasDefaultSort!=null){
if(!DefaultSort){
NewDefaultSort = "";
summary.push ("; – " + LiveRC_Config["HotCats"]["OldDefaultSort"] ) ;
}else{
summary.push ("; ± {{DEFAULTSORT:}} : " + LiveRC_Config["HotCats"]["OldDefaultSort"] + " -> " + DefaultSort) ;
}
OldText = OldText.split("{{"+HasDefaultSort+LiveRC_Config["HotCats"]["OldDefaultSort"]+"}}\n").join(NewDefaultSort);
OldText = OldText.split("{{"+HasDefaultSort+LiveRC_Config["HotCats"]["OldDefaultSort"]+"}}").join(NewDefaultSort);
}else if(DefaultSort){
var re = new RegExp("\\[\\[(?:"+lrcGetNamespaceName(14)+"|Category):[^\\]]+\\]\\]", "ig")
var index = re.exec(OldText);
if(index ==null ) {
var interWiki = new RegExp('^\\s*\\[\\[([a-z][a-z].?(x?-[^\\]]+)?|simple|tokipona):([^\\]]*)\\]\\]\\s*$');
var blank = new RegExp('^\\s*$');
var lines = OldText.split('\n');
var DebutModele = '';
var SuiteModele = '';
var FoundInterwiki = false;
for (var lineId = lines.length - 1; lineId >= 0; --lineId){
if (!interWiki.exec(lines[lineId]) && !blank.exec(lines[lineId])){
DebutModele = lines.slice(0, lineId + 1).join('\n');
SuiteModele = lines.slice(lineId + 1).join('\n');
break;
}
}
SuiteModele = SuiteModele.replace(/^\n/, "");
OldText = DebutModele+ '\n\n' + NewDefaultSort + '\n' + SuiteModele;
}else{
var lastindex = (re.lastIndex);
var compile = re.compile(re);
var FirstCat = re.exec(OldText).toString();
FirstCat = FirstCat.replace(/\n/g, "");
var Before = OldText.substring(0, lastindex).replace(FirstCat, "");
var After = FirstCat+OldText.substring(lastindex)
OldText = Before + NewDefaultSort + After;
}
summary.push ("; + " + NewDefaultSort ) ;
}
}
var cat = new RegExp("\\[\\[(?:"+lrcGetNamespaceName(14)+"|Category):[^\\]]+\\]\\]", "ig");
var NoCatTemplate = LiveRC_getHotCatsVariables("HC_NoCatTemplate");
var nocat1 = "{{"+NoCatTemplate.ucFirst()+"}}\n";
var nocat1Bis = "{{"+NoCatTemplate.lcFirst()+"}}\n";
var nocat2 = "{{"+NoCatTemplate.ucFirst()+"}}";
var nocat2Bis = "{{"+NoCatTemplate.lcFirst()+"}}";
if(cat.exec(OldText) != null){
OldText = OldText.split(nocat1).join("");
OldText = OldText.split(nocat1Bis).join("");
OldText = OldText.split(nocat2).join("");
OldText = OldText.split(nocat2Bis).join("");
}
var Summary = lrcMakeText("RESUMESTART") + lrcMakeText("HC_ResumeScript") + summary.join("");
var IsMinor = LiveRC_Config["HotCats"]["MinorEditStatus"];
var MinorEditCheckBox = getElementWithId("wpMinoredit", "input", Preview);
var MustWatchthis = LiveRC_Config["HotCats"]["WatchStatus"];
var WathThisCheckBox = getElementWithId("wpWatchthis", "input", Preview);
getElementWithId("wpTextbox1", "textarea", Preview).value = OldText;
getElementWithId("wpSummary", "input", Preview).value = Summary;
if(IsMinor==="1") MinorEditCheckBox.checked = true;
if(IsMinor==="0") MinorEditCheckBox.checked = false;
if(MustWatchthis=="watch") WathThisCheckBox.checked = true;
if(MustWatchthis=="unwatch") WathThisCheckBox.checked = false;
if(MustWatchthis=="nochange") WathThisCheckBox.checked = !!(LiveRC_Config["Suivi"][LiveRC_Config["HotCats"]["CurrentPage"]]);
if((LiveRC_getHotCatsVariables("HC_autocommit"))&&(prevent_autocommit != 1)){
var Input = getElementWithId("Live_wpSave", "input", Preview);
if(Input){
var Params = getFormParams(Preview);
var EditParam = new Array();
EditParam["token"] = document.getElementsByName("wpEditToken")[0].value;
EditParam["text"] = OldText;
EditParam["summary"] = Summary;
EditParam["title"] = LiveRC_Config["HotCats"]["CurrentPage"];
EditParam["watchlist"] = LiveRC_Config["HotCats"]["WatchStatus"];
EditParam[((MinorEditCheckBox.checked ? "" : "not")+"minor")] = "1";
EditParam["nocreate"] = "1";
var ParamsInURL = new Array();
for(var P in EditParam){
if(typeof(EditParam[P])=="string") ParamsInURL.push(P+"="+encodeURIComponent(EditParam[P]));
}
ParamsInURL = ParamsInURL.join("&")+"&wpSave=1";
var action = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=edit';
var headers = new Array();
headers['Content-Type'] = 'application/x-www-form-urlencoded';
wpajax.http({ url: action,
method: "POST",
headers: headers,
data: ParamsInURL,
onSuccess:lrcHotCats_EditDone,
page:EditParam["title"]
});
}else{
prevent_autocommit = 1;
}
}
if(prevent_autocommit == 1) getElementWithId("editform", "form", Preview).style.display = "";
LiveRC_Config["HotCats"]["IsEditMode"] = false;
}
LiveRC_AddHook("AfterPreviewEdit", lrcHotCats_DoEdit);
function lrcHotCats_EditDone(Req, data){
var Page = data.page;
liveArticle(Page);
}
///////////////////////// SUGGESTIONS ////////////////////////////////////////////////////////
// REQUÊTE DE SUGGESTIONS
function lrcHotCatsText_changed (FormIndex, Mode, titles, catContinue) {
if ( LiveRC_Config["HotCats"]["suggest_running"] ) return ;
if(!Mode) Mode = false;
if((!FormIndex)||(FormIndex=="")) FormIndex = "0";
if(!titles) titles = new Array () ;
if(!catContinue) catContinue = "";
var text = LiveRC_Config["HotCats"]["Matrix"].Text[FormIndex];
if(!text){LiveRC_alert('PB lrcHotCatsText_changed () : ' + FormIndex); return; }
var v = (LiveRC_Config["HotCats"]["CaseSensitive"] ? text.value : text.value.ucFirst());
if(v.indexOf("|")!=-1) v = v.split("|")[0];
var APILimit = ( ((mw.config.get('wgUserGroups').indexOf("sysop")!=-1)||(mw.config.get('wgUserGroups').indexOf("bot")!=-1)) ? 4999 : 499 );
if(LiveRC_getHotCatsVariables("HC_list_items")>APILimit) lrcHotCatsVariables_Custom.list_items = APILimit; // API max
if(Mode=="UP"){ // Suggestions catégories-mères
var URL = "/api.php?format=xml&action=query&prop=categories&titles=" + lrcGetNamespaceName(14)+':'+encodeURIComponent(v) + "&cllimit=" + LiveRC_getHotCatsVariables("HC_list_items");
var TagName = "cl";
var Replace = false;
}else if(Mode=="DOWN"){ // Suggestions catégories-filles
var URL = "/api.php?format=xml&action=query&list=categorymembers&cmnamespace=14&cmtitle=" + lrcGetNamespaceName(14)+':'+encodeURIComponent(v) + "&cmlimit=" + APILimit + catContinue;
var TagName = "cm";
var Replace = false;
}else{ // Suggestions normales
var URL = "/api.php?format=xml&action=query&list=allpages&apnamespace=14&apfrom=" + encodeURIComponent(v) + "&aplimit=" + LiveRC_getHotCatsVariables("HC_list_items");
var TagName = "p";
var Replace = true;
}
LiveRC_Config["HotCats"]["suggest_running"] = 1 ;
if ( v != "" ) {
if ( typeof ( lrcHotCats_xmlhttp ) != "undefined" ) lrcHotCats_xmlhttp.abort() ;
lrcHotCats_xmlhttp = new XMLHttpRequest() ;
lrcHotCats_xmlhttp.open('GET', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + URL, true);
lrcHotCats_xmlhttp.onreadystatechange = function () {
if ( typeof lrcHotCats_xmlhttp == "undefined" ) return ;
if (lrcHotCats_xmlhttp.readyState == 4) {
var xml = lrcHotCats_xmlhttp.responseXML ;
if ( xml == null ) return ;
var pages = xml.getElementsByTagName( TagName ) ;
for ( var i = 0 ; i < pages.length ; i++ ) {
var s = pages[i].getAttribute("title");
if(s.indexOf(lrcGetNamespaceName(14)+':')!=-1){
s = s.split(lrcGetNamespaceName(14)+':').join('');
titles.push ( s ) ;
}
}
var CanContinue = xml.getElementsByTagName("query-continue")[0];
if(Mode=="DOWN"&&CanContinue){
CanContinueId = "&cmcontinue="+encodeURIComponent(CanContinue.firstChild.getAttribute("cmcontinue"));
LiveRC_Config["HotCats"]["suggest_running"] = 0 ;
lrcHotCatsText_changed(FormIndex, Mode, titles ,CanContinueId) ;
}else{
lrcHotCats_show_suggestions(titles, FormIndex, Replace);
}
}
};
lrcHotCats_xmlhttp.send(null);
} else {
lrcHotCats_show_suggestions ( titles , FormIndex, Replace ) ;
}
LiveRC_Config["HotCats"]["suggest_running"] = 0 ;
}
// AFFICHAGE DES SUGGESTIONS
function lrcHotCats_show_suggestions ( titles, FormIndex, Replace, Mode ) {
var text = LiveRC_Config["HotCats"]["Matrix"].Text[FormIndex] ;
var list = LiveRC_Config["HotCats"]["Matrix"].List[FormIndex] ;
var icon = LiveRC_Config["HotCats"]["Matrix"].Exist[FormIndex] ;
if((!text)||(!list)||(!icon)) { LiveRC_alert('PB lrcHotCats_show_suggestions() : ' + FormIndex); return; }
if(titles.length==0){
list.style.display = "none" ;
if(Replace){
icon.innerHTML = lrcMakeIcon("SuggestNoExistIcon").split("$1").join("").split(" ").join(" ");
}
return ;
}
var TailleListe = LiveRC_getHotCatsVariables("HC_list_size");
if (titles.length < TailleListe ) TailleListe = titles.length;
var listh = TailleListe * 20 ;
list.size = TailleListe ;
list.style.align = "left" ;
list.style.zIndex = 5 ;
list.style.position = "relative" ;
list.style.width = text.offsetWidth + "px" ;
list.style.height = listh + "px" ;
if (LiveRC_getHotCatsVariables("HC_list_down")) {
list.style.top = parseInt(text.offsetHeight) + "px";
list.style.marginBottom = "-" + ((TailleListe * 20) + parseInt(text.offsetHeight)) + "px" ;
}else{
list.style.marginTop = "-" + (TailleListe * 20) + "px" ;
}
list.style.marginLeft = "-" + text.offsetWidth + "px" ;
while ( list.firstChild ) list.removeChild ( list.firstChild ) ;
for ( var i = 0 ; i < titles.length ; i++ ) {
var opt = document.createElement ( "option" ) ;
var ot = document.createTextNode ( titles[i] ) ;
opt.appendChild ( ot ) ;
opt.value = titles[i];
list.appendChild ( opt ) ;
}
list.onkeyup = lrcHotCats_KeypressedOnList;
list.style.display = "inline" ;
var first_title = titles.shift () ;
LiveRC_Config["HotCats"]["last_v"] = ( LiveRC_Config["HotCats"]["CaseSensitive"] ? text.value : text.value.ucFirst());
var last_v_Split = LiveRC_Config["HotCats"]["last_v"];
if(LiveRC_Config["HotCats"]["last_v"].indexOf('|')!=-1){
LiveRC_Config["HotCats"]["last_key"] = LiveRC_Config["HotCats"]["last_v"].substring(LiveRC_Config["HotCats"]["last_v"].indexOf("|"), LiveRC_Config["HotCats"]["last_v"].length);
last_v_Split = LiveRC_Config["HotCats"]["last_v"].split(LiveRC_Config["HotCats"]["last_key"]).join('');
}else{
LiveRC_Config["HotCats"]["last_key"] = "";
}
icon.innerHTML = lrcMakeIcon("SuggestExistIcon").split("$1").join(first_title).split(" ").join(" ") ;
if ( first_title == last_v_Split ) return ;
if(Replace){
var suggestion = first_title;
if(suggestion.indexOf(last_v_Split)==-1){
icon.innerHTML = lrcMakeIcon("SuggestNoExistIcon").split("$1").join(suggestion).split(" ").join(" ");
return;
}
text.value = suggestion + LiveRC_Config["HotCats"]["last_key"] ;
if (text.createTextRange) {
var ra = text.createTextRange();
ra.moveStart("character", LiveRC_Config["HotCats"]["last_v"].length);
ra.moveEnd("character", suggestion.length);
ra.select();
} else if( text.setSelectionRange ) {
text.setSelectionRange( LiveRC_Config["HotCats"]["last_v"].length, suggestion.length );
} else {
text.selectionStart = LiveRC_Config["HotCats"]["last_v"].length ;
text.selectionEnd = suggestion.length ;
}
}else{
list.focus()
}
}
// MISE A JOUR DE LA POSITION DES LISTES DE SUGGESTIONS
function lrcHotCats_upDate_FormPositions(){
var AllForms = document.getElementById('mw-normal-catlinks').getElementsByTagName('form');
for(var a=0;a<AllForms.length;a++){
if(AllForms[a].id == "lrcHotCats_modify_multi_form") continue;
if(AllForms[a].id == "lrcHotCats_form_Default") continue;
var ThisForm = AllForms[a];
var ThisSelect = ThisForm.getElementsByTagName('select')[0];
var Options = ThisSelect.getElementsByTagName('option');
var ThisInput = ThisForm.getElementsByTagName('input')[0];
var TailleListe = LiveRC_getHotCatsVariables("HC_list_size") * 20 ;
if (Options.length < LiveRC_getHotCatsVariables("HC_list_size")) {
TailleListe = Options.length * 20 ;
}
ThisSelect.style.position = "relative" ;
ThisSelect.style.width = ThisInput.offsetWidth + "px" ;
if (LiveRC_getHotCatsVariables("HC_list_down")) {
ThisSelect.style.top = parseInt(ThisInput.offsetHeight) + "px";
ThisSelect.style.marginBottom = "-" + ((TailleListe * 20) + parseInt(ThisInput.offsetHeight)) + "px" ;
}else{
ThisSelect.style.marginTop = "-" + (TailleListe * 20) + "px" ;
}
ThisSelect.style.marginLeft = "-" + ThisInput.offsetWidth + "px" ;
}
}
// SÉLECTION D'UNE SUGGESTION AU CLAVIER
function lrcHotCats_KeypressedOnList(e){
if (!e) var e = window.event;
if (e.keyCode != 13) return;
lrcHotCatsText_replace(lrcHotCats_getIndex(this))
}
// REMPLACEMENT DU CHAMP DE TEXTE PAR UNE SUGGESTION
function lrcHotCatsText_replace(Index){
var Text = LiveRC_Config["HotCats"]["Matrix"].Text[Index];
var TextValue = Text.value;
var List = LiveRC_Config["HotCats"]["Matrix"].List[Index];
var Options = List.getElementsByTagName('option');
for(var a=0;a<Options.length;a++){
if(Options[a].selected){
var ListValue = Options[a].value;
if(TextValue.indexOf('|')!=-1){
LiveRC_Config["HotCats"]["last_key"] = TextValue.substring(TextValue.indexOf("|"), TextValue.length);
}
Text.value = ListValue + LiveRC_Config["HotCats"]["last_key"];
lrcHotCatsText_changed(Index) ;
Text.focus();
return;
}
}
}
///////////////////////// DIVERS ////////////////////////////////////////////////////////
// RÉCUPÉRATION DU N° D'INDEX
function lrcHotCats_getIndex( Element ){
return parseInt(Element.id.replace(/[^0-9]/g, ""));
}
// GESTION {{PLURAL:}} (MESSAGES SYSTÈME)
function lrcHotCats_PLURAL(Text, Plural){
var PluralRegExp = new RegExp("\\{\\{PLURAL[^\\}]+\\}\\}", "ig")
var Matches = Text.match(PluralRegExp);
if(Matches!=null){
for(var b=0,m=Matches.length;b<m;b++){
var Match = Matches[b];
var Params = Match.split('}}').join('').split('|');
var Result = "";
if(Plural){
Result = Params[2];
}else{
Result = Params[1];
}
if(!Result) Result = "";
Text = Text.replace(Match, Result);
}
}
return Text;
}
// GESTION {{GENDER:}} (MESSAGES SYSTÈME)
function lrcHotCats_GENDER(Text, Gender){
var PluralRegExp = new RegExp("\\{\\{GENDER[^\\}]+\\}\\}", "ig")
var Matches = Text.match(PluralRegExp);
if(Matches!=null){
for(var b=0,m=Matches.length;b<m;b++){
var Match = Matches[b];
var Params = Match.split('}}').join('').split('|');
var Result = "";
if(Gender=="male"){
Result = Params[1];
}else if(Gender=="female"){
Result = Params[2];
}else{
Result = Params[3];
}
if(!Result) Result = "";
Text = Text.replace(Match, Result);
}
}
return Text;
}
// FONCTION : création RegExp
function lrcHotCats_CreateRegExp(Cat){
Cat = (LiveRC_Config["HotCats"]["CaseSensitive"] ? Cat : Cat.ucFirst() );
var CatRegExp = new RegExp("(\\s*)\\[\\[( |_)*(?:"+lrcGetNamespaceName(14)+"|Category)( |_)*:( |_)*" + Cat.replace(/([\\\^\$\*\+\?\.\|\{\}\[\]\(\)])/g, "\\$1")+"( |_)*(\\|[^\\]]*)?\\]\\]", "g");
return CatRegExp;
}
// PREMIÈRE LETTRE EN MAJUSCULE
String.prototype.ucFirst = function () {
return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
}
// PREMIÈRE LETTRE EN MINUSCULE
String.prototype.lcFirst = function () {
return this.substr(0,1).toLowerCase() + this.substr(1,this.length);
}
/* ************************************************************************************************************************************************ */
} // FIN IF
//</syntaxhighlight>