Utilisateur:Tarkuhal/common.js
Apparence
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.obtenir("LiveRC");
//Gadget DJ
var DJparam_sidebarlink = true;
importScript('Utilisateur:0x010C/script/DrapeauJaune.js');
//Avertit du niveau de vandalisme à l'arrivée sur wikipédia
//Crédits : Créé par [[Utilisateur:0x010C]] (adapté d'un précédent code de [[Utilisateur:Dr Brains]])
//Documentation : [[Utilisateur:0x010C/script#PopupVandalism.js]]
function PopVand_GetVand()
{
$.post(mw.config.get("wgScript"), { title: "Utilisateur:0x010C/script/PopupVandalism.js/box", action: "purge" }, function (Response)
{
if (PopVand_Mode == "text" || PopVand_Mode == "Text") {
PopVand_DisplayVandText(Response);
} else if (PopVand_Mode == "box" || PopVand_Mode == "Box") {
PopVand_DisplayVandBox(Response);
} else {
PopVand_DisplayVandText(Response);
PopVand_DisplayVandBox(Response);
}
});
}
function PopVand_DisplayVandBox(Response)
{
var Content = document.getElementById("content");
var Div = document.createElement('div');
Div.style.display = "none";
Content.insertBefore(Div, Content.firstChild);
Div.innerHTML = Response;
var box = Div.getElementsByClassName("ModeleBUtilisateur")[0];
Div.innerHTML = "";
Div.appendChild(box);
Div.style.display = "";
Div.setAttribute("style", "float:right;");
}
function PopVand_DisplayVandText(Response){
var li = document.createElement('li');
li.innerHTML = Response;
var lvl = li.getElementsByClassName("ModeleBUtilisateurImgTexte")[0].getElementsByTagName("b")[0].innerHTML;
li.innerHTML = "";
li.style.display = "";
var spancolor;
if(PopVand_Color === true)
{
switch(lvl)
{
case "1":
spancolor = '<span style="color:white;background:red;">';
break;
case "2":
spancolor = '<span style="color:red;">';
break;
case "3":
spancolor = '<span style="color:orange;">';
break;
case "4":
spancolor = '<span style="color:green;">';
break;
case "5":
spancolor = '<span style="color:blue;">';
break;
}
}
else
spancolor = '<span>';
li.innerHTML = '<a href="/wiki/Modèle:Alerte_vandalisme" title="Alerte vandalisme">' + spancolor + 'Vandalisme ' + lvl + '</span></a>';
document.getElementById("p-navigation").getElementsByTagName("ul")[0].appendChild(li);
}
if (typeof PopVand_Mode == "undefined") {
var PopVand_Mode = "both";
}
if (typeof PopVand_Color == "undefined") {
var PopVand_Color = true;
}
$(PopVand_GetVand);
/**
* Outils pour réverter
*
* fournit des liens dans les pages de diff pour révoquer facilement une modification et avertir son auteur
*
* Auteurs : Lorian (en), Chphe (fr)
* Dernière révision : 28 octobre 2018
* {{Projet:JavaScript/Script|RevertDiff}}
*/
//<nowiki>
mw.loader.using('mediawiki.util', function () {
$(function ($) {
var Texts = {
Annul : 'Annuler',
Revert : 'Révoquer',
Message : 'Message',
Warn : 'Avertir',
MessageAlert : 'Quel message faut-il laisser ?',
AnnulResume : 'Annulation des modifications de [[Special:Contributions/$2|$2]] (retour à la version précédente de [[Special:Contributions/$1|$1]])',
RevertResume : 'Révocation des modifications de [[Special:Contributions/$2|$2]] (retour à la version précédente de [[Special:Contributions/$1|$1]])',
};
var Warns = [
{text: 'Test1', template: '{{subst:Test 1|$page}} ~~~~'},
{text: 'Test2', template: '{{subst:Test 2}} ~~~~'},
{text: 'Test3', template: '{{subst:Test 3}} ~~~~'},
{text: 'Test4', template: '{{subst:Seul avertissement}} ~~~~'},
{text: 'Lien externe', template: '{{subst:Bienvenue spammeur|$page}} ~~~~'},
{text: 'Faut sourcer', template: '{{subst:Faut sourcer|$page}} ~~~~'},
{text: 'Bienvenue', template: '{{Bienvenue nouveau|sign=~~~~}}'},
{text: 'BienvenueIP', template: '{{subst:Bienvenue IP}} ~~~~'},
{text: 'MerciIP', template: '{{Bienvenue IP méritante|sign=~~~~}}'},
];
function isDiffPage() {
return !!mw.config.get('wgDiffNewId');
}
function processAnnulOrRevert(oldid, action, user1, user2, withMessage) {
var params = {
action: 'edit',
oldid: oldid,
revertdiff_action: action,
revertdiff_user1: user1,
revertdiff_user2: user2,
};
if (withMessage) {
var message = prompt(Texts.MessageAlert);
if (message) {
params.revertdiff_message = message;
} else {
return;
}
}
window.location = mw.util.getUrl(null, params);
}
function submitOldRevision(summaryTemplate) {
var summary = summaryTemplate
.split('$1').join(mw.util.getParamValue('revertdiff_user1'))
.split('$2').join(mw.util.getParamValue('revertdiff_user2'));
var message = mw.util.getParamValue('revertdiff_message');
if (message) {
summary += '\xA0: ' + message;
}
document.getElementById('wpSummary').value = summary;
document.getElementById('editform').submit();
}
if (isDiffPage()) {
// Get username of submitter
var $user1TD = $('td.diff-otitle');
var $user2TD = $('td.diff-ntitle');
if (!$user1TD.length || !$user2TD.length) return;
// Récupération du oldid de la version à rétablir
var chemin = $user1TD.find('span.mw-diff-edit a').attr('href');
var oldid = mw.util.getParamValue('oldid', chemin);
var user1 = $user1TD.find('a.mw-userlink').text();
var user2 = $user2TD.find('a.mw-userlink').text();
var $linkAnnulDirect = $('<a>')
.attr('href', '#')
.text(Texts.Annul)
.click(function (e) {
e.preventDefault();
processAnnulOrRevert(oldid, 'annul', user1, user2, false);
});
var $linkAnnulMessage = $('<a>')
.attr('href', '#')
.text(Texts.Message)
.click(function (e) {
e.preventDefault();
processAnnulOrRevert(oldid, 'annul', user1, user2, true);
});
var $linkRevertDirect = $('<a>')
.attr('href', '#')
.text(Texts.Revert)
.click(function (e) {
e.preventDefault();
processAnnulOrRevert(oldid, 'revert', user1, user2, false);
});
var $linkRevertMessage = $('<a>')
.attr('href', '#')
.text(Texts.Message)
.click(function (e) {
e.preventDefault();
processAnnulOrRevert(oldid, 'revert', user1, user2, true);
});
var $links = $('<span>');
$links.append('(', $linkAnnulDirect, ' / ', $linkAnnulMessage, ') (', $linkRevertDirect, ' / ', $linkRevertMessage, ')');
$links.append(' (' + Texts.Warn + ' : ');
Warns.forEach(function (Warn, index) {
if (index !== 0) {
$links.append(' / ');
}
var href = mw.util.getUrl('User_talk:' + user2, {
action: 'edit',
section: 'new',
revertdiff_action: 'warn',
revertdiff_warn: index,
revertdiff_src: mw.config.get('wgPageName'),
});
var $linkWarn = $('<a>')
.attr('href', href)
.attr('title', Warn.template)
.text(Warn.text);
$links.append($linkWarn);
});
$links.append(')');
$('#contentSub').append($links);
} else {
var action = mw.util.getParamValue('revertdiff_action');
if (action) {
if (action === 'annul') {
submitOldRevision(Texts.AnnulResume);
} else if (action === 'revert') {
submitOldRevision(Texts.RevertResume);
} else if (action === 'warn') {
var warnIndex = mw.util.getParamValue('revertdiff_warn');
if (warnIndex && Warns[warnIndex]) {
var Template = Warns[warnIndex].template;
Template = Template.split('$page').join(mw.util.getParamValue('revertdiff_src').replace(/_/g, ' '));
Template = Template.split('$user').join(mw.config.get('wgUserName'));
document.getElementById('wpTextbox1').value = Template;
document.getElementById('editform').submit();
}
}
}
}
});
});
//</nowiki>
/* *************************************************************************************************************************** */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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'avoir une barre d'outils lors d'une modification
* Licence : ...?
* Documentation :
* Auteur : [[:fr:User:Dr Brains]]
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if (typeof(LiveRC_AddHook)==="function") { // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("ToolbarExtension");
/* ************************************************************************************************************************************************ */
window.Custom_lrcEditToolBarSetup = [];
window.lrcEditToolBarSetup = [
{ iconid : "ToolbarIcon_bold", before : "'''", sampletext : "", after : "'''"},
{ iconid : "ToolbarIcon_italic", before : "''", sampletext : "", after : "''"},
{ iconid : "ToolbarIcon_underline", before : "<u>", sampletext : "", after : "</u>"},
{ iconid : "ToolbarIcon_strike", before : "<s>", sampletext : "", after : "</s>"},
{ iconid : "ToolbarIcon_sup", before : "<sup>", sampletext : "", after : "</sup>"},
{ iconid : "ToolbarIcon_sub", before : "<sub>", sampletext : "", after : "</sub>"},
{ iconid : "ToolbarIcon_big", before : "<big>", sampletext : "", after : "</big>"},
{ iconid : "ToolbarIcon_small", before : "", sampletext : "", after : ""},
{ iconid : "ToolbarIcon_headline2", before : "== ", sampletext : "", after : " =="},
{ iconid : "ToolbarIcon_headline3", before : "=== ", sampletext : "", after : " ==="},
{ iconid : "ToolbarIcon_headline4", before : "==== ", sampletext : "", after : " ===="},
{ iconid : "ToolbarIcon_headline5", before : "===== ", sampletext : "", after : " ====="},
{ iconid : "ToolbarIcon_link", before : "[[", sampletext : "", after : "]]"},
{ iconid : "ToolbarIcon_extlink", before : "[", sampletext : "", after : "]"},
{ iconid : "ToolbarIcon_category", before : "[[Category:", sampletext : "", after : "]]"},
{ iconid : "ToolbarIcon_template", before : "{{", sampletext : "", after : "}}"},
{ iconid : "ToolbarIcon_comment", before : "<!-- ", sampletext : "", after : " -->"},
{ iconid : "ToolbarIcon_enum", before : "\n# élément 1\n# élément 2\n# élément 3", sampletext : "", after : ""},
{ iconid : "ToolbarIcon_list", before : '\n* élément A\n* élément B\n* élément C', sampletext : "", after : ""},
{ iconid : "ToolbarIcon_image", before : "[[File:", sampletext : "Exemple.jpg", after : "|thumb|Description.]]"},
{ iconid : "ToolbarIcon_media", before : "[[File:", sampletext : "Exemple.ogg", after : "|thumb|Description.]]"},
{ iconid : "ToolbarIcon_gallery", before : "\n<gallery>\nExemple.jpg|[[Tournesol]]\nExemple1.jpg|[[La Joconde]]\nExemple2.jpg|Un [[hamster]]\n</gallery>\n", sampletext : "", after : ""},
{ iconid : "ToolbarIcon_math", before : "<math>", sampletext : "\\rho=\\sqrt{x_0^2+y_0^2}", after : "</math>"},
{ iconid : "ToolbarIcon_nowiki", before : "<nowiki"+">", sampletext : "", after : "</nowiki"+">"},
{ iconid : "ToolbarIcon_sign", before : "-- ~~"+"~~", sampletext : "", after : ""},
{ iconid : "ToolbarIcon_hr", before : "--"+"--", sampletext : "", after : ""},
{ iconid : "ToolbarIcon_br", before : "<br>", sampletext : "", after : ""},
{ iconid : "ToolbarIcon_redirect", before : "#REDIRECT[[", sampletext : "", after : "]]"},
{ iconid : "ToolbarIcon_table", before : "{| class=\"wikitable\"\n", sampletext : "|-\n! titre 1\n! titre 2\n! titre 3\n|-\n| rangée 1, case 1\n| rangée 1, case 2\n| rangée 1, case 3\n|-\n| rangée 2, case 1\n| rangée 2, case 2\n| rangée 2, case 3", after : "\n|}"},
{ iconid : "ToolbarIcon_ref", before : "<ref>", sampletext : "", after : "</ref>"},
{ iconid : "ToolbarIcon_references", before : "<references />", sampletext : "", after : ""}
];
// Icônes
lrcIcons["ToolbarIcon_bold"] = {
type:0,
src:"e/e2/Button_bold.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_italic"] = {
type:0,
src:"1/1d/Button_italic.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_underline"] = {
type:0,
src:"f/fd/Button_underline.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_strike"] = {
type:0,
src:"3/30/Btn_toolbar_rayer.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_sup"] = {
type:0,
src:"6/6a/Button_sup_letter.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_sub"] = {
type:0,
src:"a/aa/Button_sub_letter.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_big"] = {
type:0,
src:"8/89/Button_bigger.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_small"] = {
type:0,
src:"0/0d/Button_smaller.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_headline2"] = {
type:0,
src:"7/78/Button_head_A2.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_headline3"] = {
type:0,
src:"4/4f/Button_head_A3.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_headline4"] = {
type:0,
src:"1/14/Button_head_A4.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_headline5"] = {
type:0,
src:"8/8c/Button_head_A5.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_link"] = {
type:0,
src:"c/c0/Button_link.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_extlink"] = {
type:0,
src:"e/ec/Button_extlink.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_category"] = {
type:0,
src:"b/b4/Button_category03.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_template"] = {
type:0,
src:"3/3b/Button_template_alt.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_comment"] = {
type:0,
src:"1/1b/Button_hide_wiki_tag.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_enum"] = {
type:0,
src:"8/88/Btn_toolbar_enum.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_list"] = {
type:0,
src:"1/11/Btn_toolbar_liste.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_image"] = {
type:0,
src:"d/de/Button_image.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_media"] = {
type:0,
src:"1/19/Button_media.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_gallery"] = {
type:0,
src:"9/9e/Btn_toolbar_gallery.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_math"] = {
type:0,
src:"5/5b/Math_icon.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_nowiki"] = {
type:0,
src:"8/82/Nowiki_icon.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_sign"] = {
type:0,
src:"6/6d/Button_sig.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_hr"] = {
type:0,
src:"0/0d/Button_hr.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_br"] = {
type:0,
src:"1/13/Button_enter.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_redirect"] = {
type:0,
src:"c/c8/Button_redirect.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_table"] = {
type:0,
src:"0/04/Button_array.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_ref"] = {
type:0,
src:"c/c4/Button_ref.png",
width:23,
height:23
};
lrcIcons["ToolbarIcon_references"] = {
type:0,
src:"6/64/Buttonrefvs8.png",
width:23,
height:23
};
// Textes
lrcTexts["ToolbarIcon_bold_title"] = "Texte en gras";
lrcTexts["ToolbarIcon_italic_title"] = "Texte en italique";
lrcTexts["ToolbarIcon_underline_title"] = "Texte souligné";
lrcTexts["ToolbarIcon_strike_title"] = "Texte barré";
lrcTexts["ToolbarIcon_sup_title"] = "Texte en exposant";
lrcTexts["ToolbarIcon_sub_title"] = "Texte en indice";
lrcTexts["ToolbarIcon_big_title"] = "Texte en grand";
lrcTexts["ToolbarIcon_small_title"] = "Texte en petit";
lrcTexts["ToolbarIcon_headline2_title"] = "Chapitre de niveau 2";
lrcTexts["ToolbarIcon_headline3_title"] = "Chapitre de niveau 3";
lrcTexts["ToolbarIcon_headline4_title"] = "Chapitre de niveau 4";
lrcTexts["ToolbarIcon_headline5_title"] = "Chapitre de niveau 5";
lrcTexts["ToolbarIcon_link_title"] = "Lien interne";
lrcTexts["ToolbarIcon_extlink_title"] = "Lien externe";
lrcTexts["ToolbarIcon_category_title"] = "Catégorie";
lrcTexts["ToolbarIcon_template_title"] = "Modèle";
lrcTexts["ToolbarIcon_comment_title"] = "Commentaire caché";
lrcTexts["ToolbarIcon_enum_title"] = "Énumération";
lrcTexts["ToolbarIcon_list_title"] = "Liste";
lrcTexts["ToolbarIcon_image_title"] = "Image";
lrcTexts["ToolbarIcon_media_title"] = "Média";
lrcTexts["ToolbarIcon_gallery_title"] = "Galerie d'images";
lrcTexts["ToolbarIcon_math_title"] = "Expression mathématique (format LaTeX)";
lrcTexts["ToolbarIcon_nowiki_title"] = "Ignorer le format wiki";
lrcTexts["ToolbarIcon_sign_title"] = "Signature datée";
lrcTexts["ToolbarIcon_hr_title"] = "Ligne horizontale";
lrcTexts["ToolbarIcon_br_title"] = "Saut de ligne";
lrcTexts["ToolbarIcon_redirect_title"] = "Redirection";
lrcTexts["ToolbarIcon_table_title"] = "Tableau";
lrcTexts["ToolbarIcon_ref_title"] = "Référence";
lrcTexts["ToolbarIcon_references_title"] = "Index des références";
lrcTexts["ToolbarIconStandardDesc"] = "[Toolbar] « $1 »";
lrcTexts["ToolbarIconTooltipStandardDesc"] = "[Toolbar] Infobulle du bouton « $1 »";
lrcParamDesc['DesclrcEditToolBarSetup'] = 'Paramètres de l’extension Toolbar';
lrcParamDesc['DesclrcEditToolBarSetup_short'] = 'Toolbar';
lrcParamDesc['DescToolbarIconStandardDesc'] = '[Toolbar] Description standard d’un bouton';
lrcParamDesc['DescToolbarIconTooltipStandardDesc'] = '[Toolbar] Description standard d’une infobulle de bouton';
lstParamMenuTabs["lrcEditToolBarSetup"] = true;
window.ToolbarExtension_Preprocess = function(){
var buttons = Custom_lrcEditToolBarSetup;
if(!buttons || buttons.length===0) buttons = lrcEditToolBarSetup;
for(var a=0,l=buttons.length;a<l;a++){
var ID = buttons[a].iconid;
var Tooltip = lrcMakeText((ID+"_title"));
lrcParamDesc[('Desc'+ID)] = lrcMakeText("ToolbarIconStandardDesc").split("$1").join(Tooltip);
lrcParamDesc[('Desc'+ID+"_title")] = lrcMakeText("ToolbarIconTooltipStandardDesc").split("$1").join(Tooltip);
}
}
window.ToolbarExtension_Init = function(){
var preview = document.getElementById('livePreview');
if(!preview) return;
var TextBox = getElementWithId("wpTextbox1", 'textarea', preview);
if(!TextBox) return;
var Toolbar = getElementWithId("LiveRC_EditToolBar", 'div', preview);
if(!Toolbar){
Toolbar = document.createElement('div');
Toolbar.id = "LiveRC_EditToolBar";
TextBox.parentNode.insertBefore(Toolbar, TextBox);
}
var buttons = Custom_lrcEditToolBarSetup;
if(!buttons || buttons.length===0) buttons = lrcEditToolBarSetup;
for(var a=0,l=buttons.length;a<l;a++){
var ThisButton = buttons[a]
var ID = ThisButton.iconid;
var Link = document.createElement('a');
Link.innerHTML = lrcMakeIcon(ID);
Link.id = ID+"_LINK";
Link.href = "javascript:;";
Link.onclick = function(){
ToolbarExtension_InsertTag(this);
}
Toolbar.appendChild(Link);
}
}
window.ToolbarExtension_InsertTag = function(Link){
if(!Link) return;
var ID = Link.id;
if(!ID) return;
ID = ID.split("_LINK").join("");
var buttons = Custom_lrcEditToolBarSetup;
if(!buttons || buttons.length==0) buttons = lrcEditToolBarSetup;
for(var a=0,l=buttons.length;a<l;a++){
var ThisButton = buttons[a];
var ThisButtonID = ThisButton.iconid;
if(ThisButtonID !== ID) continue;
ToolbarExtension_ReallyInsertTag(ThisButton);
return false;
}
return false;
}
window.ToolbarExtension_ReallyInsertTag = function(ThisButton){
var iconid = ThisButton.iconid;
var tagOpen = ThisButton.before;
var sampleText = ThisButton.sampletext;
var tagClose = ThisButton.after;
var preview = document.getElementById('livePreview');
if(!preview) return;
var TextBox = getElementWithId("wpTextbox1", 'textarea', preview);
if(!TextBox) return;
function ToolbarExtension_checkSelectedText(){
if(!selText) {
selText = sampleText;
isSample = true;
}else if(selText.charAt(selText.length - 1) == ' ') { //exclude ending space char
selText = selText.substring(0, selText.length - 1);
tagClose += ' ';
}
}
var selText, isSample = false;
var winScroll = TextBox.scrollTop;
TextBox.focus();
if(document.selection && document.selection.createRange){
var range = document.selection.createRange();
selText = range.text;
ToolbarExtension_checkSelectedText();
range.text = tagOpen + selText + tagClose;
if(isSample && range.moveStart) {
if(window.opera) tagClose = tagClose.replace(/\n/g,'');
range.moveStart('character', - tagClose.length - selText.length);
range.moveEnd('character', - tagClose.length);
}
range.select();
}else if(TextBox.selectionStart || TextBox.selectionStart == '0'){
var startPos = TextBox.selectionStart;
var endPos = TextBox.selectionEnd;
selText = TextBox.value.substring(startPos, endPos);
ToolbarExtension_checkSelectedText();
TextBox.value = TextBox.value.substring(0, startPos) + tagOpen + selText + tagClose + TextBox.value.substring(endPos, TextBox.value.length);
}
TextBox.scrollTop = winScroll;
return false;
}
LiveRC_AddHook("BeforeInitActivationProcess", ToolbarExtension_Preprocess);
LiveRC_AddHook("AfterPreviewEdit", ToolbarExtension_Init);
LiveRC_AddHook("AfterFillParamPanel", function(){
LiveRC_ManageParams_Fill(lrcEditToolBarSetup, "lrcEditToolBarSetup", false, true);
});
window.ToolbarExtension_TransformOptions = function(){
var Fieldset = document.getElementById("LiveRC_OptionsContent_lrcEditToolBarSetup");
if(!Fieldset) return;
var Lis = Fieldset.getElementsByTagName('li');
for(var a=0,l=Lis.length;a<l;a++){
var Li = Lis[a];
var ThisItemName = false;
var Inputs = Li.getElementsByTagName('input');
for(var b=0,m=Inputs.length;b<m;b++){
if(Inputs[b].name === "iconid") ThisItemName = Inputs[b].value;
}
if(!ThisItemName) continue;
var Label = document.createElement('label');
lrcAddClass(Label, "lrcIcons_Label");
Label.innerHTML = lrcMakeText(ThisItemName+"_title");
Li.appendChild(document.createTextNode(" : "));
Li.appendChild(Label);
var DeleteLink = Li.getElementsByTagName('a')[0];
DeleteLink.parentNode.removeChild(DeleteLink);
Li.insertBefore(document.createTextNode(" "), Li.firstChild);
Li.insertBefore(DeleteLink, Li.firstChild);
}
}
LiveRC_AddHook("AfterCreateParamPanel", ToolbarExtension_TransformOptions);
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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 de marquer les utilisateurs ayant reçu un avertissement sur leur page de discussion.
* Licence : CC0
* Documentation :
* Auteur : [[:fr:User:Orlodrim]]
* Développement et maintenance :
** [[:fr:User:Dr Brains]]
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if (typeof(LiveRC_AddHook)==="function") { // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("UserWarningsExtension");
/* ************************************************************************************************************************************************ */
// Paramètres
try{
lrcParams["lrcXUWShowEditcount"] = true;
lrcParams["lrcXUWShowWarnings"] = true;
lrcParams["lrcXUWDelayIP"] = 24;
lrcParams["lrcXUWDelay"] = 24;
lrcParams["lrcXUWColorNoTalk"] = "";
lrcParams["lrcXUWColorRecentTalk"] = "";
lrcParams["lrcXUWColorRecentWarning"] = "";
}catch(e){ }
// Icônes
try{
lrcIcons["EditCount0"] = {"type":0,
"src":"thumb/1/1b/Emblem-person-red.svg/16px-Emblem-person-red.svg.png",
"width":14,
"height":14
}
lrcIcons["EditCount1"] = {"type":0,
"src":"thumb/2/23/Emblem-person-orange.svg/16px-Emblem-person-orange.svg.png",
"width":14,
"height":14
}
lrcIcons["EditCount2"] = {"type":0,
"src":"thumb/f/f4/Emblem-person-yellow.svg/16px-Emblem-person-yellow.svg.png",
"width":14,
"height":14
}
lrcIcons["EditCount3"] = {"type":0,
"src":"thumb/0/06/Emblem-person-green.svg/16px-Emblem-person-green.svg.png",
"width":14,
"height":14
}
lrcIcons["SpamIcon"] = {"type":0,
"src":"9/92/LiveRC_Spam.png",
"width":14,
"height":14
}
lrcIcons["Test0Icon"] = {"type":0,
"src":"3/3b/LiveRC_Test0.png",
"width":14,
"height":14
}
lrcIcons["Test1Icon"] = {"type":0,
"src":"5/5d/LiveRC_Test1.png",
"width":14,
"height":14
}
lrcIcons["Test2Icon"] = {"type":0,
"src":"7/78/LiveRC_Test2.png",
"width":14,
"height":14
}
lrcIcons["Test3Icon"] = {"type":0,
"src":"7/7b/LiveRC_Test3.png",
"width":14,
"height":14
}
lrcIcons["SalebotIcon"] = {"type":0,
"src":"3/31/Salebot_small_icon.png",
"width":14,
"height":14
}
}catch(e){ }
// Textes
try{
lrcTexts["EditCount0_Title"] = "Editcount : $1";
lrcTexts["EditCount1_Title"] = "Editcount : $1";
lrcTexts["EditCount2_Title"] = "Editcount : $1";
lrcTexts["EditCount3_Title"] = "Editcount : $1";
lrcTexts["SpamIcon_Title"] = "Averti : spam";
lrcTexts["Test0Icon_Title"] = "Averti : test 0";
lrcTexts["Test1Icon_Title"] = "Averti : test 1";
lrcTexts["Test2Icon_Title"] = "Averti : test 2";
lrcTexts["Test3Icon_Title"] = "Averti : test 3";
lrcTexts["SalebotIcon_Title"] = "Révoqué par Salebot";
lrcTexts['lrcXUWRAZ_Title'] = 'Remettre le compteur d’avertissements à zéro';
lrcTexts['lrcXUWRAZ_Text'] = 'raz';
}catch(e){ }
// Descriptions
try{
lrcParamDesc['DesclrcUserWarningsMessages'] = 'Paramètres de l’extension UserWarnings';
lrcParamDesc['DesclrcUserWarningsMessages_short'] = 'UserWarnings';
lrcParamDesc["DesclrcXUWShowEditcount"] = "[UserWarnings] Afficher le compteur d’éditions (couteux)";
lrcParamDesc["DesclrcXUWShowWarnings"] = "[UserWarnings] Afficher les avertissements (couteux)";
lrcParamDesc['DesclrcXUWColorNoTalk'] = '[UserWarnings] Couleur du nom des utilisateurs sans page de discussion';
lrcParamDesc['DesclrcXUWColorRecentTalk'] = '[UserWarnings] Couleur du nom des utilisateurs avec message récent mais pas d’avertissement';
lrcParamDesc['DesclrcXUWColorRecentWarning'] = '[UserWarnings] Couleur du nom des utilisateurs avertis';
lrcParamDesc['DesclrcXUWDelayIP'] = '[UserWarnings] Délai en heures avant que les avertissements ne soient caducs (IP)';
lrcParamDesc['DesclrcXUWDelay'] = '[UserWarnings] Délai en heures avant que les avertissements ne soient caducs (utilisateur enregistré)';
lrcParamDesc['DesclrcXUWRAZ_Title'] = '[UserWarnings] Infobulle du lien de mise à zéro du compteur du nombre d’avertissements';
lrcParamDesc['DesclrcXUWRAZ_Text'] = '[UserWarnings] Texte du lien de mise à zéro du compteur du nombre d’avertissements';
lrcParamDesc['DescEditCount0'] = '[UserWarnings] Compteur d’éditions, niveau 0';
lrcParamDesc['DescEditCount1'] = '[UserWarnings] Compteur d’éditions, niveau 1';
lrcParamDesc['DescEditCount2'] = '[UserWarnings] Compteur d’éditions, niveau 2';
lrcParamDesc['DescEditCount3'] = '[UserWarnings] Compteur d’éditions, niveau 3';
lrcParamDesc['DescSpamIcon'] = '[UserWarnings] Averti : spam';
lrcParamDesc['DescTest0Icon'] = '[UserWarnings] Averti : test 0';
lrcParamDesc['DescTest1Icon'] = '[UserWarnings] Averti : test 1';
lrcParamDesc['DescTest2Icon'] = '[UserWarnings] Averti : test 2';
lrcParamDesc['DescTest3Icon'] = '[UserWarnings] Averti : test 3';
lrcParamDesc['DescSalebotIcon'] = '[UserWarnings] Révoqué par Salebot';
lrcParamDesc['DescEditCount0_Title'] = '[UserWarnings] Tooltip de l’icône Compteur d’éditions, niveau 0';
lrcParamDesc['DescEditCount1_Title'] = '[UserWarnings] Tooltip de l’icône Compteur d’éditions, niveau 1';
lrcParamDesc['DescEditCount2_Title'] = '[UserWarnings] Tooltip de l’icône Compteur d’éditions, niveau 2';
lrcParamDesc['DescEditCount3_Title'] = '[UserWarnings] Tooltip de l’icône Compteur d’éditions, niveau 3';
lrcParamDesc['DescSpamIcon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : spam';
lrcParamDesc['DescTest0Icon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : test 0';
lrcParamDesc['DescTest1Icon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : test 1';
lrcParamDesc['DescTest2Icon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : test 2';
lrcParamDesc['DescTest3Icon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : test 3';
lrcParamDesc['DescSalebotIcon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : Salebot';
}catch(e){ }
// Tests de commentaire
window.lrcUserWarningsMessages = [
{ image: "SpamIcon" , class: "RcUWSpam" , regex: /(S|s)pammeur/ },
{ image: "Test0Icon" , class: "RcUWTest0" , regex: /(T|t)est ?0/ },
{ image: "Test1Icon" , class: "RcUWTest1" , regex: /(T|t)est ?1/ },
{ image: "Test2Icon" , class: "RcUWTest2" , regex: /(T|t)est ?2/ },
{ image: "Test3Icon" , class: "RcUWTest3" , regex: /(T|t)est ?3/ },
{ image: "SalebotIcon" , class: "RcUWSalebot" , regex: /^bot : annonce de révocation/ }
];
window.lrcUserWarningsMessages_Custom = [];
window.Custom_lrcUserWarningsMessages = [];
// ============================ FIN DE LA PARTIE PERSONNALISABLE
LiveRC_Config["UserWarnings_rvend"] = {};
window.lrcXUWTwoDigits = function(i) {
return (i < 10 ? '0' : '') + i;
}
window.lrcXUWGetWikiDate = function(localDate) {
var d = new Date(localDate.getTime() + localDate.getTimezoneOffset() * 60 * 1000);
return '' + d.getFullYear() + lrcXUWTwoDigits(d.getMonth() + 1)
+ lrcXUWTwoDigits(d.getDate()) + lrcXUWTwoDigits(d.getHours())
+ lrcXUWTwoDigits(d.getMinutes()) + lrcXUWTwoDigits(d.getSeconds());
}
window.lrcXUWGetUserLink = function(tr1) {
var links = tr1.getElementsByTagName("td")[0].getElementsByTagName("a");
for (var i = links.length - 1; i >= 0; i--) {
if(lrcHasClass(links[i], "lrc_EditorLink")) return links[i];
}
return null;
}
window.lrcXUWHook = function(Args) {
var id = Args.id;
var tr1 = document.getElementById(id);
if (!tr1) return;
var rc = Args.rc;
var user = rc.user;
// talkpage comments request
if(lrcMakeParam("lrcXUWShowWarnings")){
var talkPage = lrcGetNamespaceName(3) + ':' + user;
lrcDisplayDebug("Get user talk page infos : " + talkPage);
var Delay = (UserIsIP(user) ? lrcMakeParam("lrcXUWDelayIP") : lrcMakeParam("lrcXUWDelay") );
var rvend = (LiveRC_Config["UserWarnings_rvend"][user] ? LiveRC_Config["UserWarnings_rvend"][user] : lrcXUWGetWikiDate(new Date(new Date() - (Delay * 3600000))));
var requestTalkPage = lrcGetAPIURL({format:'xml',action:'query',prop:'revisions',rvlimit:LiveRC_Config["UserInfos"].APIlimit,rvend:rvend,rvprop:'comment|timestamp',titles:talkPage,continue:''});
wpajax.http({url: requestTalkPage,
onSuccess: lrcTalkPageCallback,
user: user,
tr1id: id
});
}
// user infos request
if(lrcMakeParam("lrcXUWShowEditcount")){
lrcDisplayDebug("Get user groups & editcount : " + user);
if(UserIsIP(user)){
var requestIPContribs = lrcGetAPIURL({format:'xml',action:'query',list:'usercontribs',ucuserprefix:user,uclimit:LiveRC_Config["UserInfos"].APIlimit,continue:''});
wpajax.http({url: requestIPContribs,
onSuccess: lrcIPContribsCallback,
user: user,
tr1id: id,
contribs: 0
});
}else{
var requestUserInfos = lrcGetAPIURL({format:'xml',action:'query',list:'allusers',auprefix:user,aulimit:'1',auprop:'editcount|registration|groups',continue:''});
wpajax.http({url: requestUserInfos,
onSuccess: lrcUserInfosCallback,
user: user,
tr1id: id
});
}
}
}
window.lrcTalkPageCallback = function(xmlreq, data) {
var tr1 = document.getElementById(data.tr1id);
if (!tr1) return;
var lastLink = lrcXUWGetUserLink(tr1);
if(!lastLink) return;
var page = xmlreq.responseXML.getElementsByTagName('page')[0];
if (!page.getAttribute('pageid')) {
if (lrcMakeParam("lrcXUWColorNoTalk")) lastLink.style.color = lrcMakeParam("lrcXUWColorNoTalk");
return;
}
var revisions = xmlreq.responseXML.getElementsByTagName('rev');
if (revisions.length == 0) return;
var firstrevtimestamp = revisions[0].getAttribute("timestamp");
var warning = [];
var classes = [];
var XUWMessages = lrcUserWarningsMessages_Custom;
if(XUWMessages.length===0) XUWMessages = Custom_lrcUserWarningsMessages;
if(XUWMessages.length===0) XUWMessages = lrcUserWarningsMessages;
for(var i = 0, l=revisions.length; i < l; i++) {
var comment = revisions[i].getAttribute('comment');
if (!comment) continue;
for (var j = 0; j < XUWMessages.length; j++) {
if((XUWMessages[j].regex).test(comment.unhtmlize())){
warning.push(lrcMakeIcon(XUWMessages[j].image, {before:' '}));
classes.push(XUWMessages[j].class);
}
}
}
if(warning.length>0) {
var iconcontainer = document.createElement('span');
iconcontainer.className = "UserWarningsIcons";
lastLink.parentNode.insertBefore(iconcontainer, lastLink.nextSibling);
for(var a=0,l=warning.length;a<l;a++){
var icon = document.createElement('span');
icon.innerHTML = warning[a];
if(classes[a]) lrcAddClass(tr1, classes[a]);
iconcontainer.appendChild(icon);
}
iconcontainer.appendChild(lrcXUWrazwarningslink(data.user, firstrevtimestamp, iconcontainer));
if(lrcMakeParam("lrcXUWColorRecentWarning")) {
lastLink.style.color = lrcMakeParam("lrcXUWColorRecentWarning");
}
} else if(revisions.length > 0 && lrcMakeParam("lrcXUWColorRecentTalk")) {
lastLink.style.color = lrcMakeParam("lrcXUWColorRecentTalk");
}
}
window.lrcXUWrazwarningslink = function(user, firstrevtimestamp, iconcontainer){
var linksup = document.createElement('sup');
var link = document.createElement('a');
link.innerHTML = lrcMakeText('lrcXUWRAZ_Text');
link.title = lrcMakeText('lrcXUWRAZ_Title').split("$1").join(firstrevtimestamp);
link.href = "javascript:;";
link.onclick = function(){ lrcXUWrazwarnings(user, firstrevtimestamp, iconcontainer); }
linksup.appendChild(document.createTextNode(" "));
linksup.appendChild(link);
return linksup;
}
window.lrcXUWrazwarnings = function(user, firstrevtimestamp, iconcontainer){
LiveRC_Config["UserWarnings_rvend"][user] = (parseInt(firstrevtimestamp.replace(/\D/g, ""))+1);
iconcontainer.parentNode.removeChild(iconcontainer);
}
window.lrcUserInfosCallback = function(xmlreq, data){
var tr1 = document.getElementById(data.tr1id);
if (!tr1) return;
var td2 = tr1.getElementsByTagName("td")[0];
if(!td2) return;
var U = xmlreq.responseXML.getElementsByTagName('u')[0];
if(!U) return;
var username = U.getAttribute("name");
if(username != data.user) return;
var usereditcount = U.getAttribute("editcount");
var userregistration = U.getAttribute("registration");
var G = U.getElementsByTagName("g");
var usergroups = [];
for(var a=0,l=G.length;a<l;a++){
usergroups.push(G[a].firstChild.nodeValue);
}
var editcounticon = lrcMakeIcon("EditCount3", {after:' – '});
var usereditcount = parseInt(usereditcount, {after:' – '});
if(usereditcount<10){
editcounticon = lrcMakeIcon("EditCount0", {after:' – '});
}else if(usereditcount<50){
editcounticon = lrcMakeIcon("EditCount1", {after:' – '});
}else if(usereditcount<500){
editcounticon = lrcMakeIcon("EditCount2", {after:' – '});
}
editcounticon = editcounticon.split("$1").join(usereditcount);
var SpanEditcount = document.createElement('span');
SpanEditcount.innerHTML = editcounticon;
td2.insertBefore(SpanEditcount, td2.firstChild);
UpdateGroups(usergroups, tr1, username);
}
window.UpdateGroups = function(usergroups, tr1, username){
for(var group in LiveRC_Config["UserGroupList"]){
if(usergroups.indexOf(group)!=-1 && typeof(LiveRC_Config["UserGroupList"][group])==="object" && typeof(LiveRC_Config["UserGroupList"][group].list)==="object" && LiveRC_Config["UserGroupList"][group].list.indexOf(username) == -1){
LiveRC_Config["UserGroupList"][group].list.push(username);
lrcAddClass(tr1, lrcGetGroupClass(tr1, lrcGetGroupState(username, [])));
}
}
}
window.lrcIPContribsCallback = function(xmlreq, data){
var tr1 = document.getElementById(data.tr1id);
if (!tr1) return;
var lastLink = lrcXUWGetUserLink(tr1);
var td2 = tr1.getElementsByTagName("td")[0];
if(!lastLink || !td2) return;
var UContribs = xmlreq.responseXML.getElementsByTagName('usercontribs')[0];
if(!UContribs) return;
var Items = UContribs.getElementsByTagName('item');
var contribs = data.contribs + Items.length;
var othercontribs = UContribs.getElementsByTagName('continue')[0];
if(othercontribs){
var continueparam = othercontribs.getAttribute('uccontinue');
var requestIPContribs = lrcGetAPIURL({format:'xml',action:'query',list:'usercontribs',ucuserprefix:data.user,uclimit:LiveRC_Config["UserInfos"].APIlimit,uccontinue:continueparam,continue:''});
wpajax.http({url: requestIPContribs,
onSuccess: lrcIPContribsCallback,
user: data.user,
tr1id: data.id,
contribs: contribs
});
}else{
var editcounticon = lrcMakeIcon("EditCount3", {after:' – '});
if(contribs<10){
editcounticon = lrcMakeIcon("EditCount0", {after:' – '});
}else if(contribs<50){
editcounticon = lrcMakeIcon("EditCount1", {after:' – '});
}else if(contribs<500){
editcounticon = lrcMakeIcon("EditCount2", {after:' – '});
}
editcounticon = editcounticon.split("$1").join(contribs);
var SpanEditcount = document.createElement('span');
SpanEditcount.innerHTML = editcounticon;
td2.insertBefore(SpanEditcount, td2.firstChild);
}
}
LiveRC_AddHook("AfterRC", lrcXUWHook);
// Personnalisation auto
window.defineCustomUserWarningsMessages = function(UserWarningsMessages){
Custom_lrcUserWarningsMessages = UserWarningsMessages;
}
LiveRC_AddHook("AfterFillParamPanel", function(){
LiveRC_ManageParams_Fill(lrcUserWarningsMessages, "lrcUserWarningsMessages", "defineCustomUserWarningsMessages", true);
});
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>
/* Afficher les liens déjà visités en vert */
a:visited {
color:#09a245;
}
p
{
color:blue;
}
a
{
color:purple;
}
h1, h2, h3, h4, h5, h6
{
color:orange;
}
var AC_BlackList = new Array('LODGESEARCH', 'AUBRIANT', 'PUNKAHARJU44', 'KUNDERASEARCH'); //liste des users suivi
var AC_WhiteList = new Array('O Kolymbitès','Phso2','Konstantinos'); //liste des users de confiance
var AC_debugFlag=false; //infos de debogage (laisser à faux)
var AC_delayContrib=72; //en heure, jusqu'a quand on va chercher les contribs
var AC_includeFollowList=false; //si on inclut les articles de la liste de suivi
var AC_watchListLimit=5000; //limite de réponse de la requete de la liste de suivi
var AC_historyLimit =500; //limite de réponse de la requete de l'historique d'un article
var AC_userContribLimit=500; //limite de réponse de la requete des contributions d'un user
var AC_changeFollowListLink=false; //si true, change le lien 'liste de suivi' vers la page advancedContrib
var AC_blackListColor='#FFB0B0'; //la couleur de fond d'un user suivi en blacklist
var AC_whiteListColor='#B0B0FF'; //la couleur de fond d'un utilisateur de la whitelist
var AC_normalListColor='#B0FFB0'; //la couleur de fond d'un utilisateur non suivi
var AC_displayDeleteLink=false; //affiche un lien delete pour chaque article dans la liste (landry-mode)
var AC_displayWarnings=true; //affiche les warnings (souvent qd les limites sont atteintes)
function nouvelleBoite() {
var l = document.getElementById('column-one');
if (!l) return;
l.innerHTML = l.innerHTML
+ '<div class="portlet" id="p-nbx">'
+ ' <h5>Boîte perso</h5>'
+ ' <div class="pBody">'
+ ' <ul>'
+ ' <li><a href="/wiki/Portail:Grèce">Portail Grèce</a></li>'
+ ' <li><a href="/wiki/Portail:Îles">Portail Îles</a></li>'
+ ' <li><a href="/wiki/Portail:Empire ottoman">Portail Empire ottoman</a></li>'
+ ' <li><a href="/wiki/Portail:Crète">Portail Crète</a></li>'
+ ' <li><a href="/wiki/Utilisateur:O_Kolymbitès/Outils">Outils</a></li>'
+ ' <li><a href="/wiki/Utilisateur:O_Kolymbitès/Brouillon">Brouillon</a></li>'
+ ' <li><a href="/wiki/Utilisateur:O_Kolymbitès/Brouillon2">Brouillon2</a></li>'
+ ' <li><a href="/wiki/Utilisateur:O_Kolymbitès/Brouillon3">Brouillon3</a></li>'
+ ' <li><a href="/wiki/Wikipédia:Demande_de_restauration_de_page">Restauration</a></li>'
+ ' </ul>'
+ ' </div>'
+ '</div> ';
}
addOnloadHook(nouvelleBoite);
/*
--------------------------------------------------------------------------------------
---------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'insérer un bandeau d'article avec paramètres
* Licence : ...?
* Documentation :
* Auteur : [[:it:User:Jalo]] [[:it:User:Rotpunkt]], [[:fr:User:Dr Brains]]
*
* This script contains functions (InserisciTemplate_showDialog, InserisciTemplate_dumpTemplate and InserisciTemplate_buildInputEl)
* and formats (all template definitions) modified from:
* http://it.wikipedia.org/w/index.php?title=MediaWiki:Gadget-tb-base.js&oldid=66478020
* http://it.wikipedia.org/w/index.php?title=MediaWiki:Gadget-tb-* (for the templates)
* author Rotpunkt (http://it.wikipedia.org/wiki/Utente:Rotpunkt)
*
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
*/
//<source lang=javascript>
if(typeof(LiveRC_AddHook)==="function"){ // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("InserisciTemplate");
/* ************************************************************************************************************************************************ */
window.Custom_lstMyTemplate = {};
window.lstMyTemplate = {
'Ébauche': {
template:'Ébauche',
string:'Ébauche',
where:'top',
noinclude: false,
subst: false,
parameters: {
"1": {name: 'Thème 1', type: 'select'},
"2": {name: 'Thème 2', type: 'select'},
"3": {name: 'Thème 3', type: 'select'},
"4": {name: 'Thème 4', type: 'select'},
"5": {name: 'Thème 5', type: 'select'},
"6": {name: 'Thème 6', type: 'select'}
}
},
'À fusionner':{
template:'À fusionner',
string:'À fusionner',
where:'top',
noinclude: false,
subst: false,
parameters: {
"1": {name: 'Article 1', type: 'string'},
"2": {name: 'Article 2', type: 'string'},
"3": {name: 'Article 3', type: 'string'},
"4": {name: 'Article 4', type: 'string'},
"5": {name: 'Article 5', type: 'string'},
"6": {name: 'Article 6', type: 'string'},
"section FT": {name: 'Titre de section', type: 'string'}
}
},
'Fusion technique':{
template:'Fusion technique',
string:'Fusion technique',
where:'top',
noinclude: false,
subst: false,
parameters: {
"1": {name: 'Article 1', type: 'string'},
"2": {name: 'Article 2', type: 'string'},
"3": {name: 'Article 3', type: 'string'},
"4": {name: 'Article 4', type: 'string'},
"5": {name: 'Article 5', type: 'string'},
"6": {name: 'Article 6', type: 'string'},
"section FT": {name: 'Titre de section', type: 'string'}
}
}
};
mw.loader.addStyleTag("" +
".InserisciTemplate_TemplateDiv {" +
" border: 1px solid #808080;" +
" padding: 0.5em;" +
" margin: 2px;" +
"} " +
".InserisciTemplate_template {" +
" font-size:150%;" +
" font-weight:bold;" +
"}"
);
window.AddComplexTemplateExtension_Init = function(){
var GoodActions = (mw.config.get('wgAction')=="view"||mw.config.get('wgAction')=="purge");
if(!GoodActions) return;
var ThisPage = mw.config.get('wgPageName').replace(/_/g, " ");
var lrcPage = ( ThisPage === lrcMakeParam("PageTitle") );
var installPage = ( ThisPage === LiveRC_Config["InstallationPage"]);
var userCustomPage = ( ThisPage === lrcGetNamespaceName(2)+":"+mw.config.get('wgUserName')+LiveRC_Config["UserParamPage"]+".js");
if(!lrcPage && !installPage && !userCustomPage ) return;
AddComplexTemplateExtension_getEbaucheParams();
}
LiveRC_AddHook("AfterGotUserInfos", AddComplexTemplateExtension_Init);
// ===== GET PARAMS FOR {{Ébauche}} =====
window.AddComplexTemplateExtension_getEbaucheParams = function(ParamList, apcontinue){
if(!ParamList){
ParamList = new Array();
ParamList.push("");
}
if(!apcontinue) apcontinue = "";
var URL = lrcGetAPIURL('format=xml&action=query')
+ '&list=allpages'
+ '&apnamespace=10'
+ '&aplimit='+LiveRC_Config["UserInfos"].APIlimit
+ '&apprefix=Ébauche/paramètres%20'
+ '&apfilterredir=nonredirects'
+ apcontinue;
wpajax.http({url:URL,
onSuccess:AddComplexTemplateExtension_getEbaucheParamsDone,
list:ParamList
});
}
window.AddComplexTemplateExtension_getEbaucheParamsDone = function(Req, data){
var ParamList = data.list;
var ObjectXML = Req.responseXML;
var pages = ObjectXML.getElementsByTagName('p');
for(var a=0,l=pages.length;a<l;a++){
var page = pages[a];
var title = page.getAttribute("title").split('Ébauche/paramètres ')[1];
if(!title || title == "?" ) continue;
if(ParamList.indexOf(title)==-1) ParamList.push(title);
}
var MustContinue = ObjectXML.getElementsByTagName('query-continue')[0];
if(MustContinue && MustContinue.getElementsByTagName("allpages")[0]){
var apcontinue = "&apcontinue=" + encodeURIComponent(MustContinue.getElementsByTagName("allpages")[0].getAttribute("apcontinue"));
AddComplexTemplateExtension_getEbaucheParams(ParamList, apcontinue);
}else{
try{
var Params = lstMyTemplate['Ébauche'].parameters;
for(var paramname in Params){
if(!Params.hasOwnProperty(paramname)) continue;
lstMyTemplate['Ébauche'].parameters[paramname].value = ParamList;
}
}catch(e){
lrcDisplayDebug("Failed to get {{Ébauche}} params");
};
InserisciTemplate_PopulateConfigPanel();
}
}
// ####################################################################################################################
// ####################################################################################################################
// Add options in the "Tag" form
window.lrcRunInsertTemplate = function(data){
var TagSelect = document.getElementById('LiveTagReason');
var TemplateList = Custom_lstMyTemplate;
if(!lrcGetObjectLength(TemplateList)) TemplateList = lstMyTemplate;
$.each(TemplateList, function(i, val) {
var optTag = document.createElement('option');
optTag.value = i;
optTag.className = "InserisciTemplateExtension";
optTag.innerHTML = val.string;
TagSelect.appendChild(optTag);
});
// setup dialog
mw.loader.using(['jquery.ui'], function () {
$('<div>')
.attr('id', 'gtb-dialog')
.appendTo('body');
});
}
LiveRC_AddHook("AfterPreviewArticle", lrcRunInsertTemplate);
// Function launched when choosing one of this extension options
getLiveTagFunctions["InserisciTemplateExtension"] = function(page, option){
lrcDisableLink("LiveTagReason");
lrcDisableLink("LiveTagLink");
var TemplateList = Custom_lstMyTemplate;
if(!lrcGetObjectLength(TemplateList)) TemplateList = lstMyTemplate;
var message = TemplateList[option.value];
wpajax.http({ url: mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?format=xml'
+ '&action=query&prop=info&intoken=edit'
+ '&inprop=protection'
+ '&titles=' + encodeURIComponent(page),
onSuccess: InserisciTemplate_PostTagPage,
page: page,
message: message});
return false;
}
// Get page edit token and protection status
window.InserisciTemplate_PostTagPage = function(xmlreq, data){
var page = data.page;
var message = data.message;
ObjetXML = xmlreq.responseXML;
var Isprotected = false;
var PR = ObjetXML.getElementsByTagName("pr");
for(var a=0,l=PR.length;a<l;a++){
var Type = PR[a].getAttribute("type");
var Level = PR[a].getAttribute("level");
if(Type=="edit" && mw.config.get('wgUserGroups').indexOf(Level)==-1) Isprotected = true;
}
if(Isprotected){
LiveRC_alert("<b>"+lrcMakeText("PROTECTEDPAGE").split("$1").join(page)+"</b>");
return;
}
var Page = ObjetXML.getElementsByTagName("page")[0];
LiveRC_Config["edittoken"] = Page.getAttribute("edittoken");
// show dialog
var tpl = InserisciTemplate_showDialog(message, page);
}
// Show the dialog in order to ask for the template parameters.
window.InserisciTemplate_showDialog = function(data, page) {
var $dialog, $fieldset;
// create the dialog html
$dialog = $('#gtb-dialog').html(lrcMakeText("IT_InsertTemplate1"));
$('<a>')
.attr('href', mw.config.get('wgArticlePath').split("$1").join(lrcGetNamespaceName(10)) + data.template)
.attr('target', '_blank')
.attr('tabindex', '-1')
.css('color', '#2e45ad')
.text(data.template)
.appendTo($dialog);
$dialog.append(lrcMakeText("IT_InsertTemplate2"));
$fieldset = $('<fieldset>').css('border-color', 'gray').appendTo($dialog);
$('<legend>').text(lrcMakeText('IT_InsertTemplateParams')).appendTo($fieldset);
$.each(data.parameters, function (id, val) {
var inputEl = InserisciTemplate_buildInputEl(id, val);
$('<label>')
.attr('for', id)
.text(inputEl.label + ':')
.appendTo($fieldset);
$fieldset
.append('<br/>')
.append(inputEl.el)
.append('<br/>');
});
// show the dialog
var Buttons = new Object();
var OKText = lrcMakeText('OK');
var CancelText = lrcMakeText('Cancel');
Buttons[OKText] = function () {
var params = {};
$dialog.find('input:text,select').each(function () {
params[this.id] = this.value.trim();
});
var text = InserisciTemplate_dumpTemplate(data, params);
$(this).dialog('close');
InserisciTemplate_postTemplate(data, text, page);
};
Buttons[CancelText] = function () {
$(this).dialog('close');
};
$dialog.dialog({
title: lrcMakeIcon("LogoIcon") + ' ' + data.string,
width: 500,
resizable: false,
modal: true,
zIndex: 10000,
buttons: Buttons
});
}
window.InserisciTemplate_buildInputEl = function(id, data) {
var label, inputEl;
if (data.type == 'string') {
label = data.name;
inputEl = $('<input/>')
.attr('id', id)
.attr('type', 'text')
.attr('size', 50)
.attr('value', (data.value || ''));
} else if (data.type == 'select') {
label = data.name;
inputEl = $('<select>')
.attr('id', id)
.css('width', '200px');
$.each(data.value, function (i, option) {
$('<option>')
.html(option)
.appendTo(inputEl);
});
}
return { label: label, el: inputEl };
}
// Check the dialog box and create the wikitext from the template and its params
window.InserisciTemplate_dumpTemplate = function(template, params) {
var text, templateParams = "";
templateParams = LiveRC_FormatTemplateParams(params || {});
text = (template.noinclude ? '<noinclude>' : '') +
'{{' + (template.subst ? 'subst:' : '') +
template.template + '|' +
(templateParams) +
'}}' +
(template.noinclude ? '</noinclude>' : '') + '\n';
return text;
}
window.LiveRC_FormatTemplateParams = function(params) {
var text = new Array();
for(var arg in params){
if(params.hasOwnProperty(arg)) text.push(arg+"="+params[arg]);
}
return text.join("|");
}
// Save the edit
window.InserisciTemplate_postTemplate = function(data, text, page){
lrcDisableLink("LiveTagReason");
lrcDisableLink("LiveTagLink");
var EditParam = new Array();
EditParam["token"] = LiveRC_Config["edittoken"];
if (data.where == 'top')
EditParam["prependtext"] = text+"\n";
else if (data.where == 'bottom')
EditParam["appendtext"] = "\n"+text;
else //default = top
EditParam["prependtext"] = text+"\n";
EditParam["summary"] = lrcMakeText("RESUMESTART") + lrcMakeText("TAG_RESUME") + ' ' + data.template;
EditParam["title"] = page;
EditParam["watchlist"] = "preferences";
EditParam["notminor"] = "1";
EditParam["nocreate"] = "1";
if(lrcMakeParam("BypassWatchdefault")) EditParam["watchlist"] = "nochange";
var Params = new Array();
for(var Param in EditParam){
Params.push(Param+"="+encodeURIComponent(EditParam[Param]));
}
Params = Params.join("&");
var headers = new Array();
headers['Content-Type'] = 'application/x-www-form-urlencoded';
wpajax.http({ url: mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=edit',
method: "POST", headers: headers,
data: Params,
onSuccess: InserisciTemplate_PostTagPageDone,
params:EditParam,
where: data.where
});
}
window.InserisciTemplate_PostTagPageDone = function(Req, data){
var params = data.params;
var where = data.where;
var text = "<b>" +params["title"]+ " : " + lrcMakeText("TAG_DONE") + "</b> <small>("+params[(where=='bottom')?"appendtext":"prependtext"]+")</small>";
LiveRC_alert(text);
}
/* ########################################## CONFIGURATION PANEL ################################## */
// ===== Create a fieldset in the configuration panel =====
window.InserisciTemplate_CreateConfigPanel = function(){
var InserisciTemplateUl = LiveRC_ManageParams_CreateNewListMenu("InserisciTemplateLegend", LiveRC_ManageParams_CreateActionButtons());
if(!InserisciTemplateUl) return;
InserisciTemplateUl.parentNode.removeChild(InserisciTemplateUl);
var ThisFieldset = document.getElementById("LiveRC_OptionsContent_InserisciTemplateLegend");
var TargetFieldset = document.getElementById("LiveRC_OptionsContent_lstParamMenuTabs");
if(ThisFieldset && TargetFieldset) TargetFieldset.parentNode.insertBefore(ThisFieldset, TargetFieldset);
}
LiveRC_AddHook("AfterCreateParamPanel", InserisciTemplate_CreateConfigPanel);
window.InserisciTemplate_PopulateConfigPanel = function(){
var InserisciTemplateFieldset = document.getElementById("LiveRC_OptionsContent_InserisciTemplateLegend");
if(!InserisciTemplateFieldset) InserisciTemplate_CreateConfigPanel();
var Target = lrcGetElementsByClass("LiveRC_ParamMenuPart", InserisciTemplateFieldset, "div")[0];
if(!Target) return;
while(Target.firstChild){ Target.removeChild(Target.firstChild); }
var Templates = Custom_lstMyTemplate;
if(!Templates || lrcGetObjectLength(Templates)==0) Templates = lstMyTemplate;
for(var temp in Templates){
if(!Templates.hasOwnProperty(temp)) continue;
var Template = Templates[temp];
var TemplateForm = InserisciTemplate_CreateTemplateConfigPanel(Template);
Target.appendChild(TemplateForm);
}
var NewTemplate = document.createElement('p');
NewTemplate.id = "InserisciTemplate_AddNeTemplateP";
var NewTemplateLink = document.createElement('a');
NewTemplateLink.innerHTML = "(+)";
NewTemplateLink.title = lrcMakeText("IT_AddTemplate");
NewTemplateLink.href = "javascript:;";
NewTemplateLink.onclick = function(){ InserisciTemplate_AddNewTemplate(); };
NewTemplate.appendChild(NewTemplateLink);
Target.appendChild(NewTemplate);
}
window.InserisciTemplate_AddNewTemplate = function(){
var P = document.getElementById("InserisciTemplate_AddNeTemplateP");
if(!P) return;
var BlankTemplate = { template:'',
string:'',
where:'top',
noinclude: false,
subst: false,
parameters: {}
};
var NewDiv = InserisciTemplate_CreateTemplateConfigPanel(BlankTemplate);
P.parentNode.insertBefore(NewDiv, P);
}
window.InserisciTemplate_DeleteTemplate = function(DeleteLink){
var Div = DeleteLink;
while(Div){
if(lrcHasClass(Div, "InserisciTemplate_TemplateDiv")) break;
Div = Div.parentNode;
}
if(!Div) return;
Div.parentNode.removeChild(Div);
}
window.InserisciTemplate_CreateTemplateConfigPanel = function(Template){
var TemplateDiv = document.createElement('div');
TemplateDiv.className = "InserisciTemplate_TemplateDiv ParamMenuLi";
var Legend = document.createElement('p');
var Title = document.createElement('a')
Title.className = "InserisciTemplate_template";
Title.innerHTML = "{{"+Template.template+"}} ";
Title.target = "_blank";
Title.href = lrcGetPageURL(lrcGetNamespaceName(10)+":"+Template.template);
Title.title = lrcGetNamespaceName(10)+":"+Template.template;
Title.onclick = function(){ liveArticle(lrcGetNamespaceName(10)+":"+Template.template); return false; };
Legend.appendChild(Title);
var DeleteTemplateLink = document.createElement('a');
DeleteTemplateLink.innerHTML = "(-)";
DeleteTemplateLink.title = lrcMakeText("IT_DeleteTemplate");
DeleteTemplateLink.href = "javascript:;";
DeleteTemplateLink.onclick = function(){ InserisciTemplate_DeleteTemplate(this); };
Legend.appendChild(DeleteTemplateLink);
TemplateDiv.appendChild(Legend);
var TemplateForm = document.createElement('form');
TemplateForm.className = "InserisciTemplate_TemplateForm";
TemplateDiv.appendChild(TemplateForm);
var UL = document.createElement('ul');
TemplateForm.appendChild(UL);
var LI_Template = document.createElement('li');
UL.appendChild(LI_Template);
// 'template': name of the template to be inserted
var Label_template = document.createElement('label');
Label_template.setAttribute('for', 'template');
Label_template.innerHTML = "template : ";
LI_Template.appendChild(Label_template);
var Input_template = document.createElement('input');
Input_template.id = 'template';
Input_template.type = "text";
Input_template.value = (Template.template || "");
LI_Template.appendChild(Input_template);
LI_Template.appendChild(document.createTextNode(" - "));
// 'string': option label in the template combo box
var Label_string = document.createElement('label');
Label_string.setAttribute('for', 'string');
Label_string.innerHTML = "string : ";
LI_Template.appendChild(Label_string);
var Input_string = document.createElement('input');
Input_string.id = 'string';
Input_string.type = "text";
Input_string.value = (Template.string || "");
LI_Template.appendChild(Input_string);
LI_Template.appendChild(document.createTextNode(" - "));
// 'where': where to insert the template in the page (top or bottom)
var Label_where = document.createElement('label');
Label_where.setAttribute('for', 'where');
Label_where.innerHTML = "where : ";
LI_Template.appendChild(Label_where);
var Select_where = document.createElement('select');
Select_where.id = 'where';
var Opts = ["top", "bottom"];
for(var a=0,l=Opts.length;a<l;a++){
var OptValue = Opts[a];
var Opt = document.createElement('option');
Opt.innerHTML = OptValue;
Opt.value = OptValue;
if(OptValue == Template.where) Opt.selected = "selected";
Select_where.appendChild(Opt);
}
LI_Template.appendChild(Select_where);
LI_Template.appendChild(document.createTextNode(" - "));
// 'noinclude': whether the template shall be tagged with "noinclude"
var Label_noinclude = document.createElement('label');
Label_noinclude.setAttribute('for', 'noinclude');
Label_noinclude.innerHTML = "noinclude : ";
LI_Template.appendChild(Label_noinclude);
var Input_noinclude = document.createElement('input');
Input_noinclude.id = 'noinclude';
Input_noinclude.type = "checkbox";
if(Template.noinclude) Input_noinclude.checked = "checked";
LI_Template.appendChild(Input_noinclude);
LI_Template.appendChild(document.createTextNode(" - "));
// 'subst': whether the template shall be "substed"
var Label_subst = document.createElement('label');
Label_subst.setAttribute('for', 'subst');
Label_subst.innerHTML = "subst : ";
LI_Template.appendChild(Label_subst);
var Input_subst = document.createElement('input');
Input_subst.id = 'subst';
Input_subst.type = "checkbox";
if(Template.subst) Input_subst.checked = "checked";
LI_Template.appendChild(Input_subst);
// 'parameters'
var LI_parameters = document.createElement('li');
UL.appendChild(LI_parameters);
var Label_parameters = document.createElement('label');
Label_parameters.setAttribute('for', 'parameters');
Label_parameters.innerHTML = "parameters : ";
LI_parameters.appendChild(Label_parameters);
var ParamsUL = document.createElement('ul');
ParamsUL.id = 'parameters';
LI_parameters.appendChild(ParamsUL);
for(var param in Template.parameters){
if(!Template.parameters.hasOwnProperty(param)) continue;
var LI_Param = InserisciTemplate_CreateNewParam(param, Template.parameters[param]);
ParamsUL.appendChild(LI_Param);
}
var Li_NewParam = document.createElement('li');
var Link_NewParam = document.createElement('a');
Link_NewParam.innerHTML = "(+)";
Link_NewParam.title = lrcMakeText("IT_AddParam");
Link_NewParam.href = "javascript:;";
Link_NewParam.onclick = function(){ InserisciTemplate_AddParamToTemplate(this); };
Li_NewParam.appendChild(Link_NewParam);
ParamsUL.appendChild(Li_NewParam);
return TemplateDiv;
}
window.InserisciTemplate_AddParamToTemplate = function(AddParamLink){
var Li = AddParamLink.parentNode;
var NewParams = {name: '', type: 'string', value: ''};
var NewParamLi = InserisciTemplate_CreateNewParam("", NewParams);
Li.parentNode.insertBefore(NewParamLi, Li);
}
window.InserisciTemplate_CreateNewParam = function(param, Params){
var ParamName = Params.name;
var ParamType = Params.type;
var ParamValue = Params.value;
var LI_Param = document.createElement('li');
LI_Param.className = "LI_parameters_li";
var DeleteParamLink = document.createElement('a');
DeleteParamLink.innerHTML = "(-)";
DeleteParamLink.title = lrcMakeText("IT_DeleteParam");
DeleteParamLink.href = "javascript:;";
DeleteParamLink.onclick = function(){ InserisciTemplate_DeleteParamFromTemplate(this); };
LI_Param.appendChild(DeleteParamLink);
LI_Param.appendChild(document.createTextNode(" - "));
//// parameters id
var Label_id = document.createElement('label');
Label_id.setAttribute('for', 'Param_id');
Label_id.innerHTML = "id : ";
LI_Param.appendChild(Label_id);
var Input_id = document.createElement('input');
Input_id.id = 'Param_id';
Input_id.type = "text";
Input_id.value = (param || "");
LI_Param.appendChild(Input_id);
LI_Param.appendChild(document.createTextNode(" - "));
//// parameters.name
var Label_name = document.createElement('label');
Label_name.setAttribute('for', 'Param_name');
Label_name.innerHTML = "name : ";
LI_Param.appendChild(Label_name);
var Input_name = document.createElement('input');
Input_name.id = 'Param_name';
Input_name.type = "text";
Input_name.value = (ParamName || "");
LI_Param.appendChild(Input_name);
LI_Param.appendChild(document.createTextNode(" - "));
//// parameters.type
var Label_type = document.createElement('label');
Label_type.setAttribute('for', 'Param_type');
Label_type.innerHTML = "type : ";
LI_Param.appendChild(Label_type);
var Select_type = document.createElement('select');
Select_type.id = 'Param_type';
var Opts = ["string", "select"];
for(var a=0,l=Opts.length;a<l;a++){
var OptValue = Opts[a];
var Opt = document.createElement('option');
Opt.innerHTML = OptValue;
Opt.value = OptValue;
if(OptValue == ParamType) Opt.selected = "selected";
Select_type.appendChild(Opt);
}
Select_type.onchange = function(){ InserisciTemplate_ChageValueType(this); }
LI_Param.appendChild(Select_type);
LI_Param.appendChild(document.createTextNode(" - "));
//// parameters.value
var Label_value = document.createElement('label');
Label_value.setAttribute('for', 'Param_value');
Label_value.innerHTML = "value : ";
LI_Param.appendChild(Label_value);
if(ParamType == "string"){
var Input_value = document.createElement('input');
Input_value.id = 'Param_value';
Input_value.type = "text";
Input_value.size = "30";
Input_value.value = (ParamValue || "");
LI_Param.appendChild(Input_value);
}else if(ParamType == "select"){
var Select_value = document.createElement('select');
Select_value.id = 'Param_value';
Select_value.style.width = '206px';
var Opts = ParamValue;
if(typeof(Opts) ==="object"){
for(var a=0,l=Opts.length;a<l;a++){
var OptValue = Opts[a];
var Opt = document.createElement('option');
Opt.innerHTML = OptValue;
Opt.value = OptValue;
Select_value.appendChild(Opt);
}
}
LI_Param.appendChild(Select_value);
LI_Param.appendChild(document.createTextNode(" "));
var DeleteOptionLink = document.createElement('a');
DeleteOptionLink.innerHTML = "(-)";
DeleteOptionLink.title = lrcMakeText("IT_DeleteOption");
DeleteOptionLink.href = "javascript:;";
DeleteOptionLink.onclick = function(){ InserisciTemplate_DeleteOptionFromSelect(this); };
LI_Param.appendChild(DeleteOptionLink);
LI_Param.appendChild(document.createTextNode(" "));
var AddOptionLink = document.createElement('a');
AddOptionLink.innerHTML = "(+)";
AddOptionLink.title = lrcMakeText("IT_AddOption");
AddOptionLink.href = "javascript:;";
AddOptionLink.onclick = function(){ InserisciTemplate_AddOptionToSelect(this); };
LI_Param.appendChild(AddOptionLink);
}
return LI_Param;
}
window.InserisciTemplate_ChageValueType = function(Select){
var NewType = Select.value;
var Li = Select.parentNode;
var Labels = Li.getElementsByTagName('label');
var LastLabel = Labels[(Labels.length-1)];
while(LastLabel.nextSibling){ LastLabel.nextSibling.parentNode.removeChild(LastLabel.nextSibling); }
if(NewType == "string"){
var Input_value = document.createElement('input');
Input_value.id = 'Param_value';
Input_value.type = "text";
Input_value.size = "30";
Input_value.value = "";
LastLabel.parentNode.appendChild(Input_value);
}else{
var Select_value = document.createElement('select');
Select_value.id = 'Param_value';
Select_value.style.width = '206px';
var Opt = document.createElement('option');
Opt.innerHTML = "";
Opt.value = "";
Select_value.appendChild(Opt);
LastLabel.parentNode.appendChild(Select_value);
LastLabel.parentNode.appendChild(document.createTextNode(" "));
var DeleteOptionLink = document.createElement('a');
DeleteOptionLink.innerHTML = "(-)";
DeleteOptionLink.title = lrcMakeText("IT_DeleteOption");
DeleteOptionLink.href = "javascript:;";
DeleteOptionLink.onclick = function(){ InserisciTemplate_DeleteOptionFromSelect(this); };
LastLabel.parentNode.appendChild(DeleteOptionLink);
LastLabel.parentNode.appendChild(document.createTextNode(" "));
var AddOptionLink = document.createElement('a');
AddOptionLink.innerHTML = "(+)";
AddOptionLink.title = lrcMakeText("IT_AddOption");
AddOptionLink.href = "javascript:;";
AddOptionLink.onclick = function(){ InserisciTemplate_AddOptionToSelect(this); };
LastLabel.parentNode.appendChild(AddOptionLink);
}
}
window.InserisciTemplate_DeleteOptionFromSelect = function(DeleteOptionLink){
var Li = DeleteOptionLink.parentNode;
var Selects = Li.getElementsByTagName('select');
for(var a=0,l=Selects.length;a<l;a++){
var Select = Selects[a];
if(!Select.id || Select.id != 'Param_value') continue;
var SelectedOpt = Select.value;
var Options = Select.getElementsByTagName('option');
for(var b=0,m=Options.length;b<m;b++){
var thisOpt = Options[b];
if(thisOpt.value != SelectedOpt) continue;
thisOpt.parentNode.removeChild(thisOpt);
}
}
}
window.InserisciTemplate_AddOptionToSelect = function(AddOptionLink){
var AddOptionForm = document.createElement('span');
var AddOptionInput = document.createElement('input');
AddOptionInput.type = 'text';
AddOptionForm.appendChild(AddOptionInput);
var AddOptionInputOK = document.createElement('input');
AddOptionInputOK.type = 'button';
AddOptionInputOK.value = lrcMakeText("OK");
AddOptionInputOK.onclick = function(){ InserisciTemplate_AddOptionToSelect_OK(this); };
AddOptionInputOK.onselect = function(){ InserisciTemplate_AddOptionToSelect_OK(this); };
AddOptionForm.appendChild(AddOptionInputOK);
var AddOptionInputCancel = document.createElement('input');
AddOptionInputCancel.type = 'button';
AddOptionInputCancel.value = lrcMakeText("Cancel");
AddOptionInputCancel.onclick = function(){ InserisciTemplate_AddOptionToSelect_Cancel(this); };
AddOptionInputCancel.onselect = function(){ InserisciTemplate_AddOptionToSelect_Cancel(this); };
AddOptionForm.appendChild(AddOptionInputCancel);
AddOptionLink.parentNode.insertBefore(AddOptionForm, AddOptionLink);
AddOptionLink.style.display = "none";
}
window.InserisciTemplate_AddOptionToSelect_Cancel = function(AddOptionInputCancel){
var Span = AddOptionInputCancel.parentNode;
var Link = Span.nextSibling;
Span.parentNode.removeChild(Span);
Link.style.display = "";
}
window.InserisciTemplate_AddOptionToSelect_OK = function(AddOptionInputOK){
var Input = AddOptionInputOK.previousSibling;
var NewOption = Input.value;
var Li = AddOptionInputOK.parentNode.parentNode;
var Selects = Li.getElementsByTagName('select');
for(var a=0,l=Selects.length;a<l;a++){
var Select = Selects[a];
if(!Select.id || Select.id != 'Param_value') continue;
var Option = document.createElement('option');
Option.innerHTML = NewOption;
Option.value = NewOption;
Select.appendChild(Option);
}
InserisciTemplate_AddOptionToSelect_Cancel(AddOptionInputOK)
}
window.InserisciTemplate_DeleteParamFromTemplate = function(DeleteParamLink){
var Li = DeleteParamLink.parentNode;
Li.parentNode.removeChild(Li);
}
// ===== Check the fieldset and add a text to be saved in /LiveRCparam.js page =====
window.InserisciTemplate_CheckConfigPanel = function(){
var ITConfigPanel = document.getElementById('LiveRC_OptionsContent_InserisciTemplateLegend');
if(!ITConfigPanel) return;
var ElementForms = lrcGetElementsByClass("InserisciTemplate_TemplateForm", ITConfigPanel, "form");
var Items = new Object();
for(var a=0,l=ElementForms.length;a<l;a++){
var ThisForm = ElementForms[a];
var NewItem = new Object();
NewItem.template = getElementWithId('template', 'input', ThisForm).value;
NewItem.string = getElementWithId('string', 'input', ThisForm).value;
NewItem.where = getElementWithId('where', 'select', ThisForm).value;
NewItem.noinclude = (getElementWithId('noinclude', 'input', ThisForm).checked ? true : false );
NewItem.subst = (getElementWithId('subst', 'input', ThisForm).checked ? true : false );
NewItem.parameters = new Object();
var ParamLIs = lrcGetElementsByClass("LI_parameters_li", ThisForm, "li");
for(var b=0,m=ParamLIs.length;b<m;b++){
var ParamLi = ParamLIs[b];
var NewParam = new Object();
var NewParamId = getElementWithId('Param_id', 'input', ParamLi).value;
NewParam.name = getElementWithId('Param_name', 'input', ParamLi).value;
NewParam.type = getElementWithId('Param_type', 'select', ParamLi).value;
if(NewParam.type == "string"){
NewParam.value = getElementWithId('Param_value', 'input', ParamLi).value.unhtmlize();
if(!NewParam.value) delete NewParam.value;
}else{
NewParam.value = new Array();
var ParamValueSelect = getElementWithId('Param_value', 'select', ParamLi);
var Opt = ParamValueSelect.getElementsByTagName('option');
for(var c=0,k=Opt.length;c<k;c++){
NewParam.value.push(Opt[c].value.unhtmlize());
}
}
NewItem.parameters[NewParamId] = NewParam;
}
Items[NewItem.template] = NewItem;
}
var TextToSave = InserisciTemplate_CompareNewParams(Items);
if(!TextToSave) return;
var SavedText = "\nCustom_lstMyTemplate = {\n";
var SavedItems = new Array();
for(var item in Items){
var SavedItem = " '"+item+"':{\n";
var ThisTemplate = Items[item];
for(var tempParam in ThisTemplate){
SavedItem += " "+tempParam+" : ";
var tempParamValue = ThisTemplate[tempParam];
if(tempParam!="parameters"){
SavedItem += ( typeof(tempParamValue)=="string" ? lrcEscapeStrHTML(tempParamValue) : tempParamValue ) + ",\n";
}else{
SavedItem += "{\n";
var tempParameters = new Array();
for(var parameter in tempParamValue){
var thisparam = tempParamValue[parameter];
var ParamItems = new Array();
for(var paramItem in thisparam){
var thisparamItemValue = thisparam[paramItem];
if(paramItem!="value" || typeof(thisparamItemValue)=="string"){
ParamItems.push( paramItem + ":" + lrcEscapeStrHTML(thisparamItemValue) );
}else{
var ThisParamValue = new Array();
for(var a=0,l=thisparamItemValue.length;a<l;a++){
ThisParamValue.push(lrcEscapeStrHTML(thisparamItemValue[a]));
}
ParamItems.push( paramItem +": [" + ThisParamValue.join(",") + "]" );
}
}
tempParameters.push(" " + lrcEscapeStrHTML(parameter) + " : {" + ParamItems.join(",") + "}");
}
SavedItem += tempParameters.join(",\n");
SavedItem += "\n }";
}
}
SavedItem += "\n }";
SavedItems.push(SavedItem);
}
SavedText += SavedItems.join(",\n");
SavedText += "};\n\n";
LiveRC_Config["BeforeParamPanelSavedHookResult"] += SavedText;
}
LiveRC_AddHook("BeforeParamPanelSaved", InserisciTemplate_CheckConfigPanel);
window.InserisciTemplate_CompareNewParams = function(NewItems){
var OldItems = lstMyTemplate;
for(var template in OldItems){
if(typeof(NewItems[template])==="undefined") return true;
for(var item in OldItems[template]){
if(item != "parameters"){
if(OldItems[template][item] !== NewItems[template][item]) return true;
}else{
if(lrcGetObjectLength(OldItems[template][item]) != lrcGetObjectLength(NewItems[template][item])) return true;
for(var param in OldItems[template][item]){
if(!NewItems[template][item][param]) return true;
for(var paramitem in OldItems[template][item][param]){
if(paramitem != "value" || (typeof(OldItems[template][item][param][paramitem]) != "object" && typeof(NewItems[template][item][param][paramitem]) != "object")){
if(OldItems[template][item][param][paramitem] !== NewItems[template][item][param][paramitem]) return true;
}else{
if(OldItems[template][item][param][paramitem].length != NewItems[template][item][param][paramitem].length) return true;
for(var a=0, l=OldItems[template][item][param][paramitem].length;a<l;a++){
if(OldItems[template][item][param][paramitem][a] != NewItems[template][item][param][paramitem][a]) return true;
}
}
}
}
}
}
}
for(var template in NewItems){
if(typeof(OldItems[template])==="undefined") return true;
}
return false;
}
// ===== Vars for configuration panel fieldset =====
// Texts
try{
lrcTexts["IT_InsertTemplate1"] = "Inserisce il template {{";
lrcTexts["IT_InsertTemplate2"] = "}} nella pagina.";
lrcTexts["IT_InsertTemplateParams"] = "Parametri";
lrcTexts["IT_AddTemplate"] = "Aggiungi un nuovo template";
lrcTexts["IT_DeleteTemplate"] = "Cancella questo template";
lrcTexts["IT_AddParam"] = "Aggiungi un nuovo parametro";
lrcTexts["IT_DeleteParam"] = "Cancella questo parametro";
lrcTexts["IT_DeleteOption"] = "Cancella l'opzione selezionata";
lrcTexts["IT_AddOption"] = "Aggiungi una nuova opzione";
}catch(e){ }
// Descriptions
try{
lrcParamDesc["DescIT_InsertTemplate1"] = "[InserisciTemplate] Inserisci la parte 1 della frase del template";
lrcParamDesc["DescIT_InsertTemplate2"] = "[InserisciTemplate] Inserisci la parte 2 della frase del template";
lrcParamDesc["DescIT_InsertTemplateParams"] = "[InserisciTemplate] Parametri";
lrcParamDesc["DescIT_AddTemplate"] = "[InserisciTemplate] Frase Aggiungi un nuovo template";
lrcParamDesc["DescIT_DeleteTemplate"] = "[InserisciTemplate] Frase Cancella questo template";
lrcParamDesc["DescIT_AddParam"] = "[InserisciTemplate] Frase Aggiungi un nuovo parametro";
lrcParamDesc["DescIT_DeleteParam"] = "[InserisciTemplate] Frase Cancella questo parametro";
lrcParamDesc["DescIT_DeleteOption"] = "[InserisciTemplate] Frase Cancella l'opzione selezionata";
lrcParamDesc["DescIT_AddOption"] = "[InserisciTemplate] Frase Aggiungi una nuova opzione";
lrcParamDesc["DescInserisciTemplateLegend"] = "Parametri per l'estensione InserisciTemplate";
lrcParamDesc["DescInserisciTemplateLegend_short"] = "InserisciTemplate";
}catch(e){ }
// Hide/Show tabs panel item
addParamMenuTab("InserisciTemplateLegend", true);
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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'''
Ajoute des cases à cocher et un bouton dans la prévisualisation d'un historique pour demander un masquage (non sysop)
* Licence : ...?
* Documentation :
* Auteur : [[:fr:User:Dr Brains]]
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if(typeof(LiveRC_AddHook)=="function") { // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("AskForRevisionDeleteFromHistExtension");
/* *************************************************************************************************************************** */
// textes traduits
try{
lrcTexts["AFRDFH_ButtonText"] = "Demander le masquage des versions sélectionnées (live)";
lrcTexts["AFRDFH_AskReason"] = "Raison de la demande de masquage";
lrcTexts["AFRDFH_NoSelection"] = "Vous devez sélectionner au moins une révision";
lrcTexts["AFRDFH_NoReason"] = "Vous devez indiquer une raison";
}catch(e){ }
// textes non traduits
try{
UnTranslatedTexts["AFRDFH_Resume"] = "{{a-court|$1}}";
}catch(e){ }
// paramètres
try{
lrcParams["AFRDFH_RequestPage"] = "Wikipédia:Demande de purge d'historique";
lrcParams["AFRDFH_Template"] = "Wikipédia:LiveRC/Modèles/Demande de purge d'historique|page=$page|url=$url|raison=$reason";
lrcParams["AFRDFH_ReasonInputSize"] = 35;
lrcParams["AFRDFH_UseOutOfLiveRC"] = true;
}catch(e){ }
// descriptions de variables
try{
lrcParamDesc["DescAFRDFH_ButtonText"] = "[AskForRevisionDeleteFromHist] Texte du bouton de demande de masquage";
lrcParamDesc["DescAFRDFH_AskReason"] = "[AskForRevisionDeleteFromHist] Texte de la pop-up pour la raison de la demande de masquage";
lrcParamDesc["DescAFRDFH_NoSelection"] = "[AskForRevisionDeleteFromHist] Erreur si pas de révision sélectionnée";
lrcParamDesc["DescAFRDFH_NoReason"] = "[AskForRevisionDeleteFromHist] Erreur si pas de raison donnée";
lrcParamDesc["DescAFRDFH_Resume"] = "[AskForRevisionDeleteFromHist] Résumé de modification de la demande de masquage";
lrcParamDesc["DescAFRDFH_RequestPage"] = "[AskForRevisionDeleteFromHist] Page de requête pour la demande de masquage";
lrcParamDesc["DescAFRDFH_Template"] = "[AskForRevisionDeleteFromHist] Modèle pour la demande de masquage";
lrcParamDesc["DescAFRDFH_ReasonInputSize"] = "[AskForRevisionDeleteFromHist] Taille du champ « Raison » ";
lrcParamDesc["DescAFRDFH_UseOutOfLiveRC"] = "[AskForRevisionDeleteFromHist] Activer dans les pages d’historique normales";
lrcParamDesc["DesclstAskForRevisionReasons_short"] = "Masquage";
lrcParamDesc["DesclstAskForRevisionReasons"] = "Raisons de requête de masquage";
}catch(e){ }
// Limitation
LiveRC_Config["LimitationsRight"]["AskForRevisionDeleteFromHist"] = "autopatrol";
// Liste de raisons
window.Custom_lstAskForRevisionReasons = [];
window.lstAskForRevisionReasons = [
{ reason : "Violation de copyright", text : "copyvio" },
{ reason : "Diffamation", text : "diffamation" },
{ reason : "Renseignements personnels inappropriés", text : "vie privée" }
];
// Personnalisation auto
window.defineCustomAskForRevisionReasons = function(AskForRevisionReasons){
Custom_lstAskForRevisionReasons = AskForRevisionReasons;
}
LiveRC_AddHook("AfterFillParamPanel", function(){
LiveRC_ManageParams_Fill(lstAskForRevisionReasons, "lstAskForRevisionReasons", "defineCustomAskForRevisionReasons", true);
});
// ********************************************************************************************************* //
window.LiveRC_AskForRevisionDeleteFromHistExtension_PreProcess = function(){
if(!lrcMakeParam("AFRDFH_UseOutOfLiveRC") ) return;
LiveRC_Config["LaunchProcessForce"]["InterfaceLang"] = true;
LiveRC_Config["LaunchProcessForce"]["UserInfos"] = true;
LiveRC_Config["LaunchProcessForce"]["TranslationsLoaded"] = true;
LiveRC_Config["LaunchProcessForce"]["InitTranslations"] = true;
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_Init = function(){
if(!lrcUserCan("AskForRevisionDeleteFromHist") || lrcUserHasRight("deleterevision")) return;
LiveRC_Config["LaunchProcess"].push({functions:LiveRC_AskForRevisionDeleteFromHistExtension_Run});
}
if(mw.config.get('wgAction')=="history"){
LiveRC_AddHook("BeforeInitActivationProcess", LiveRC_AskForRevisionDeleteFromHistExtension_PreProcess);
LiveRC_AddHook("AfterGotUserInfos", LiveRC_AskForRevisionDeleteFromHistExtension_Init);
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_Run = function(data){
if(!lrcUserCan("AskForRevisionDeleteFromHist") || lrcUserHasRight("deleterevision")) return LiveRC_LaunchProcessNextStep();
var HistForm = getElementWithId("mw-history-compare", 'form', document);
var HistUL = getElementWithId("pagehistory", 'ul', Form);
if(!HistForm || !HistUL) return LiveRC_LaunchProcessNextStep();
var Lis = HistUL.getElementsByTagName('li');
for(var a=0,l=Lis.length;a<l;a++){
var Li = Lis[a];
var AlreadyCheckboxes = false;
for(var i=0,ilen=Inputs.length;i<ilen;i++){
var Input = Inputs[i];
if(Input.type !== "checkbox") continue;
if(!Input.name) continue;
if(Input.name.indexOf("ids[") !== -1){
$(Input).addClass("AFRDFH_checkbox");
AlreadyCheckboxes = true;
}
}
if(AlreadyCheckboxes) continue;
var Target = lrcGetElementsByClass("mw-changeslist-date", Li, "a")[0];
if(!Target) continue; // revision already hidden
var Input = document.createElement('input');
Input.type = "checkbox";
Input.className = "AFRDFH_checkbox";
Input.name = "ids["+lrcGetArgFromURL(Target.href, "oldid")+"]";
Input.value = "1";
Target.parentNode.insertBefore(Input, Target);
}
var revisionactionsDiv = lrcGetElementsByClass("mw-history-revisionactions", HistForm, "div");
if(revisionactionsDiv.length > 0){
for(var a=0,l=revisionactionsDiv.length;a<l;a++){
revisionactionsDiv[a].insertBefore(LiveRC_AskForRevisionDeleteFromHistExtension_CreateSubmitInput(), revisionactionsDiv[a].firstChild);
}
}else{
var CompareInputs = lrcGetElementsByClass("mw-history-compareselectedversions-button", HistForm, "input");
if(CompareInputs.length > 0){
for(var a=0,l=CompareInputs.length;a<l;a++){
CompareInputs[a].parentNode.appendChild(LiveRC_AskForRevisionDeleteFromHistExtension_CreateSubmitInput());
}
}
}
LiveRC_LaunchProcessNextStep();
}
LiveRC_AddHook("AfterPreviewHistory", LiveRC_AskForRevisionDeleteFromHistExtension_Run);
window.LiveRC_AskForRevisionDeleteFromHistExtension_CreateSubmitInput = function(){
var SubmitInput = document.createElement('input');
SubmitInput.id = "AFRDFH_button_"+a;
SubmitInput.type = "button";
SubmitInput.className = "AFRDFH_buttonReason";
SubmitInput.value = lrcMakeText("AFRDFH_ButtonText");
SubmitInput.onclick = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_CreateReasonForm(this); };
return SubmitInput;
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_DisAbleCheckboxes = function(Disable){
var HistForm = getElementWithId("mw-history-compare", 'form', document);
var HistUL = getElementWithId("pagehistory", 'ul', document);
if(!HistForm || !HistUL) return;
var Checkboxes = lrcGetElementsByClass("AFRDFH_checkbox", HistUL, "input");
for(var a=0,l=Checkboxes.length;a<l;a++){
Checkboxes[a].disabled = ( Disable ? "disabled" : false );
}
var SubmitInputs = lrcGetElementsByClass("AFRDFH_buttonReason", HistForm, "input");
for(var a=0,l=SubmitInputs.length;a<l;a++){
SubmitInputs[a].style.display = ( Disable ? "none" : "" );
}
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_GetIds = function(){
var HistForm = getElementWithId("mw-history-compare", 'form', document);
var HistParams = getFormParams(HistForm);
var ids = [];
for(var paramname in HistParams){
if(paramname.indexOf("ids[")===0) ids.push(encodeURIComponent(paramname)+"=1");
}
if(ids.length===0){
LiveRC_alert(lrcMakeText("AFRDFH_NoSelection"));
return false;
}
return ids;
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_CreateReasonForm = function(Button){
if(!Button) return;
var ids = LiveRC_AskForRevisionDeleteFromHistExtension_GetIds();
if(!ids) return;
LiveRC_AskForRevisionDeleteFromHistExtension_DisAbleCheckboxes(true);
var Form = document.createElement("form");
Form.id = "AFRDFH_form";
Form.style.display = "inline";
Form.submit = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_Process(); return false; };
var InputText = document.createElement('input');
InputText.type = "text";
InputText.id = "AFRDFH_inputtext";
InputText.size = lrcMakeParam("AFRDFH_ReasonInputSize");
InputText.title = lrcMakeText("AFRDFH_AskReason");
Form.appendChild(InputText);
var InputOK = document.createElement('input');
InputOK.type = "button";
InputOK.value = lrcMakeText("OK");
InputOK.onclick = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_Process(); };
InputOK.onselect = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_Process(); };
Form.appendChild(InputOK);
var CancelInput = document.createElement('input');
CancelInput.type = "button";
CancelInput.value = lrcMakeText("Cancel");
CancelInput.onclick = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_CloseReasonForm(); }
CancelInput.onselect = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_CloseReasonForm(); }
Form.appendChild(CancelInput);
Button.parentNode.insertBefore(Form, Button.nextSibling);
LiveRC_AskForRevisionDeleteFromHistExtension_Init(Button);
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_Init = function(Button){
var Input = document.getElementById("AFRDFH_inputtext");
if(!Input) return;
var Bottom = parseInt(Button.id.replace(/[^0-9]/g, ""));
var Select = document.createElement('select');
Select.id = "AFRDFH_SelectList";
Select.style.zIndex = 100;
Select.className = "LiveRC_Opacity_100";
var OptZero = '<option selected="selected" onClick="LiveRC_AskForRevisionDeleteFromHistExtension_Update()" value=""> </option>';
Select.innerHTML = OptZero;
var Reasons = Custom_lstAskForRevisionReasons;
if(!Reasons || Reasons.length==0) Reasons = lstAskForRevisionReasons;
for(var a=0,l=Reasons.length;a<l;a++){
var Reason = Reasons[a];
var Opt = document.createElement('option');
Opt.value = Reason.reason;
Opt.title = Reason.reason;
Opt.onclick = LiveRC_AskForRevisionDeleteFromHistExtension_Update;
Opt.name = a;
Opt.innerHTML = Reason.text;
Select.appendChild(Opt);
}
var Taille = (Reasons.length+1);
Select.style.display = "none";
Select.style.position = "relative" ;
Select.style.width = Input.offsetWidth + "px" ;
// Select.style.height = ((Reasons.length+1) * 20) + "px" ;
Select.size = Taille;
if(!Bottom){
Select.style.top = parseInt(Input.offsetHeight) + "px";
Select.style.marginBottom = "-" + (20 * Taille) + "px";
}else{
Select.style.marginTop = "-" + (16.5 * Taille) + "px" ;
}
Select.style.marginLeft = "-"+Input.offsetWidth+"px" ;
Input.parentNode.insertBefore(Select, Input.nextSibling);
Select.onkeyup = LiveRC_AskForRevisionDeleteFromHistExtension_KeyPress;
Select.onchange = LiveRC_AskForRevisionDeleteFromHistExtension_Update;
Input.onmouseover = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_Toggle(true); };
Select.onmouseover = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_Toggle(true); };
Input.onmouseout = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_Toggle(false); };
Select.onmouseout = function(){ LiveRC_AskForRevisionDeleteFromHistExtension_Toggle(false); };
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_Toggle = function(show){
var Select = document.getElementById("AFRDFH_SelectList");
if(!Select) return;
if(show){
clearTimeout(LiveRC_Config["Timeout"]["AFRDFH_SelectList"]);
Select.className = "LiveRC_Opacity_100";
Select.style.display = "inline";
}else{
LiveRC_Config["Timeout"]["AFRDFH_SelectList"] = setTimeout("LiveRC_alert_setOpacity("+lrcEscapeStr("AFRDFH_SelectList")+", function(){document.getElementById("+lrcEscapeStr("AFRDFH_SelectList")+").style.display = "+lrcEscapeStr("none")+";}, 5, 50);", 200);
}
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_KeyPress = function(e){
if (!e) var e = window.event;
if (e.keyCode != 13) return;
LiveRC_AskForRevisionDeleteFromHistExtension_Update();
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_Update = function(){
var Input = document.getElementById("AFRDFH_inputtext");
var Select = document.getElementById("AFRDFH_SelectList");
if(!Input || !Select) return;
var InputValue = Input.value;
var Options = Select.getElementsByTagName('option');
for(var a=0,l=Options.length;a<l;a++){
if(!Options[a].selected) continue;
Input.value = Options[a].value;
Input.focus();
return;
}
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_CloseReasonForm = function(){
var Form = document.getElementById("AFRDFH_form");
if(Form) Form.parentNode.removeChild(Form);
LiveRC_AskForRevisionDeleteFromHistExtension_DisAbleCheckboxes(false);
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_Process = function(){
var ids = LiveRC_AskForRevisionDeleteFromHistExtension_GetIds();
if(!ids) return;
var type;
var Form = getElementWithId("mw-history-compare", 'form', document);
if(Form){
type = "revision";
}else{
Form = getElementWithId("mw-log-deleterevision-submit", 'form', document);
type = "logging";
}
if(!Form) return;
var Params = getFormParams(Form);
var title = Params["title"];
if(!title) title = lrcGetNamespaceName(-1, true) + ":Log";
var ReasonInput = document.getElementById("AFRDFH_inputtext");
Reason = ReasonInput.value;
if(!Reason){
LiveRC_alert(lrcMakeText("AFRDFH_NoReason"));
return;
}
var URL = mw.config.get('wgServer') + mw.config.get('wgScript') + '?action=revisiondelete&type=' + type + "&" + ids.join("&");
var Template = lrcMakeParam("AFRDFH_Template");
Template = Template.split("$page").join(title);
Template = Template.split("$url").join(URL);
Template = Template.split("$reason").join(Reason);
LiveRC_AskForRevisionDeleteFromHistExtension_CreateRequest(Template, title);
return false;
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_CreateRequest = function(Template, title){
var Page = buildReportPageMagicWords(lrcMakeParam("AFRDFH_RequestPage"));
var summary = lrcMakeText("AFRDFH_Resume").split("$1").join(title);
var URL = lrcGetAPIURL('format=xml&action=query&prop=info&intoken=edit&inprop=protection&titles='+encodeURIComponent(Page));
wpajax.http({ url : URL,
onSuccess : LiveRC_AskForRevisionDeleteFromHistExtension_SendRequest,
template : Template,
summary : summary,
page : Page
});
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_SendRequest = function(Req, data){
var page = data.page;
var message = data.template;
var summary = data.summary;
var ObjetXML = Req.responseXML;
var Isprotected = false;
var PR = ObjetXML.getElementsByTagName("pr");
for(var a=0,l=PR.length;a<l;a++){
var Type = PR[a].getAttribute("type");
var Level = PR[a].getAttribute("level");
if(Type=="edit" && !lrcUserHasGroup(Level)) Isprotected = true;
}
if(Isprotected){
LiveRC_alert("<b>"+lrcMakeText("PROTECTEDPAGE").split("$1").join(page)+"</b>");
return;
}
var Page = ObjetXML.getElementsByTagName("page")[0];
var EditParam = new Array();
EditParam["token"] = Page.getAttribute("edittoken");
EditParam["section"] = "new";
EditParam["sectiontitle"] = summary;
EditParam["text"] = '\n{{subst:' + message +'}}\n';
EditParam["title"] = page;
EditParam["notminor"] = "1";
EditParam["watchlist"] = "preferences";
if(lrcMakeParam("BypassWatchdefault")) EditParam["watchlist"] = "nochange";
var Params = new Array();
for(var Param in EditParam){
Params.push(Param+"="+encodeURIComponent(EditParam[Param]));
}
Params = Params.join("&");
var headers = new Array();
headers['Content-Type'] = 'application/x-www-form-urlencoded';
wpajax.http({ url: lrcGetAPIURL('action=edit'),
method: "POST", headers: headers,
data: Params,
onSuccess: LiveRC_AskForRevisionDeleteFromHistExtension_SendRequestDone,
params:EditParam
});
}
window.LiveRC_AskForRevisionDeleteFromHistExtension_SendRequestDone = function(Req, data){
var params = data.params;
var text = "<b>"+params["title"]+ " : " + lrcMakeText("REPORTING_DONE") + "</b> <small>("+params["text"]+")</small>";
LiveRC_alert(text);
LiveRC_AskForRevisionDeleteFromHistExtension_CloseReasonForm();
}
/* *************************************************************************************************************************** */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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 de n'afficher que les modifications faites dans une ou plusieurs catégories
* Licence : ...?
* Documentation :
* Auteur : [[:fr:User:Dr Brains]]
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if (typeof(LiveRC_AddHook)!="undefined") { // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("CategoryRC");
/* ************************************************************************************************************************************************ */
// Options
try{
lrcOptionMenuValues["showCatRC"] = false;
}catch(e){ }
// textes
try{
lrcTexts["showCatRC_SHORT"] = "Catégories";
lrcTexts["showCatRC_TIP"] = "Filtrer les RC par catégorie";
lrcTexts["RCCategoryNoCat"] = "Vous devez sélectionner l’option « $1 » pour pouvoir filtrer par catégorie";
lrcTexts["CRC_DELETECAT_SHORT"] = "-";
lrcTexts["CRC_ADDCAT_SHORT"] = "+";
}catch(e){ }
// Descriptions
try{
lrcParamDesc["DescshowCatRC"] = '[CategoryRC] Case "Catégories"';
lrcParamDesc["DescshowCatRC_SHORT"] = '[CategoryRC] Texte de la case "Catégories"';
lrcParamDesc["DescshowCatRC_TIP"] = '[CategoryRC] Infobulle de la case "Catégories"';
lrcParamDesc["DescRCCategoryNoCat"] = "[CategoryRC] Avertissement paramétrage de LiveRC";
lrcParamDesc["DescCRC_DELETECAT_SHORT"] = "[CategoryRC] Texte du bouton pour supprimer une catégorie";
lrcParamDesc["DescCRC_ADDCAT_SHORT"] = "[CategoryRC] Texte du bouton pour ajouter une catégorie";
lrcParamDesc["DescLiveRC_defaultCats"] = "Catégories pour le filtrage des RC";
lrcParamDesc["DescLiveRC_defaultCats_short"] = "RC par catégorie";
}catch(e){ }
window.LiveRC_defaultCats = [
{cat:"Portail:Amérique/Articles liés", checked:true},
{cat:"Portail:Cinéma/Articles liés", checked:true},
{cat:"Portail:Europe/Articles liés", checked:true},
{cat:"Portail:Musique/Articles liés", checked:true}
];
window.LiveRC_defaultCats_Custom = new Array();
window.Custom_LiveRC_defaultCats = new Array();
window.defineCustomDefaultCats = function(defaultCats){
Custom_LiveRC_defaultCats = defaultCats;
}
LiveRC_AddHook("AfterFillParamPanel", function(){
LiveRC_ManageParams_Fill(LiveRC_defaultCats, "LiveRC_defaultCats", "defineCustomDefaultCats", true);
});
window.LiveRC_CategoryRC_CheckIfGetPageInfosEnabled = function(){
setTimeout("LiveRC_CategoryRC_AutoUncheckCatFilter();", 75);
}
window.LiveRC_CategoryRC_AutoUncheckCatFilter = function(){
var showCatRC = document.getElementById("showCatRC");
if(!showCatRC) return;
if(!showCatRC.checked) return;
if(!lrcMakeParam("GetPageInfos")){
var NoCatMessage = lrcMakeText("RCCategoryNoCat")
NoCatMessage = NoCatMessage.split("$1").join("<code>"+lrcMakeParamDescription("DescGetPageInfos")+"</code>");
LiveRC_alert(NoCatMessage);
showCatRC.checked = false;
disableAllCheckboxesInChecklist("showCatRC", "showCatRC_CheckList")
}
}
window.LiveRC_CategoryRC_AddButton = function(){
var NamespaceForm = document.getElementById('NamespaceForm');
if(!NamespaceForm) return;
var CategoryForm = document.createElement('form');
CategoryForm.id = "CategoryForm";
var Span = document.createElement("span");
Span.style.padding = "3px";
Span.title = lrcMakeText("showCatRC_TIP");
var NewInput = document.createElement('input');
NewInput.id = "showCatRC";
NewInput.type = "checkbox";
NewInput.onmouseup = LiveRC_CategoryRC_CheckIfGetPageInfosEnabled;
var NewLabel = document.createElement('label');
NewLabel.setAttribute('for', "showCatRC");
NewLabel.appendChild(document.createTextNode(lrcMakeText("showCatRC_SHORT")));
Span.appendChild(NewInput);
Span.appendChild(NewLabel);
CategoryForm.appendChild(Span);
NamespaceForm.parentNode.insertBefore(CategoryForm, NamespaceForm.nextSibling);
var SepSpan = document.createElement('span');
SepSpan.appendChild(document.createTextNode("·"));
NamespaceForm.parentNode.insertBefore(SepSpan, NamespaceForm.nextSibling);
if(lrcMakeOption("showCatRC") && lrcMakeParam("GetPageInfos")){
NewInput.checked = "checked";
}
addCatFilterCheckInMenu();
}
LiveRC_AddHook("AfterOptions", LiveRC_CategoryRC_AddButton);
window.addCatFilterCheckInMenu = function(){
var Lines = new Array();
var CheckList = createChecklistMenu("showCatRC", Lines);
var Li = document.createElement('li');
Li.style.textAlign = "right";
var AddCatInput = document.createElement('input');
AddCatInput.type = "button";
AddCatInput.style.width = "100%";
AddCatInput.value = lrcMakeText("CRC_ADDCAT_SHORT");
AddCatInput.onclick = function(){ LiveRC_CategoryRC_AddACat(this); };
AddCatInput.onselect = function(){ LiveRC_CategoryRC_AddACat(this); };
Li.appendChild(AddCatInput);
CheckList.appendChild(Li);
var defaultCats = LiveRC_defaultCats_Custom;
if(defaultCats.length===0) defaultCats = Custom_LiveRC_defaultCats;
if(defaultCats.length===0) defaultCats = LiveRC_defaultCats;
for(var a=0,l=defaultCats.length;a<l;a++){
var ThisItem = defaultCats[a];
var Cat = ThisItem["cat"];
var checked = (ThisItem["checked"] ? ' checked="checked" ' : '');
LiveRC_CategoryRC_AddACat(AddCatInput, Cat, checked);
};
LiveRC_SetCheckListPosition(CheckList.id);
}
window.LiveRC_CategoryRC_DeleteThisCat = function(DeleteInput){
var Li = DeleteInput.parentNode;
if(Li) Li.parentNode.removeChild(Li);
}
window.LiveRC_CategoryRC_AddACat = function(AddCatInput, Value, Checked){
var LastLi = AddCatInput.parentNode;
var Li = document.createElement('li');
var InputCheck = document.createElement("input");
InputCheck.type = "checkBox";
if(Checked) InputCheck.checked = "checked";
var Input = document.createElement("input");
Input.type = "text";
Input.size = 40;
Input.value = (Value ? Value : "");
var DeleteInput = document.createElement('input');
DeleteInput.type = "button";
DeleteInput.value = lrcMakeText("CRC_DELETECAT_SHORT");
DeleteInput.onclick = function(){ LiveRC_CategoryRC_DeleteThisCat(this); };
DeleteInput.onselect = function(){ LiveRC_CategoryRC_DeleteThisCat(this); };
Li.appendChild(InputCheck);
Li.appendChild(Input);
Li.appendChild(DeleteInput);
LastLi.parentNode.insertBefore(Li, LastLi);
LiveRC_Suggest_AddPageSuggestion({
"InputNode" : Input,
"NSFilter" : 14,
"StripNS" : true,
"ListDown" : true,
"AddExist" : true
});
LiveRC_Suggest_GetPageSuggestions(LiveRC_Suggest_GetSuggestionIndex(Input));
disableAllCheckboxesInChecklist("showCatRC", "showCatRC_CheckList");
}
window.LiveRC_CategoryRC_getCategories = function(){
var showCatRC = document.getElementById("showCatRC");
if(!showCatRC) return false;
if(!showCatRC.checked) return false;
var showCatList = document.getElementById("showCatRC_CheckList");
if(!showCatList) return false;
var Categories = new Array();
var Lis = showCatList.getElementsByTagName('li');
for(var a=0,l=Lis.length;a<l;a++){
var Li = Lis[a];
var CheckBox = Li.getElementsByTagName('input')[0];
var Input = Li.getElementsByTagName('input')[1];
var CatExist = Li.getElementsByTagName('input')[2];
if(!CheckBox || !Input || !CatExist) continue;
if(CatExist.value == "0") continue;
if(CheckBox.type != "checkbox") continue;
if(!CheckBox.checked) continue;
var Cat = Input.value;
if(!Cat) continue;
if(Categories.indexOf(Cat)==-1) Categories.push(lrcGetNamespaceName(14)+":"+Cat);
}
if(Categories.length===0) return false;
return Categories;
}
window.LiveRC_CategoryRC_filterRC = function(Args){
if(!lrcMakeParam("GetPageInfos")) return;
var showCatRC = document.getElementById("showCatRC");
if(!showCatRC) return;
if(!showCatRC.checked) return;
var ID = Args.id;
var TR = document.getElementById(ID);
if(!TR) return;
var Categories = LiveRC_CategoryRC_getCategories();
if(!Categories) return;
var rc = Args.rc;
var Cats = rc.categories;
if(typeof(Cats)!=="object" || Cats.length === 0){
TR.parentNode.removeChild(TR);
return;
}
var HasCat = false;
for(var a=0,l=Cats.length;a<l;a++){
if(Categories.indexOf(Cats[a])!=-1){
HasCat = true;
}
}
if(!HasCat) TR.parentNode.removeChild(TR);
}
LiveRC_AddHook("AfterRC", LiveRC_CategoryRC_filterRC);
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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'''
// Ajout de fonctions automatiques dans les pages de diff
{{Projet:JavaScript/Script|LiveRC}}
************************************************************************************************************************************************ */
if (typeof(LiveRC_AddHook)==="function" ) { // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("DiffExtension");
/* ************************************************************************************************************************************************ */
lrcParams["DiffExtensionShowConfigPanel"] = true;
lrcParamDesc["DescDiffExtensionShowConfigPanel"] = "[Diff] Ajoute un bouton pour ouvrir le menu de configuration";
window.LiveRC_DiffExtension_PreProcess = function(){
if(mw.config.get('wgNamespaceNumber')<0 || (mw.config.get('wgAction')!="view" && mw.config.get('wgAction') != "purge")) return;
if(mw.config.get('wgPageName').replace(/_/g, " ") == lrcMakeParam("PageTitle")) return;
var TableDiff = $('table.diff')[0];
var EditTextarea = document.getElementById('wpTextbox1');
if(!TableDiff || EditTextarea) return;
if(lrcMakeParam("DiffExtensionShowConfigPanel")){
LiveRC_Config["LaunchProcessForce"]["OldLocalCSS"] = true;
LiveRC_Config["LaunchProcessForce"]["OldPersonal"] = true;
LiveRC_Config["LaunchProcessForce"]["SiteInfos"] = true;
LiveRC_Config["LaunchProcessForce"]["Watchlist"] = true;
LiveRC_Config["LaunchProcessForce"]["MissingParams"] = true;
}
LiveRC_Config["LaunchProcessForce"]["UserInfos"] = true;
}
LiveRC_AddHook("BeforeInitActivationProcess", LiveRC_DiffExtension_PreProcess);
window.LiveRC_DiffExtension_Init = function(){
var LimitationsToCheck = ["Revert","Blank","Tag","Message","Thank","Report"];
var OK = false;
for(var a=0,l=LimitationsToCheck.length;a<l;a++){ if(lrcUserCan(LimitationsToCheck[a])) OK = true; }
if(!OK) return;
LiveRC_Config["LaunchProcess"].push({functions:LiveRC_DiffExtension_Build});
}
LiveRC_AddHook("AfterGotUserInfos", LiveRC_DiffExtension_Init);
window.LiveRC_DiffExtension_Build = function(){
var TableDiff = $('table.diff')[0];
if(!TableDiff) return LiveRC_LaunchProcessNextStep();
buildReportCreateReasons();
var Container = document.createElement('div');
Container.style.overflow = "hidden";
lrcaddCustomizableClasses(Container, "LiveRC_MenuAnchor");
var Control = document.createElement('table');
Control.id = "livePreviewFoot";
lrcaddCustomizableClasses(Control, "livePreviewFoot");
Control.style.width = "100%";
Control.style.fontSize = "12px";
Control.style.display = "block";
Control.appendChild(document.createElement('tr'));
Container.appendChild(Control);
TableDiff.parentNode.insertBefore(Container, TableDiff);
var ShowConfig = lrcMakeParam("DiffExtensionShowConfigPanel");
if(ShowConfig){
var ConfigTarget = document.createElement('div');
ConfigTarget.id = "LiveRCContainer";
ConfigTarget.innerHTML = '<div id="OutFixedBottomPanel"></div>';
document.body.appendChild(ConfigTarget);
var ConfigPanelLink = ''
+ '<div id="LiveRCButtons">'
+ '<span id="LiveRCConfigButtonOn" >'
+ '<span class="OnButton"><a href="#">'+lrcMakeIcon("ConfigButtonIcon")+'</a></span>'
+ '</span>'
+ ' '
+ '<span id="LiveRCConfigButtonOff" >'
+ '<span class="OffButton"><a href="#">'+lrcMakeIcon("ConfigButtonIcon")+'</a></span>'
+ '</span>'
+ '</div>';
AddButtonToControlBar(ConfigPanelLink);
lrcUpdateButton("LiveRCConfigButtonOff", false, function(){ LiveRC_ManageParams_OpenMenu(); return false; });
lrcUpdateButton("LiveRCConfigButtonOn", false, function(){ LiveRC_ManageParams_OpenMenu(); return false; });
lrcaddCustomizableClasses(document.getElementById("LiveRCButtons"), "LiveRCButtons");
lrcaddCustomizableClasses(document.getElementById("LiveRCContainer"), "LiveRCContainer");
lrcaddCustomizableClasses(document.getElementById("OutFixedBottomPanel"), "OutFixedBottomPanel");
}
var Page = mw.config.get('wgPageName').replace(/_/g, " ");
var User1 = document.getElementById('mw-diff-otitle2');
if (User1 != null) {
var User1link = User1.getElementsByTagName('a')[0];
if(User1link) User1 = $(User1link).text();
else User1 = false;
}
var User2 = document.getElementById('mw-diff-ntitle2');
if (User2 != null) {
var User2link = User2.getElementsByTagName('a')[0];
if(User2link) User2 = $(User2link).text();
else User2 = false;
}
var Oldid = document.getElementById('mw-diff-otitle1');
if (Oldid != null) {
Oldid = Oldid.getElementsByTagName('a')[0].href;
try{Oldid = decodeURIComponent(Oldid); }catch(e){ };
if(Oldid) Oldid = lrcGetArgFromURL(Oldid, "oldid");
else Oldid = false;
}
var User = User2;
var NextModifLink = document.getElementById("differences-nextlink");
var AllForms = new Array();
AllForms.push( buildLiveTag(Page) );
AllForms.push( buildLiveBlank(Page) );
if(!NextModifLink) AllForms.push( buildLiveUndo(Page, Oldid, User1, User2) );
AllForms.push( buildLiveAverto(Page, User, true) );
AllForms.push( buildReport(Page, User) );
for(var a=0,l=AllForms.length;a<l;a++){
var Sep = (a!==0 || ShowConfig);
AddButtonToControlBar(AllForms[a], Sep);
}
LiveRC_RevertMessagesExtension_Init();
LiveRC_BlankExtension_Init();
Control.onmouseover = function(){ lrcSetControlBarPosition(true); };
Control.onmouseout = function(){ lrcSetControlBarPosition(false); };
mw.loader.addStyleTag(".LiveRC_MenuAnchor #livePreviewFoot { background:none !important;border:none !important;}" );
LiveRC_RunHooks("AfterDiffExtension");
LiveRC_LaunchProcessNextStep();
}
/* ************************************************************************************************************************************************ */
} // FIN IF
/*
--------------------------------------------------------------------------------------
---------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 de rendre fonctionnels les caractères spéciaux lors de l'édition + autres boutons dans la toolbar
* Licence : ...?
* Documentation :
* Auteur : [[:fr:User:Dr Brains]]
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if (typeof(LiveRC_AddHook)==="function") { // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("EditCharactersExtension");
/* ************************************************************************************************************************************************ */
window.LiveRC_EditCharactersExtension_Init = function(){
if(typeof(addCharSubsetMenu)=="function") addCharSubsetMenu();
}
window.LiveRC_EditCharactersExtension_PreProcess = function(){
if (mw.config.get('wgPageName') == lrcMakeParam("PageTitle") && mw.config.get('wgAction')=="view") {
mw.loader.load("ext.gadget.CommonEdit");
LiveRC_AddHook("AfterPreviewEdit", LiveRC_EditCharactersExtension_Init);
}
}
LiveRC_AddHook("BeforeInitActivationProcess", LiveRC_EditCharactersExtension_PreProcess);
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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}}
<source lang=javascript> */
if(typeof(LiveRC_AddHook)==="function"){ // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("HotCatsMulti");
/* ************************************************************************************************************************************************ */
///////////////////////// VARIABLES ////////////////////////////////////////////////////////
//// PARAMÈTRES PERSONNALISABLES ////
window.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 Object();
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");
window.lrcHotCatsVariables_Custom = new Object();
window.Custom_lrcHotCatsVariables = new Object();
window.LiveRC_getHotCatsVariables = function(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.addStyleTag("" +
".RemovedCategory {" +
" text-decoration:line-through;" +
" background-color:#FF9999;" +
"} " +
".ModifiedCategory {" +
" background-color:#CCCC77;" +
"} " +
".AddedCategory {" +
" background-color:#99FF99;" +
"} " +
".ModifiedDefaultSort {" +
" background-color:#CCCC77;" +
"} " +
"#catlinks {" +
" text-align:left !important;" +
"} " +
"#catlinks div {" +
" text-align:left !important;" +
"} "
);
window.lrcRunHotCatsMulti = function(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{
lrcRemoveClass(catlinks, "catlinks-allhidden");
}
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);
}
window. lrcHotCats_AvoidEditMode = function(){
LiveRC_Config["HotCats"]["IsEditMode"] = false;
}
window.lrcHotCats_getCatCase = function(){
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("AfterPreviewInterwiki", lrcHotCats_AvoidEditMode);
LiveRC_AddHook("AfterOptions", lrcHotCats_getCatCase);
window.defineCustomHotCatsVariable = function(textcode, HotCatsVariable){
if(typeof(lrcHotCatsVariables[textcode])!=="undefined") Custom_lrcHotCatsVariables[textcode] = HotCatsVariable;
}
LiveRC_AddHook("AfterFillParamPanel", function(){
LiveRC_ManageParams_Fill(lrcHotCatsVariables, "lrcHotCatsVariables", "defineCustomHotCatsVariable");
});
window.lrcHotCats_TransformOptions = function(){
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);
//<source lang=javascript><pre><nowiki>
// RÉCUPÉRATION CLEF DE TRI GLOBALE
window.lrcHotCats_defaultSort_getOld = function(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
window.lrcHotCats_defaultSort_getOneOld = function(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)
window.lrcHotCats_getOldPageContent = function(Page, Mode){
var URL = lrcGetUglyPageURL(Page,'&action=raw');
wpajax.http({ url: URL,
async : Mode,
onSuccess: lrcHotCats_UpdateOldPageContent
});
}
window.lrcHotCats_UpdateOldPageContent = function(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"
window.lrcHotCats_append_firstlink = function( catline, plural) {
if (!catline.firstChild ){
var a = document.createElement('a');
a.href = lrcGetPageURL(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
window.lrcHotCats_modify_existing = function( 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 (±)
window.lrcHotCats_modify_span = function( 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] = !!(lrcHasClass(cat_link, "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 (+)
window.lrcHotCats_append_add_span = function(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
window.lrcHotCats_remove = function( 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(lrcHasClass(Span, "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 = lrcGetPageURL(lrcGetNamespaceName(14)+':'+OldCat);
lrcAddClass(FirstLink, 'RemovedCategory');
lrcRemoveClass(FirstLink, "ModifiedCategory")
if(LiveRC_Config["HotCats"]["Matrix"].CatLinkIsRed[Index]){
if(!lrcHasClass(FirstLink, "new")) lrcAddClass(FirstLink, "new");
}else{
lrcRemoveClass(FirstLink, "new");
}
}
lrcHotCats_Multi_CheckForChanges();
}
}
// MODIFICATION D'UNE CATÉGORIE
window.lrcHotCats_modify = function( 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
window.lrcHotCats_add_new = function(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
window.lrcHotCats_create_new_span = function( thespan , init_text, Index ) {
var DefaultSort = lrcHotCats_defaultSort_getOneOld(init_text);
if(lrcHasClass(thespan, "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
window.lrcHotCats_ok = function(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 = lrcHasClass(IfExist, "lrcHotCats_Exists");
if(TheSpan.id!="lrcHotCats_add"){
CatLink.innerHTML = NewCatName;
CatLink.title = lrcGetNamespaceName(14)+':'+NewCatName;
CatLink.href = lrcGetPageURL(lrcGetNamespaceName(14)+':'+NewCatName);
if((!lrcHasClass(CatLink, "AddedCategory"))&&(!lrcHasClass(CatLink, "ModifiedCategory"))) lrcAddClass(CatLink,"ModifiedCategory");
if((OldCatName+OldDefaultSort)==(NewCatName+NewDefaultSort)){
lrcRemoveClass(CatLink,"ModifiedCategory");
}
lrcRemoveClass(CatLink,"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 = lrcGetPageURL(lrcGetNamespaceName(14)+':'+NewCatName);
lrcAddClass(CatLink,"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){
lrcAddClass(CatLink,"new");
}else{
lrcRemoveClass(CatLink,"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
window.lrcHotCats_cancel = function(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 (±)
window.lrcHotCats_append_multiedit_span = function( 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);
Span.parentNode.insertBefore(DefaultSortSpan, Span.nextSibling);
Span.parentNode.insertBefore(document.createTextNode(" "), Span.nextSibling);
if(LiveRC_getHotCatsVariables("HC_AutoMulti")) lrcHotCats_multiedit_createForm();
}
// CREATION DU FORMULAIRE "MULTI"
window.lrcHotCats_multiedit_createForm = function(){
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(!lrcHasClass(LiveRC_Config["HotCats"]["Matrix"].CatLink[a], "new")) lrcAddClass(LiveRC_Config["HotCats"]["Matrix"].CatLink[a], "new");
}else{
lrcRemoveClass(LiveRC_Config["HotCats"]["Matrix"].CatLink[a], "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
window.lrcHotCats_multiedit_CancelForm = function(){
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(lrcHasClass(CatSpans[a], "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";
lrcRemoveClass(CatLinks[a], "RemovedCategory");
if(lrcHasClass(CatLinks[a], "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 = lrcGetPageURL(lrcGetNamespaceName(14)+':'+OldCatName);
lrcRemoveClass(CatLinks[a], "ModifiedCategory");
}
if(lrcHasClass(CatLinks[a], "ModifiedDefaultSort")){
var DefaultSortSpan = document.getElementById("OldDefaultSortSpan");
DefaultSortSpan.innerHTML = LiveRC_Config["HotCats"]["OldDefaultSort"];
lrcRemoveClass(CatLinks[a], "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(!lrcHasClass(LiveRC_Config["HotCats"]["Matrix"].CatLink[a], "new")) lrcAddClass(LiveRC_Config["HotCats"]["Matrix"].CatLink[a], "new");
}else{
lrcRemoveClass(LiveRC_Config["HotCats"]["Matrix"].CatLink[a], "new");
}
}
LiveRC_Config["HotCats"]["Multi_Edit"] = false;
Link.focus();
}
// VALIDATION DU FORMULAIRE "MULTI" + LISTING DES CATÉGORIES À ENLEVER/MODIFIER/AJOUTER
window.lrcHotCats_multiedit_FormOK = function(){
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(lrcHasClass(Link, "RemovedCategory")){
var RemovedCat = (LiveRC_Config["HotCats"]["CaseSensitive"] ? Link.innerHTML : Link.innerHTML.ucFirst());
RemovedCategories.push(RemovedCat);
}
if(lrcHasClass(Link, "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(lrcHasClass(Link, "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(lrcHasClass(Link, "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
window.lrcHotCats_Multi_CheckForChanges = function(){
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((lrcHasClass(Link, "RemovedCategory"))||(lrcHasClass(Link, "ModifiedCategory"))||(lrcHasClass(Link, "AddedCategory"))||(lrcHasClass(Link, "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
window.lrcHotCats_defaultSort_createForm = function(){
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
window.lrcHotCats_Default_Cancel = function(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"];
lrcRemoveClass(Span.getElementsByTagName('a')[0], "ModifiedDefaultSort");
Span.getElementsByTagName('a')[0].style.display = "";
lrcHotCats_Multi_CheckForChanges();
}
document.getElementById("lrcHotCats_DefaultSort_Link").focus();
}
// VALIDATION FORMULAIRE CLEF DE TRI GLOBALE
window.lrcHotCats_Default_ok = function(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 = "";
lrcAddClass(Link, "ModifiedDefaultSort");
Form.parentNode.removeChild(Form) ;
lrcHotCats_Multi_CheckForChanges();
lrcHotCats_upDate_FormPositions();
document.getElementById("lrcHotCats_DefaultSort_Link").focus();
}
}
}
///////////////////////// ÉDITION ////////////////////////////////////////////////////////
window.lrcHotCats_Edit = function(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"]);
}
window.lrcHotCats_DoEdit = function(){
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 = '';
for (var lineId = lines.length - 1; lineId >= 0; --lineId){
if (!interWiki.test(lines[lineId]) && !blank.test(lines[lineId])){
DebutModele = lines.slice(0, lineId + 1).join('\n') + '\n\n';
SuiteModele = lines.slice(lineId + 1).join('\n');
break;
}
}
if (DebutModele === '') {
// edge case: source has nothing else than interwikis
SuiteModele = OldText;
}
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 = '';
for (var lineId = lines.length - 1; lineId >= 0; --lineId){
if (!interWiki.test(lines[lineId]) && !blank.test(lines[lineId])){
DebutModele = lines.slice(0, lineId + 1).join('\n') + '\n\n';
SuiteModele = lines.slice(lineId + 1).join('\n');
break;
}
}
if (DebutModele === '') {
// edge case: source has nothing else than interwikis
SuiteModele = OldText;
}
SuiteModele = SuiteModele.replace(/^\n/, "");
OldText = DebutModele + 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 = lrcGetAPIURL('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);
window.lrcHotCats_EditDone = function(Req, data){
var Page = data.page;
liveArticle(Page);
}
///////////////////////// SUGGESTIONS ////////////////////////////////////////////////////////
// REQUÊTE DE SUGGESTIONS
window.lrcHotCatsText_changed = function(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 = text.value
v = lrcHotCats_deleteUnwantedUnicodeChars(v);
if(getNamespaceInfoFromPage(v) == 14) v = getNamespaceInfoFromPage(v, "PageName");
v = (LiveRC_Config["HotCats"]["CaseSensitive"] ? v : v.ucFirst());
text.value = v;
if(v.indexOf("|")!=-1) v = v.split("|")[0];
var APILimit = LiveRC_Config["UserInfos"].APIlimit;
if(LiveRC_getHotCatsVariables("HC_list_items")>APILimit) lrcHotCatsVariables_Custom.list_items = APILimit; // API max
if(Mode=="UP"){ // Suggestions catégories-mères
var URL = "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 = "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 = "format=xml&action=query&list=allpages&apnamespace=14&apfrom=" + encodeURIComponent(v) + "&aplimit=" + LiveRC_getHotCatsVariables("HC_list_items");
var TagName = "p";
var Replace = true;
}
if ( v != "" ) {
LiveRC_Config["HotCats"]["suggest_running"] = 1 ;
wpajax.http({ url: lrcGetAPIURL(URL),
onSuccess: lrcHotCatsText_changed_getSuggests,
mode:Mode,
tag:TagName,
index:FormIndex,
replace:Replace,
titles:titles
});
} else {
lrcHotCats_show_suggestions ( titles , FormIndex, Replace ) ;
}
}
// RECEPTION REQUETE
window.lrcHotCatsText_changed_getSuggests = function(Req, data){
var Mode = data.mode;
var TagName = data.tag;
var FormIndex = data.index;
var Replace = data.replace;
var titles = data.titles;
var xml = Req.responseXML ;
if ( xml == null ){ LiveRC_Config["HotCats"]["suggest_running"] = 0; 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);
}
LiveRC_Config["HotCats"]["suggest_running"] = 0;
}
// AFFICHAGE DES SUGGESTIONS
window.lrcHotCats_show_suggestions = function( 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(" ");
$(icon).addClass("lrcHotCats_NoExists");
$(icon).removeClass("lrcHotCats_Exists");
}
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(" ") ;
$(icon).addClass("lrcHotCats_Exists");
$(icon).removeClass("lrcHotCats_NoExists");
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(" ");
$(icon).addClass("lrcHotCats_NoExists");
$(icon).removeClass("lrcHotCats_Exists");
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
window.lrcHotCats_upDate_FormPositions = function(){
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
window.lrcHotCats_KeypressedOnList = function(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
window.lrcHotCatsText_replace = function(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
window.lrcHotCats_getIndex = function( Element ){
return parseInt(Element.id.replace(/[^0-9]/g, ""));
}
// GESTION {{PLURAL:}} (MESSAGES SYSTÈME)
window.lrcHotCats_PLURAL = function(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)
window.lrcHotCats_GENDER = function(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
window.lrcHotCats_CreateRegExp = function(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);
}
// Retrait de caractères unicode indésirables
window.lrcHotCats_deleteUnwantedUnicodeChars = function(Text){
return Text.replace(/\u200E|\u200F|\u202A|\u202B|\u202C|\u202D|\u202E/g, '');
}
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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'''
Ajoute une icône à côté des articles modifiés par plus de 5 personnes différentes durant la dernière heure
* Licence : ...?
* Documentation :
* Auteur : [[:fr:User:Dr Brains]]
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if(typeof(LiveRC_AddHook)==="function"){ // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("MostModifiedPagesExtension");
/* ************************************************************************************************************************************************ */
// Paramètres
try{
lrcParams["MostModifiedPagesRun"] = true;
lrcParams["MostModifiedPagesDelay"] = 1;
lrcParams["MostModifiedPagesUserLimit"] = 4;
lrcParams["MostModifiedPagesRevertLimit"] = 2;
}catch(e){ }
// Textes
try{
lrcTexts["MostModifiedIcon_Title"] = "$1 éditeurs $2 : $3";
lrcTexts["MostRevertedIcon_Title"] = "$1 reverts $2 : $3";
lrcTexts["MostModifiedHours"] = "durant les $1 dernières heures";
lrcTexts["MostModifiedHour"] = "durant la dernière heure";
}catch(e){ }
// Icônes
try{
lrcIcons["MostModifiedIcon"] = {"type":0,
"src":"thumb/1/16/Co-op_activism4.svg/12px-Co-op_activism4.svg.png",
"width":12,
"height":12
}
lrcIcons["MostRevertedIcon"] = {"type":0,
"src":"thumb/9/98/Tango-grenade.svg/12px-Tango-grenade.svg.png",
"width":12,
"height":12
}
}catch(e){ }
// Descriptions
try{
lrcParamDesc["DescMostModifiedPagesRun"] = "[MostModified] Charger l’historique des pages (coûteux)";
lrcParamDesc["DescMostModifiedPagesDelay"] = "[MostModified] Nombre d’heures d’historique à charger";
lrcParamDesc["DescMostModifiedPagesUserLimit"] = "[MostModified] Limite d’utilisateurs pour les pages très modifiées";
lrcParamDesc["DescMostModifiedPagesRevertLimit"] = "[MostModified] Limite de reverts pour les pages très revertées";
lrcParamDesc["DescMostModifiedIcon"] = "[MostModified] Page très modifiée";
lrcParamDesc["DescMostRevertedIcon"] = "[MostModified] Possible guerre d’édition";
lrcParamDesc["DescMostModifiedIcon_Title"] = "[MostModified] Infobulle de l’icône pour pages très modifiées";
lrcParamDesc["DescMostRevertedIcon_Title"] = "[MostModified] Infobulle de l’icône pour pages en guerre d’édition";
lrcParamDesc["DescMostModifiedHours"] = '[MostModified] Texte "durant les X dernières heures" (pluriel)';
lrcParamDesc["DescMostModifiedHour"] = '[MostModified] Texte "durant la dernière heure" (singulier)';
}catch(e){ }
window.MostModifiedPagesExtension_GetTimestamp = function(TS){
var Year = parseInt(TS.substring(0, 4));
var Month = parseInt(TS.substring(5, 7).replace(/^0/, ""));
var Day = parseInt(TS.substring(8, 10).replace(/^0/, ""));
var Hour = parseInt(TS.substring(11, 13).replace(/^0/, ""));
var Minut = parseInt(TS.substring(14, 16).replace(/^0/, ""));
var DaysinMonth = {"1" :31,
"2" :28,
"3" :31,
"4" :30,
"5" :31,
"6" :30,
"7" :31,
"8" :31,
"9" :30,
"10":31,
"11":30,
"12":31
}
if(Year%4==0 && (Year%100!=0 || Year%400==0) ) DaysinMonth[2]=29;
Hour = Hour-lrcMakeParam("MostModifiedPagesDelay");
if(Hour==-1){
Hour = Hour + 24;
Day = Day-1;
if(Day == 0){
Month = Month-1;
if(Month==0){
Month = 12;
Year = Year-1;
}
Day = DaysinMonth[Month];
}
}
var ThisTimestamp = "" + Year
+ (Month<10 ? "0"+Month : Month)
+ (Day <10 ? "0"+Day : Day )
+ (Hour <10 ? "0"+Hour : Hour )
+ (Minut<10 ? "0"+Minut : Minut)
+ "00";
return ThisTimestamp;
}
window.MostModifiedPagesExtension_GetInfos = function(Args){
if(!lrcMakeParam("MostModifiedPagesRun")) return;
var tr1 = document.getElementById(Args.id);
if (!tr1) return;
var rc = Args.rc;
var article = rc.title;
var continuevalue = Args.mustcontinue;
if(!continuevalue) continuevalue = '';
var TS = MostModifiedPagesExtension_GetTimestamp(rc.timestamp);
var URL = lrcGetAPIURL('format=xml&action=query')
+ '&prop=revisions&titles='+encodeURIComponent(article)
+ '&rvlimit='+LiveRC_Config["UserInfos"].APIlimit
+ '&rvend='+TS
+ '&rvprop=user|comment'
+ continuevalue
+ '&continue=';
if(!Args.users) Args.users = [];
if(!Args.reverts) Args.reverts =[];
lrcDisplayDebug("Get page revisions : " + article + " " + continuevalue);
wpajax.http({ url: URL,
onSuccess: MostModifiedPagesExtension_AddIcon,
page: article,
Args: Args
});
}
LiveRC_AddHook("AfterRC", MostModifiedPagesExtension_GetInfos);
window.MostModifiedPagesExtension_AddIcon = function(Req, data){
var Args = data.Args
var rc = Args.rc;
var TR = document.getElementById(Args.id);
if (!TR) return;
var ObjetXML = Req.responseXML;
if(!ObjetXML) return;
var Modifs = ObjetXML.getElementsByTagName('rev');
for(var a=0,l=Modifs.length;a<l;a++){
var User = Modifs[a].getAttribute('user');
if(Args.users.indexOf(User)==-1) Args.users.push(User);
var Comment = Modifs[a].getAttribute("comment");
var rc = new Object();
rc.state = new Array();
if (typeof(Comment) != "undefined") {
var CommentTests = Custom_commenttests;
if(CommentTests.length===0) CommentTests = commenttests;
for(var j=0,lenj = CommentTests.length; j<lenj; j++)
if(new RegExp(CommentTests[j].regex).test(Comment))
rc.state = lrcAddState(rc.state, CommentTests[j].state);
}
if(lrcHasState(rc.state, "REVERT")) Args.reverts.push(User);
}
var ContinueTag = ObjetXML.getElementsByTagName('continue')[0];
if(ContinueTag){
Args.mustcontinue = "&rvcontinue=" + encodeURIComponent(ContinueTag.getAttribute('rvcontinue'));
MostModifiedPagesExtension_GetInfos(Args);
}else{
MostModifiedPagesExtension_AddIcons(Args);
}
}
window.MostModifiedPagesExtension_AddIcons = function(Args){
var Users = Args.users;
var Reverts = Args.reverts;
var IconsToAdd = new Array();
var HourParam = lrcMakeParam("MostModifiedPagesDelay");
var HourParamText = lrcMakeText("MostModifiedHour"+(HourParam>1 ? "s" : "")).split("$1").join(HourParam);
if(Users.length>lrcMakeParam("MostModifiedPagesUserLimit")){
var UbuttonIcon = lrcMakeIcon("MostModifiedIcon", {after:' '});
UbuttonIcon = UbuttonIcon.split("$1").join(Users.length);
UbuttonIcon = UbuttonIcon.split("$2").join(HourParamText);
UbuttonIcon = UbuttonIcon.split("$3").join(Users.join(" - "));
IconsToAdd.push(UbuttonIcon);
}
if(Reverts.length>lrcMakeParam("MostModifiedPagesRevertLimit")){
var RbuttonIcon = lrcMakeIcon("MostRevertedIcon", {after:' '});
RbuttonIcon = RbuttonIcon.split("$1").join(Reverts.length);
RbuttonIcon = RbuttonIcon.split("$2").join(HourParamText);
RbuttonIcon = RbuttonIcon.split("$3").join(Reverts.join(" - "));
IconsToAdd.push(RbuttonIcon);
}
if(IconsToAdd.length>0) LiveRC_AddIconBeforeArticleLink(Args, IconsToAdd);
}
window.LiveRC_AddIconBeforeArticleLink = function(Args, IconsToAdd){
var TR = document.getElementById(Args.id);
if (!TR || typeof(IconsToAdd)!= "object") return;
var ArticleLink = lrcGetElementsByClass("lrc_ArticleLink", TR, "a")[0];
if(!ArticleLink) return;
var Icons = document.createElement('span');
Icons.innerHTML = IconsToAdd.join("");
ArticleLink.parentNode.insertBefore(Icons, ArticleLink);
}
window.MostModifiedPagesExtension_TransformOptions = function(){
var InputsToTransform = new Array();
var Options = new Array();
for(var a=1,l=25;a<l;a++) Options.push({value:a,text:a});
InputsToTransform["MostModifiedPagesDelay"] = Options;
LiveRC_ManageParams_CheckInputsToTransform(InputsToTransform);
}
LiveRC_AddHook("AfterCreateParamPanel", MostModifiedPagesExtension_TransformOptions);
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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'''
Tous les liens internes de la prévisualisation lancent une prévisualisation
* Licence : ...?
* Documentation :
* Auteur : [[:fr:User:Dr Brains]]
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if(typeof(LiveRC_AddHook)==="function"){ // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("PreviewAllLinksExtension");
/* ************************************************************************************************************************************************ */
lrcTexts["LIVELINK"] = ' (live)';
window.DebugLimit = 5;
window.DebugIndex = 0;
window.LinkHasClass = function(node, classNames) {
if(!node || !node.classList){
return false;
}
for(var a=0,l=classNames.length;a<l;a++){
if(node.classList.contains(classNames[a])){
return true;
}
}
return false;
}
window.liveAllLinks = function(){
var Element = document.getElementById("livePreview");
if(!Element) return;
var Toc = getElementWithId("toc", "table", Element);
if(Toc){
var TocLinks = Toc.getElementsByTagName("a");
for(var a=0,l=TocLinks.length;a<l;a++){
if(TocLinks[a].href.indexOf('javascript:') != 0)
TocLinks[a].href = "javascript:;";
}
}
var Links = Element.getElementsByTagName("a");
for(var a=0,l=Links.length;a<l;a++){
var Url = Links[a].href;
if(!Url) continue;
try{ Url = decodeURIComponent(Url); }catch(e){ }
if(Url.indexOf("#")!=-1){
Links[a].href = Url.substring(0, Url.indexOf("#"));
}
if(Links[a].href == "") Links[a].href = "javascript;";
if(
LinkHasClass(Links[a].parentNode, new Array("reference", "mw-cite-backlink")) ||
LinkHasClass(Links[a].parentNode.parentNode, new Array("mw-cite-backlink"))
){
var NewLink = document.createElement('a');
NewLink.href = "javascript;";
NewLink.innerHTML = Links[a].innerHTML;
Links[a].parentNode.insertBefore(NewLink,Links[a]);
Links[a].style.display = "none";
}
if(!(
LinkHasClass(Links[a].parentNode, new Array('cachelinks', "patrollink")) ||
LinkHasClass(Links[a], new Array('noprint', 'external')) ||
Links[a].href.indexOf('javascript:') == 0 ||
Links[a].href == "#"
)){
lrcAddClass(Links[a], "PreviewAllLinks_ModifiedLink");
Links[a].title = (Links[a].title ? Links[a].title + lrcMakeText("LIVELINK") : lrcMakeText("LIVELINK"));
Links[a].onclick = function(){
return liveModifyLinks(this);
}
}
}
}
window.liveModifyLinks = function(Link, test){
var Href = Link.href;
try{ Href = decodeURIComponent(Href); }catch(e){ }
var ArticlePath = mw.config.get('wgArticlePath').split("$1").join("");
var ArticleReg = new RegExp(".*"+ArticlePath.replace(/\//g, "\\\/"));
var ScriptReg = new RegExp(".*"+mw.config.get('wgScript').replace(/\//g, "\\\/")+"\\?");
Href = Href.replace(ArticleReg, "");
Href = Href.replace(ScriptReg, "");
if(Href.indexOf("title=")==-1) Href = "title=" + Href;
if(Href.match(/^http/)!=null) return false;
var Onclick = "";
var Params = new Array();
var URL = Href.split("&");
for(var a=0,l=URL.length;a<l;a++){
if(URL[a].indexOf("=")==-1) continue;
var ParamName = URL[a].split("=")[0];
var ParamValue = URL[a].split("=")[1];
Params[ParamName] = ParamValue;
}
if(Params["title"]) Params["title"] = Params["title"].replace(/_/g, " ");
if(Params["action"]){
if(Params["action"]=="edit"){
var EditParams = "";
if(Params["oldid"]) EditParams += "&oldid="+Params["oldid"];
if(Params["section"]) EditParams += "§ion="+Params["section"];
if(Params["redlink"]) EditParams += "&redlink="+Params["redlink"];
Onclick = 'liveEdit('+lrcEscapeStr(Params["title"])+(EditParams ? ',\''+EditParams+'\'' : '')+')';
}
if(Params["action"]=="delete"){
Onclick = 'liveDelete('+lrcEscapeStr(Params["title"])+')';
}
if(Params["action"]=="protect"){
Onclick = 'liveProtect('+lrcEscapeStr(Params["title"])+')';
}
if(Params["action"]=="historysubmit"){
Onclick = 'liveDiff('+lrcEscapeStr(Params["title"])+','+lrcEscapeStr(Params["diff"])+','+lrcEscapeStr(Params["oldid"])+')';
}
}else{
var PageNamespaceNumber = getNamespaceInfoFromPage(Params["title"]);
var PageName = getNamespaceInfoFromPage(Params["title"], "PageName");
if(PageNamespaceNumber==-1){
if(PageName.indexOf("Movepage")!=-1 || PageName.indexOf("Renommer une page")!=-1){
var Page = PageName.replace(/[^\/]*\//, "");
Onclick = 'liveMove('+lrcEscapeStr(Page)+');';
}
if(PageName.indexOf("Contributions")!=-1){
var Page = Params["target"];
if(Page) Page = PageName.replace(/[^\/]*\//, "");
if(PageName.indexOf("DeletedContributions")!=-1 || PageName.indexOf("Contributions supprimées")!=-1){
Onclick = 'liveDeletedContrib('+lrcEscapeStr(Page)+');';
}else{
Onclick = 'liveContrib('+lrcEscapeStr(Page)+');';
}
}
if(PageName.indexOf("Blockip")!=-1 || PageName.indexOf("Bloquer")!=-1){
var Page = PageName.replace(/[^\/]*\//, "");
Onclick = 'liveBlock('+lrcEscapeStr(Page)+');';
}
if(PageName.indexOf("Log")!=-1 || PageName.indexOf("Journal")!=-1){
var Type = Params["type"];
var Page = Params["page"];
var User = Params["user"];
if(Page) Onclick = 'liveLog(\''+Type+'\',{page:'+lrcEscapeStr(Page)+',user:'+lrcEscapeStr(User)+'});';
}
}else{
if(Params["diff"]&&Params["oldid"]){
Onclick = 'liveDiff('+lrcEscapeStr(Params["title"])+','+lrcEscapeStr(Params["diff"])+','+lrcEscapeStr(Params["oldid"])+');';
}
if(Params["title"] && URL.length==1){
Onclick = 'liveArticle('+lrcEscapeStr(Params["title"])+');';
}
}
}
if(Onclick == ""){
var TitleCustom = (Params["title"] ? ','+lrcEscapeStr(Params["title"]) : "");
Onclick = 'liveCustom('+lrcEscapeStr(Link.href) + TitleCustom +');';
}
try{ eval(Onclick); }catch(e){ }
return false;
}
window.liveCustom = function(URL, Title){
lrcAddToHistory("liveCustom",new Array(lrcEscapeStr(URL), lrcEscapeStr(Title)), URL, Title);
if(!Title){
var ArticleReg = new RegExp(".*"+mw.config.get('wgArticlePath').split("$1").join("").replace(/\//g, "\\\/"));
var ScriptReg = new RegExp(".*"+mw.config.get('wgScript').replace(/\//g, "\\\/")+"\\?");
try{ Title=URL.replace(ArticleReg, "").replace(ScriptReg, ""); }catch(e){ }
}
if(!Title) Title = URL;
buildBlanckPreviewBar("<b style='text-decoration: blink;'>Custom : <span style='color:red'>"+Title+"</span>...</b>");
wpajax.http({url: URL,
onSuccess: getCustom,
onFailure: getCustom,
title:Title});
}
window.getCustom = function(xmlreq, data){
var c = data.title;
if(c) buildBlanckPreviewBar('<b><a href="'+lrcGetPageURL(c)+'" target="_new">'+c+'</a></b>', true);
var bC = getPageContent(xmlreq);
var PreviewWindow = document.getElementById("livePreview");
PreviewWindow.innerHTML = "";
PreviewWindow.innerHTML = bC.innerHTML;
lrcCloseAll();
lrcAddClass(document.body, "LiveRCPreviewDisplayed");
updatePreviewWindowAttributes();
liveAllLinks();
}
////////////////////////////////////////// HOOKS
LiveRC_AddHook("AfterPreviewArticle", liveAllLinks);
LiveRC_AddHook("AfterPreviewDiff", liveAllLinks);
LiveRC_AddHook("AfterPreviewHistory", liveAllLinks);
LiveRC_AddHook("AfterPreviewContribs", liveAllLinks);
LiveRC_AddHook("AfterPreviewDeletedContribs", liveAllLinks);
LiveRC_AddHook("AfterPreviewEdit", liveAllLinks);
LiveRC_AddHook("AfterPreviewMove", liveAllLinks);
LiveRC_AddHook("AfterPreviewProtect", liveAllLinks);
LiveRC_AddHook("AfterPreviewDelete", liveAllLinks);
LiveRC_AddHook("AfterPreviewBlock", liveAllLinks);
LiveRC_AddHook("AfterPreviewRevisiondelete", liveAllLinks);
LiveRC_AddHook("AfterPreviewWhatlinkshere", liveAllLinks);
LiveRC_AddHook("AfterPreviewLog", liveAllLinks);
LiveRC_AddHook("AfterPreviewFilter", liveAllLinks);
// LiveRC_AddHook("AfterPreviewFeedback", liveAllLinks);
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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'''
Ajoute un champ de texte dans le menu d'options pour visualiser n'importe quelle page
* Licence : ...?
* Documentation :
* Auteur : [[:fr:User:Dr Brains]]
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if (typeof(LiveRC_AddHook)==="function") { // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("PreviewThisPageExtension");
/* ************************************************************************************************************************************************ */
// textes
try{
lrcTexts["PTP_StartButton_TIP"] = "Prévisualiser une page";
lrcTexts["PTP_StartButton_SHORT"] = "P";
lrcTexts["PTP_TextInput_TIP"] = "Inscrire le nom de la page à prévisualiser";
lrcTexts["PTP_OKButton_TIP"] = "Prévisualiser cette page";
lrcTexts["PTP_OKButton_SHORT"] = "OK";
}catch(e){ }
// Descriptions
try{
lrcParamDesc["DescPTP_StartButton_TIP"] = "[PreviewThisPage] Infobulle du bouton de prévisualisation de page";
lrcParamDesc["DescPTP_StartButton_SHORT"] = "[PreviewThisPage] Texte du bouton de prévisualisation de page";
lrcParamDesc["DescPTP_TextInput_TIP"] = "[PreviewThisPage] Infobulle du champ de prévisualisation de page";
lrcParamDesc["DescPTP_OKButton_TIP"] = "[PreviewThisPage] Infobulle du bouton de validation de la prévisualisation de page";
lrcParamDesc["DescPTP_OKButton_SHORT"] = "[PreviewThisPage] Texte du bouton de validation de la prévisualisation de page";
}catch(e){ }
window.LiveRC_PreviewThisPageExtension_AddButton = function(){
var ButtonList = [
{id : "StartButton", text : lrcMakeText("PTP_StartButton_SHORT") , title : lrcMakeText("PTP_StartButton_TIP") },
{id : "TextInput", text : "" , title : lrcMakeText("PTP_TextInput_TIP") },
{id : "OKButton", text : lrcMakeText("PTP_OKButton_SHORT") , title : lrcMakeText("PTP_OKButton_TIP") }
];
var Form = document.createElement('form');
Form.id = "PreviewThisPageButtons"
for(var a=0,l=ButtonList.length;a<l;a++){
var Input = document.createElement('input');
Input.type = (a==1 ? "text" : "button");
Input.id = "PreviewThisPage_"+ ButtonList[a]["id"];
Input.value = ButtonList[a]["text"];
Input.title = ButtonList[a]["title"];
Input.setAttribute('style', 'padding:0;');
Form.appendChild(Input);
if(a==0){
Input.onclick = function(){
LiveRC_PreviewThisPageExtension_ShowHide();
}
Input.onselect = function(){
LiveRC_PreviewThisPageExtension_ShowHide();
}
}
if(a==1){
LiveRC_Suggest_AddPageSuggestion({"InputNode": Input, "ListDown" : true, "AddExist" : true });
}
if(a==2){
Input.onclick = function(){
LiveRC_PreviewThisPageExtension_Preview();
}
Input.onselect = function(){
LiveRC_PreviewThisPageExtension_Preview();
}
}
}
AddButtonToControlBar(Form, true);
Form.onsubmit = function(){
LiveRC_PreviewThisPageExtension_Preview();
return false;
}
LiveRC_PreviewThisPageExtension_ShowHide();
}
window.LiveRC_PreviewThisPageExtension_ShowHide = function(){
var Input = document.getElementById("PreviewThisPageButtons").firstChild;
var Element = Input.nextSibling;
while(Element){
if(Element.type !== "hidden"){
if(Element.style.display == "none"){
if(!lrcHasClass(Element, "SuggestionList")) Element.style.display = "";
}else{
Element.style.display = "none";
}
}
Element = Element.nextSibling;
if(!Element) break;
}
}
window.LiveRC_PreviewThisPageExtension_Preview = function(){
var Input = false;
var Inputs = document.getElementById("PreviewThisPageButtons").getElementsByTagName("input");
for(var a=0,l=Inputs.length;a<l;a++){
var ThisInput = Inputs[a];
var Type = ThisInput.type;
if(Type=="text") Input = ThisInput;
}
if(!Input) return;
var Value = Input.value;
if(!Value) return;
var NS = getNamespaceInfoFromPage(Value);
if(NS==-1) return;
liveArticle(Value);
LiveRC_PreviewThisPageExtension_ShowHide();
}
LiveRC_AddHook("AfterOptions", LiveRC_PreviewThisPageExtension_AddButton);
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>
/*
--------------------------------------------------------------------------------------
---------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 du Common.js :
* Modèle {{Animation}},
* Géolocalisation multiple,
* Boîtes déroulantes,
* Palettes de navigation.
* Licence : ...?
* Documentation :
* Auteur : [[:fr:User:Dr Brains]]
* Développement et maintenance :
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if (typeof LiveRC_AddHook === 'function') {
LiveRC_Config['InstalledLiveRCExtensions'].push('RunCommonJS');
/* ************************************************************************************************************** */
window.RunCommonJS = function () {
if (mw.config.get('wgPageName') !== lrcMakeParam('PageTitle')) return;
var $preview = $('#livePreview');
if (!$preview.length) return;
// Modèle {{Animation}}
if ($preview.find('.diaporama').length) {
mw.loader.using('ext.gadget.Diaporama', function () {
Diaporama_Init($preview);
});
}
GeoBox_Init($preview); // Géolocalisation multiple
BoiteDeroulante($preview); // Boîtes déroulantes
Palette($preview); // Palettes de navigation
};
//////////////////// HOOKS
LiveRC_AddHook('AfterPreviewDiff', RunCommonJS);
LiveRC_AddHook('AfterPreviewArticle', RunCommonJS);
LiveRC_AddHook('AfterPreviewHistory', RunCommonJS);
LiveRC_AddHook('AfterPreviewContribs', RunCommonJS);
LiveRC_AddHook('AfterPreviewDeletedContribs', RunCommonJS);
LiveRC_AddHook('AfterPreviewEdit', RunCommonJS);
LiveRC_AddHook('AfterPreviewLog', RunCommonJS);
LiveRC_AddHook('AfterPreviewFilter', RunCommonJS);
LiveRC_AddHook('AfterPreviewMove', RunCommonJS);
LiveRC_AddHook('AfterPreviewProtect', RunCommonJS);
LiveRC_AddHook('AfterPreviewDelete', RunCommonJS);
LiveRC_AddHook('AfterPreviewBlock', RunCommonJS);
LiveRC_AddHook('AfterPreviewRevisiondelete', RunCommonJS);
LiveRC_AddHook('AfterPreviewWhatlinkshere', RunCommonJS);
LiveRC_AddHook('AfterPreviewFeedback', RunCommonJS);
/* ************************************************************************************************************** */
}
//</source>
/* ************************************************************************************************************************************************
--------------------------------------------------------------------------------------
---------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------------
--------------------------------------------------------------------------------------
// LiveRC extension
// This is an example of extension
// using hooks related to special log lists
//
// change all "SpecialLogListExtensionExample"
// by what ever you want
//
// For this example, we will get all edits made
// on pages that belongs to Category:ExampleCategory
{{Catégorisation JS|LiveRC}}
************************************************************************************************************************************************ */
if (typeof(LiveRC_AddHook)==="function") { // START IF, to be sure LiveRC is loaded and prevent javascript errors
LiveRC_Config["InstalledLiveRCExtensions"].push("SpecialLogListExtensionExample"); // Used to warn LiveRC that this extension is enabled
/* ************************************************************************************************************************************************ */
// == Variables ==
// === Param ===
lrcParams["SLLEE_Category"] = "ExampleCategory";
// === Texts ===
// Title of the special list
lrcTexts['liveSpecialLogListExtensionExampleTitle'] = 'SpecialLogListExtensionExample';
// Description of the show/hide option
lrcParamDesc['DescDisplayliveSpecialLogListExtensionExample'] = 'Show SpecialLogListExtensionExample list';
// Descrition of the special list title
lrcParamDesc['DescliveSpecialLogListExtensionExampleTitle'] = 'SpecialLogListExtensionExample special list title';
// Description of the category param
lrcParamDesc['DescSLLEE_Category'] = 'Category to match';
// === List set up ===
// This is optional, but you have to do it if you want the default state to be false
LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"] = {
"Values" : {}, // list of pages with rc values
"DefaultState" : true // default display state for the log list
}
// == Functions ==
// === Check the rc to see if the conditions match ===
window.SpecialLogListExtensionExample_AfterSpecialLogListUpdated = function(Args){
// get all rc params we need from Args
var rc = Args.rc;
var title = rc.title;
var timestamp = rc.timestamp;
var categories = rc.categories;
var state = rc.state;
// no need the patrol log
if(lrcHasState(state, "PATROL")) return;
// no cat means the edit don't match what we want
if(!categories || categories.length ===0) return
// set the target category
var Target = lrcGetNamespaceName(14)+":"+lrcMakeParam("SLLEE_Category");
// test each category
for(var a=0,l=categories.length;a<l;a++){
var cat = categories[a];
if(cat !== Target) continue;
// If we are here, we found an edit made on a page of the target category
// So lets update the list
// If there where no edit on that page yet, set the item
if(!LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title]){
LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title] = {};
LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title].users = [];
}
// Set the last timestamp and add the edit to the page rc list
LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title].ts = timestamp;
lrcSubFollowAddItem("liveSpecialLogListExtensionExample", title, "users", rc);
// Update the log
SpecialLogListExtensionExample_AfterAllSpecialLogListUpdated();
}
}
// === Update the log list ===
window.SpecialLogListExtensionExample_AfterAllSpecialLogListUpdated = function(){
// add an entry in the debug log
lrcDisplayDebug("Update list (liveSpecialLogListExtensionExample)");
// Set the lines Array
var tempAr = [];
// List all the pages
for(var title in LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"]){
// Make sure that the item exists. Sometimes, for ... in ... loops are shitty
if(!LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"].hasOwnProperty(title)) continue;
// Don't show list if there is no rc. For some purpose, this can be avoided
if(LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title].users.length == 0) continue;
// Get the last timestamp
var timestamp = LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title].ts;
// set the line node
var Line = document.createElement('li');
Line.id = 'specialloglistextensionexample-' + timestamp; // timestamp needed here to sort the lines later
// set the timestamp tag
var TS = document.createElement('span');
TS.innerHTML = getTimeTag(timestamp);
// set the remove link
var uremove = document.createElement('a');
uremove.className = "hidelineLink";
uremove.href = "javascript:;";
uremove.title = lrcMakeText("HIDE_THIS");
uremove.onclick = function(){ SpecialLogListExtensionExample_removeSpecialLogListExtensionExample(title); return false; }; // Here we have a special function set above
uremove.innerHTML = 'x';
// set the watch link
var watchbutton = document.createTextNode(' · ');
if(lrcGetFlowStatusForAction(title, "watch")) watchbutton = lrcCreateWatchPageLink(title, LiveRC_Config["SpecialLogListConfig"]["liveSuivi"]["Values"][title], 0);
// set the delete link (if you can delete)
var sdelete = lrcGetDeleteLink({title:title});
// set the page link
var sarti = document.createElement('a');
sarti.className = "lrc_ArticleLink";
sarti.href = lrcGetPageURL(title);
sarti.onclick = function(){ liveArticle(title); return false; };
sarti.title = title;
sarti.innerHTML = title;
// Set the log sublist for this title
var MoreLink = SpecialLogListExtensionExample_lrcGetAllSpecialLogListExtensionExample(title);
// Add all links except main link in a small tag and put it in the line, along with some separator text nodes
var Small = document.createElement('small');
Small.appendChild(uremove);
Small.appendChild(document.createTextNode(' · '));
Small.appendChild(TS);
Small.appendChild(document.createTextNode(' : '));
Small.appendChild(watchbutton);
if(sdelete){
Small.appendChild(document.createTextNode(' • '));
Small.appendChild(sdelete);
}
Small.appendChild(document.createTextNode(' • '));
Line.appendChild(Small);
// add the main link in the line
Line.appendChild(sarti);
// add the sub-list in the line
if(MoreLink) Line.appendChild(MoreLink);
// put the line in the Array
tempAr.push(Line);
}
// sort the lines (by timestamp)
tempAr = lrcSortFollow(tempAr);
// get the special list node
var liveSpecialLogListExtensionExample = document.getElementById('liveSpecialLogListExtensionExample');
if(!liveSpecialLogListExtensionExample) return;
// Reset its content and add all the lines
liveSpecialLogListExtensionExample.innerHTML = "";
var List = document.createElement('ul');
List.className = "FollowList";
var len = tempAr.length;
for(var n=(tempAr.length)-1; n>=0; n--){
if(tempAr[n]) List.appendChild(tempAr[n]);
}
liveSpecialLogListExtensionExample.appendChild(List);
}
// === Create a sublist for all edits on a given page ===
window.SpecialLogListExtensionExample_lrcGetAllSpecialLogListExtensionExample = function(title){
var GlobalVar = LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"];
// Check if we have the infos. if not, return false
if(!GlobalVar[title]) return false;
var users = GlobalVar[title].users;
if(users.length<1) return false;
// set the sublist display status
var display = ( GlobalVar[title].display ? '' : 'none');
// create the node and add the rc count
var SubListSpan = document.createElement('span');
SubListSpan.appendChild(document.createTextNode(' - '+users.length));
// set the toggle link
var ToggleLink = document.createElement('a');
ToggleLink.className = "FollowSublistToggleLink";
ToggleLink.href="javascript:;";
ToggleLink.onclick = function(){ SpecialLogListExtensionExample_lrcShowHideAllSpecialLogListExtensionExample(this,title); }; // Here we have a special function set above
ToggleLink.title = lrcMakeText("FollowSublistToggleTitle");
ToggleLink.innerHTML = '<b>±</b>';
SubListSpan.appendChild(ToggleLink);
// Set the sublist
var SubList = document.createElement('ul');
SubList.className = "FollowSublist";
SubList.style.display = display;
SubListSpan.appendChild(SubList);
var Lines = [];
// List all the edits
for(var a=0,l=users.length;a<l;a++){
var thisedit = users[a];
// set the line and add the timestamp
var Line = document.createElement('span');
Line.innerHTML = getTimeTag(thisedit.timestamp);
// add the diff link
Line.appendChild(document.createTextNode(' – '));
Line.appendChild(lrcGetDiffLink(thisedit));
// add the user link
Line.appendChild(document.createTextNode(' : '));
Line.appendChild(lrcGetUserLink(thisedit.user));
// add the line to the sublist
Lines.push(Line);
}
// add the edits to the sublist
for(var a=0,l=Lines.length;a<l;a++){
var Li = document.createElement('li');
Li.appendChild(Lines[a]);
SubList.appendChild(Li);
}
// return the sublist
return SubListSpan;
}
// === Toggle a sublist ===
window.SpecialLogListExtensionExample_lrcShowHideAllSpecialLogListExtensionExample = function(Link, title){
// get the sublist node
if(!Link) return false;
var Span = Link.nextSibling;
if(!Span) return false;
// The list is hidden
if(Span.style.display == "none"){
// unhide it
Span.style.display = "";
// set the display status, for the next updates
if(LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title])
LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title].display = true;
// The list is not hidden
}else{
// hide it
Span.style.display = "none";
// set the display status, for the next updates
if(LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title])
LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title].display = false;
}
}
// === Delete an element from the list ===
window.SpecialLogListExtensionExample_removeSpecialLogListExtensionExample = function(title){
// Delete the element
delete LiveRC_Config["SpecialLogListConfig"]["liveSpecialLogListExtensionExample"]["Values"][title];
// update the log list
SpecialLogListExtensionExample_AfterAllSpecialLogListUpdated();
}
// === Init the log list ===
window.SpecialLogListExtensionExample_AfterSpecialLogList = function(){
// Here can be tested some conditions (mediawiki extension, user right, user group, etc...)
// to prevent the log list to be set.
// As here we will use a page category, LiveRC must have loaded the page infos,
// that means lrcMakeParam("GetPageInfos") must return true;
if(!lrcMakeParam("GetPageInfos")) return;
// If OK until there, set the list
lrcAddSpecialLogList("liveSpecialLogListExtensionExample", true, false);
// Then set the other hooks
LiveRC_AddHook("AfterSpecialLogListUpdated", SpecialLogListExtensionExample_AfterSpecialLogListUpdated );
LiveRC_AddHook("AfterAllSpecialLogListUpdated", SpecialLogListExtensionExample_AfterAllSpecialLogListUpdated);
}
// == Set the main hook ==
LiveRC_AddHook("AfterSpecialLogList", SpecialLogListExtensionExample_AfterSpecialLogList);
/* ************************************************************************************************************************************************ */
} // END IF
/*
--------------------------------------------------------------------------------------
---------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 de marquer les utilisateurs ayant reçu un avertissement sur leur page de discussion.
* Licence : CC0
* Documentation :
* Auteur : [[:fr:User:Orlodrim]]
* Développement et maintenance :
** [[:fr:User:Dr Brains]]
{{Catégorisation JS|LiveRC}}
<source lang=javascript> */
if (typeof(LiveRC_AddHook)==="function") { // DÉBUT IF
LiveRC_Config["InstalledLiveRCExtensions"].push("UserWarningsExtension");
/* ************************************************************************************************************************************************ */
// Paramètres
try{
lrcParams["lrcXUWShowEditcount"] = true;
lrcParams["lrcXUWShowWarnings"] = true;
lrcParams["lrcXUWDelayIP"] = 24;
lrcParams["lrcXUWDelay"] = 24;
lrcParams["lrcXUWColorNoTalk"] = "";
lrcParams["lrcXUWColorRecentTalk"] = "";
lrcParams["lrcXUWColorRecentWarning"] = "";
}catch(e){ }
// Icônes
try{
lrcIcons["EditCount0"] = {"type":0,
"src":"thumb/1/1b/Emblem-person-red.svg/16px-Emblem-person-red.svg.png",
"width":14,
"height":14
}
lrcIcons["EditCount1"] = {"type":0,
"src":"thumb/2/23/Emblem-person-orange.svg/16px-Emblem-person-orange.svg.png",
"width":14,
"height":14
}
lrcIcons["EditCount2"] = {"type":0,
"src":"thumb/f/f4/Emblem-person-yellow.svg/16px-Emblem-person-yellow.svg.png",
"width":14,
"height":14
}
lrcIcons["EditCount3"] = {"type":0,
"src":"thumb/0/06/Emblem-person-green.svg/16px-Emblem-person-green.svg.png",
"width":14,
"height":14
}
lrcIcons["SpamIcon"] = {"type":0,
"src":"9/92/LiveRC_Spam.png",
"width":14,
"height":14
}
lrcIcons["Test0Icon"] = {"type":0,
"src":"3/3b/LiveRC_Test0.png",
"width":14,
"height":14
}
lrcIcons["Test1Icon"] = {"type":0,
"src":"5/5d/LiveRC_Test1.png",
"width":14,
"height":14
}
lrcIcons["Test2Icon"] = {"type":0,
"src":"7/78/LiveRC_Test2.png",
"width":14,
"height":14
}
lrcIcons["Test3Icon"] = {"type":0,
"src":"7/7b/LiveRC_Test3.png",
"width":14,
"height":14
}
lrcIcons["SalebotIcon"] = {"type":0,
"src":"3/31/Salebot_small_icon.png",
"width":14,
"height":14
}
}catch(e){ }
// Textes
try{
lrcTexts["EditCount0_Title"] = "Editcount : $1";
lrcTexts["EditCount1_Title"] = "Editcount : $1";
lrcTexts["EditCount2_Title"] = "Editcount : $1";
lrcTexts["EditCount3_Title"] = "Editcount : $1";
lrcTexts["SpamIcon_Title"] = "Averti : spam";
lrcTexts["Test0Icon_Title"] = "Averti : test 0";
lrcTexts["Test1Icon_Title"] = "Averti : test 1";
lrcTexts["Test2Icon_Title"] = "Averti : test 2";
lrcTexts["Test3Icon_Title"] = "Averti : test 3";
lrcTexts["SalebotIcon_Title"] = "Révoqué par Salebot";
lrcTexts['lrcXUWRAZ_Title'] = 'Remettre le compteur d’avertissements à zéro';
lrcTexts['lrcXUWRAZ_Text'] = 'raz';
}catch(e){ }
// Descriptions
try{
lrcParamDesc['DesclrcUserWarningsMessages'] = 'Paramètres de l’extension UserWarnings';
lrcParamDesc['DesclrcUserWarningsMessages_short'] = 'UserWarnings';
lrcParamDesc["DesclrcXUWShowEditcount"] = "[UserWarnings] Afficher le compteur d’éditions (couteux)";
lrcParamDesc["DesclrcXUWShowWarnings"] = "[UserWarnings] Afficher les avertissements (couteux)";
lrcParamDesc['DesclrcXUWColorNoTalk'] = '[UserWarnings] Couleur du nom des utilisateurs sans page de discussion';
lrcParamDesc['DesclrcXUWColorRecentTalk'] = '[UserWarnings] Couleur du nom des utilisateurs avec message récent mais pas d’avertissement';
lrcParamDesc['DesclrcXUWColorRecentWarning'] = '[UserWarnings] Couleur du nom des utilisateurs avertis';
lrcParamDesc['DesclrcXUWDelayIP'] = '[UserWarnings] Délai en heures avant que les avertissements ne soient caducs (IP)';
lrcParamDesc['DesclrcXUWDelay'] = '[UserWarnings] Délai en heures avant que les avertissements ne soient caducs (utilisateur enregistré)';
lrcParamDesc['DesclrcXUWRAZ_Title'] = '[UserWarnings] Infobulle du lien de mise à zéro du compteur du nombre d’avertissements';
lrcParamDesc['DesclrcXUWRAZ_Text'] = '[UserWarnings] Texte du lien de mise à zéro du compteur du nombre d’avertissements';
lrcParamDesc['DescEditCount0'] = '[UserWarnings] Compteur d’éditions, niveau 0';
lrcParamDesc['DescEditCount1'] = '[UserWarnings] Compteur d’éditions, niveau 1';
lrcParamDesc['DescEditCount2'] = '[UserWarnings] Compteur d’éditions, niveau 2';
lrcParamDesc['DescEditCount3'] = '[UserWarnings] Compteur d’éditions, niveau 3';
lrcParamDesc['DescSpamIcon'] = '[UserWarnings] Averti : spam';
lrcParamDesc['DescTest0Icon'] = '[UserWarnings] Averti : test 0';
lrcParamDesc['DescTest1Icon'] = '[UserWarnings] Averti : test 1';
lrcParamDesc['DescTest2Icon'] = '[UserWarnings] Averti : test 2';
lrcParamDesc['DescTest3Icon'] = '[UserWarnings] Averti : test 3';
lrcParamDesc['DescSalebotIcon'] = '[UserWarnings] Révoqué par Salebot';
lrcParamDesc['DescEditCount0_Title'] = '[UserWarnings] Tooltip de l’icône Compteur d’éditions, niveau 0';
lrcParamDesc['DescEditCount1_Title'] = '[UserWarnings] Tooltip de l’icône Compteur d’éditions, niveau 1';
lrcParamDesc['DescEditCount2_Title'] = '[UserWarnings] Tooltip de l’icône Compteur d’éditions, niveau 2';
lrcParamDesc['DescEditCount3_Title'] = '[UserWarnings] Tooltip de l’icône Compteur d’éditions, niveau 3';
lrcParamDesc['DescSpamIcon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : spam';
lrcParamDesc['DescTest0Icon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : test 0';
lrcParamDesc['DescTest1Icon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : test 1';
lrcParamDesc['DescTest2Icon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : test 2';
lrcParamDesc['DescTest3Icon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : test 3';
lrcParamDesc['DescSalebotIcon_Title'] = '[UserWarnings] Infobulle de l’icône d’avertissement : Salebot';
}catch(e){ }
// Tests de commentaire
window.lrcUserWarningsMessages = [
{ image: "SpamIcon" , class: "RcUWSpam" , regex: /(S|s)pammeur/ },
{ image: "Test0Icon" , class: "RcUWTest0" , regex: /(T|t)est ?0/ },
{ image: "Test1Icon" , class: "RcUWTest1" , regex: /(T|t)est ?1/ },
{ image: "Test2Icon" , class: "RcUWTest2" , regex: /(T|t)est ?2/ },
{ image: "Test3Icon" , class: "RcUWTest3" , regex: /(T|t)est ?3/ },
{ image: "SalebotIcon" , class: "RcUWSalebot" , regex: /^bot : annonce de révocation/ }
];
window.lrcUserWarningsMessages_Custom = [];
window.Custom_lrcUserWarningsMessages = [];
// ============================ FIN DE LA PARTIE PERSONNALISABLE
LiveRC_Config["UserWarnings_rvend"] = {};
window.lrcXUWTwoDigits = function(i) {
return (i < 10 ? '0' : '') + i;
}
window.lrcXUWGetWikiDate = function(localDate) {
var d = new Date(localDate.getTime() + localDate.getTimezoneOffset() * 60 * 1000);
return '' + d.getFullYear() + lrcXUWTwoDigits(d.getMonth() + 1)
+ lrcXUWTwoDigits(d.getDate()) + lrcXUWTwoDigits(d.getHours())
+ lrcXUWTwoDigits(d.getMinutes()) + lrcXUWTwoDigits(d.getSeconds());
}
window.lrcXUWGetUserLink = function(tr1) {
var links = tr1.getElementsByTagName("td")[0].getElementsByTagName("a");
for (var i = links.length - 1; i >= 0; i--) {
if(lrcHasClass(links[i], "lrc_EditorLink")) return links[i];
}
return null;
}
window.lrcXUWHook = function(Args) {
var id = Args.id;
var tr1 = document.getElementById(id);
if (!tr1) return;
var rc = Args.rc;
var user = rc.user;
// talkpage comments request
if(lrcMakeParam("lrcXUWShowWarnings")){
var talkPage = lrcGetNamespaceName(3) + ':' + user;
lrcDisplayDebug("Get user talk page infos : " + talkPage);
var Delay = (UserIsIP(user) ? lrcMakeParam("lrcXUWDelayIP") : lrcMakeParam("lrcXUWDelay") );
var rvend = (LiveRC_Config["UserWarnings_rvend"][user] ? LiveRC_Config["UserWarnings_rvend"][user] : lrcXUWGetWikiDate(new Date(new Date() - (Delay * 3600000))));
var requestTalkPage = lrcGetAPIURL({format:'xml',action:'query',prop:'revisions',rvlimit:LiveRC_Config["UserInfos"].APIlimit,rvend:rvend,rvprop:'comment|timestamp',titles:talkPage,continue:''});
wpajax.http({url: requestTalkPage,
onSuccess: lrcTalkPageCallback,
user: user,
tr1id: id
});
}
// user infos request
if(lrcMakeParam("lrcXUWShowEditcount")){
lrcDisplayDebug("Get user groups & editcount : " + user);
if(UserIsIP(user)){
var requestIPContribs = lrcGetAPIURL({format:'xml',action:'query',list:'usercontribs',ucuserprefix:user,uclimit:LiveRC_Config["UserInfos"].APIlimit,continue:''});
wpajax.http({url: requestIPContribs,
onSuccess: lrcIPContribsCallback,
user: user,
tr1id: id,
contribs: 0
});
}else{
var requestUserInfos = lrcGetAPIURL({format:'xml',action:'query',list:'allusers',auprefix:user,aulimit:'1',auprop:'editcount|registration|groups',continue:''});
wpajax.http({url: requestUserInfos,
onSuccess: lrcUserInfosCallback,
user: user,
tr1id: id
});
}
}
}
window.lrcTalkPageCallback = function(xmlreq, data) {
var tr1 = document.getElementById(data.tr1id);
if (!tr1) return;
var lastLink = lrcXUWGetUserLink(tr1);
if(!lastLink) return;
var page = xmlreq.responseXML.getElementsByTagName('page')[0];
if (!page.getAttribute('pageid')) {
if (lrcMakeParam("lrcXUWColorNoTalk")) lastLink.style.color = lrcMakeParam("lrcXUWColorNoTalk");
return;
}
var revisions = xmlreq.responseXML.getElementsByTagName('rev');
if (revisions.length == 0) return;
var firstrevtimestamp = revisions[0].getAttribute("timestamp");
var warning = [];
var classes = [];
var XUWMessages = lrcUserWarningsMessages_Custom;
if(XUWMessages.length===0) XUWMessages = Custom_lrcUserWarningsMessages;
if(XUWMessages.length===0) XUWMessages = lrcUserWarningsMessages;
for(var i = 0, l=revisions.length; i < l; i++) {
var comment = revisions[i].getAttribute('comment');
if (!comment) continue;
for (var j = 0; j < XUWMessages.length; j++) {
if((XUWMessages[j].regex).test(comment.unhtmlize())){
warning.push(lrcMakeIcon(XUWMessages[j].image, {before:' '}));
classes.push(XUWMessages[j].class);
}
}
}
if(warning.length>0) {
var iconcontainer = document.createElement('span');
iconcontainer.className = "UserWarningsIcons";
lastLink.parentNode.insertBefore(iconcontainer, lastLink.nextSibling);
for(var a=0,l=warning.length;a<l;a++){
var icon = document.createElement('span');
icon.innerHTML = warning[a];
if(classes[a]) lrcAddClass(tr1, classes[a]);
iconcontainer.appendChild(icon);
}
iconcontainer.appendChild(lrcXUWrazwarningslink(data.user, firstrevtimestamp, iconcontainer));
if(lrcMakeParam("lrcXUWColorRecentWarning")) {
lastLink.style.color = lrcMakeParam("lrcXUWColorRecentWarning");
}
} else if(revisions.length > 0 && lrcMakeParam("lrcXUWColorRecentTalk")) {
lastLink.style.color = lrcMakeParam("lrcXUWColorRecentTalk");
}
}
window.lrcXUWrazwarningslink = function(user, firstrevtimestamp, iconcontainer){
var linksup = document.createElement('sup');
var link = document.createElement('a');
link.innerHTML = lrcMakeText('lrcXUWRAZ_Text');
link.title = lrcMakeText('lrcXUWRAZ_Title').split("$1").join(firstrevtimestamp);
link.href = "javascript:;";
link.onclick = function(){ lrcXUWrazwarnings(user, firstrevtimestamp, iconcontainer); }
linksup.appendChild(document.createTextNode(" "));
linksup.appendChild(link);
return linksup;
}
window.lrcXUWrazwarnings = function(user, firstrevtimestamp, iconcontainer){
LiveRC_Config["UserWarnings_rvend"][user] = (parseInt(firstrevtimestamp.replace(/\D/g, ""))+1);
iconcontainer.parentNode.removeChild(iconcontainer);
}
window.lrcUserInfosCallback = function(xmlreq, data){
var tr1 = document.getElementById(data.tr1id);
if (!tr1) return;
var td2 = tr1.getElementsByTagName("td")[0];
if(!td2) return;
var U = xmlreq.responseXML.getElementsByTagName('u')[0];
if(!U) return;
var username = U.getAttribute("name");
if(username != data.user) return;
var usereditcount = U.getAttribute("editcount");
var userregistration = U.getAttribute("registration");
var G = U.getElementsByTagName("g");
var usergroups = [];
for(var a=0,l=G.length;a<l;a++){
usergroups.push(G[a].firstChild.nodeValue);
}
var editcounticon = lrcMakeIcon("EditCount3", {after:' – '});
var usereditcount = parseInt(usereditcount, {after:' – '});
if(usereditcount<10){
editcounticon = lrcMakeIcon("EditCount0", {after:' – '});
}else if(usereditcount<50){
editcounticon = lrcMakeIcon("EditCount1", {after:' – '});
}else if(usereditcount<500){
editcounticon = lrcMakeIcon("EditCount2", {after:' – '});
}
editcounticon = editcounticon.split("$1").join(usereditcount);
var SpanEditcount = document.createElement('span');
SpanEditcount.innerHTML = editcounticon;
td2.insertBefore(SpanEditcount, td2.firstChild);
UpdateGroups(usergroups, tr1, username);
}
window.UpdateGroups = function(usergroups, tr1, username){
for(var group in LiveRC_Config["UserGroupList"]){
if(usergroups.indexOf(group)!=-1 && typeof(LiveRC_Config["UserGroupList"][group])==="object" && typeof(LiveRC_Config["UserGroupList"][group].list)==="object" && LiveRC_Config["UserGroupList"][group].list.indexOf(username) == -1){
LiveRC_Config["UserGroupList"][group].list.push(username);
lrcAddClass(tr1, lrcGetGroupClass(tr1, lrcGetGroupState(username, [])));
}
}
}
window.lrcIPContribsCallback = function(xmlreq, data){
var tr1 = document.getElementById(data.tr1id);
if (!tr1) return;
var lastLink = lrcXUWGetUserLink(tr1);
var td2 = tr1.getElementsByTagName("td")[0];
if(!lastLink || !td2) return;
var UContribs = xmlreq.responseXML.getElementsByTagName('usercontribs')[0];
if(!UContribs) return;
var Items = UContribs.getElementsByTagName('item');
var contribs = data.contribs + Items.length;
var othercontribs = UContribs.getElementsByTagName('continue')[0];
if(othercontribs){
var continueparam = othercontribs.getAttribute('uccontinue');
var requestIPContribs = lrcGetAPIURL({format:'xml',action:'query',list:'usercontribs',ucuserprefix:data.user,uclimit:LiveRC_Config["UserInfos"].APIlimit,uccontinue:continueparam,continue:''});
wpajax.http({url: requestIPContribs,
onSuccess: lrcIPContribsCallback,
user: data.user,
tr1id: data.id,
contribs: contribs
});
}else{
var editcounticon = lrcMakeIcon("EditCount3", {after:' – '});
if(contribs<10){
editcounticon = lrcMakeIcon("EditCount0", {after:' – '});
}else if(contribs<50){
editcounticon = lrcMakeIcon("EditCount1", {after:' – '});
}else if(contribs<500){
editcounticon = lrcMakeIcon("EditCount2", {after:' – '});
}
editcounticon = editcounticon.split("$1").join(contribs);
var SpanEditcount = document.createElement('span');
SpanEditcount.innerHTML = editcounticon;
td2.insertBefore(SpanEditcount, td2.firstChild);
}
}
LiveRC_AddHook("AfterRC", lrcXUWHook);
// Personnalisation auto
window.defineCustomUserWarningsMessages = function(UserWarningsMessages){
Custom_lrcUserWarningsMessages = UserWarningsMessages;
}
LiveRC_AddHook("AfterFillParamPanel", function(){
LiveRC_ManageParams_Fill(lrcUserWarningsMessages, "lrcUserWarningsMessages", "defineCustomUserWarningsMessages", true);
});
/* ************************************************************************************************************************************************ */
} // FIN IF
//</source>