User:OldBee/ScriptManager.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*
{{Sommaire à droite}}
= Informations =
* Author : Dr Brains ( https://fr.wikipedia.org/wiki/Utilisateur:Dr_Brains )
* License : CC0
* Documentation : https://fr.wikipedia.org/wiki/Projet:JavaScript/Notices/ScriptManager
= Code source =
<source lang=javascript> */
if(typeof(ScriptManagerLoaded)==="undefined") window.ScriptManagerLoaded = (function($, mw){
"use strict";
/* </source>
== Options ==
<source lang=javascript> */
window.ScriptManagerOptions = {
HelpPage : "fr:w:Projet:JavaScript/Notices/ScriptManager",
HelpPageURL : 'https://fr.wikipedia.org/wiki/Projet:JavaScript/Notices/ScriptManager',
ScriptURL : '//meta.wikimedia.org/w/index.php?title=User:' + mw.config.get('wgUserName') + '/ScriptManager.js',
ScriptsURL : '//meta.wikimedia.org/w/index.php?title=User:' + mw.config.get('wgUserName') + '/ScriptManager-Scripts.js',
ScriptsAPIbase : '//meta.wikimedia.org/w/api.php',
OptionsURL : '//meta.wikimedia.org/w/index.php?title=User:' + mw.config.get('wgUserName') + '/ScriptManager-Options.js',
InputSize : 150,
RunningSkins : 'cologneblue,modern,monobook,vector,common,global',
LocalURL : mw.config.get('wgServer') + mw.config.get('wgArticlePath').split('$1').join(''),
LocalURLBis : mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=',
MetaGlobalURL : '//meta.wikimedia.org' + mw.config.get('wgArticlePath').split('$1').join('User:'+mw.config.get('wgUserName')+'/global.js'),
AddMainScript : false,
MouseHoverToggle : false
};
/* </source>
== Textes ==
<source lang=javascript> */
window.ScriptManager_Texts = {
ScriptOptions : "$3 Options de ScriptManager",
Desc_HelpPage : "Page d'aide",
Desc_HelpPageURL : "Adresse de la page d'aide",
Desc_InputSize : "Taille des champs de texte",
Desc_RunningSkins : "Habillages disponibles",
Desc_ScriptURL : "URL d'origine du Manager",
Desc_ScriptsURL : "URL d'origine des scripts",
Desc_ScriptsAPIbase : "URL d'origine des scripts (API)",
Desc_OptionsURL : "URL d'origine des options",
Desc_MouseHoverToggle : "Ouvrir/fermer les menus au survol de la souris",
Desc_AddMainScript : "Ajouter localement le script principal (déconseillé)",
Desc_type : "Type d’item",
Desc_installed : "Script installé",
Desc_scriptitem : "Identifiant de l’item",
Desc_text : "Texte (wikitext autorisé)",
Desc_scripturl : "URL du script",
SaveOptions : "Sauvegarder les options",
RAZOptions : "Remettre les options par défaut",
SelectScripts : "$3 Scripts à ajouter à la page $1 $2",
Help : "(Documentation)",
InputOK : "Générer le script",
InputPersonal : "Sauvegarder les gadgets",
InputRAZ : "Annuler les changements",
Hide : "[Masquer]",
Show : "[Afficher]",
type1 : "Script",
type2 : "Section de niveau 2",
type3 : "Section de niveau 3",
type4 : "Section de niveau 4",
type5 : "Section de niveau 5",
type6 : "Section de niveau 6",
IDexistError : "Cette identifiant est déjà utilisé",
OK : "OK",
cancel : "Annuler",
moveuptext : "▲",
moveuptitle : "Déplacer cet item vers le haut",
movedowntext : "▼",
movedowntitle : "Déplacer cet item vers le bas",
deletetext : "S",
deletetitle : "Supprimer cet item",
edittext : "M",
edittitle : "Modifier cet item",
newitemtext : "Ajouter",
newitemtitle : "Ajouter un item",
ScriptsSavingSummary : 'Sauvegarde de la liste des scripts',
NewScriptSavingSummary : 'Sauvegarde des gadgets installés',
OptionsSavingSummary : 'Sauvegarde des options de ScriptManager',
LoadingComment : 'Chargement de [[$1]]'
};
mw.loader.addStyleTag("" +
".cantmoveup .moveuplink, .cantmovedown .movedownlink { visibility:hidden; } " +
".ScriptManager_EditDiv { border:1px dotted silver;padding:0.5em;background-color:#EEEEEE; } " +
".noerror .error { display:none; } " +
".highlighted { background-color:#EEEEEE; } " +
".installedseparator { margin-left:1em;margin-right:0.5em; } " +
"#ScriptManager_Options { margin-bottom:0px; } " +
"#ScriptManager_Fieldset { margin-top:0px; } "
);
window.ScriptManager_UserScriptList = {};
window.ScriptManager_getDefaultScripts = function(){
window.ScriptManager_UserScriptList = {
"Liste_des_gadgets_par_défaut" : {
type : 4,
text : "Liste des gadgets par défaut"
},
"BacsASable" : {
type : 5,
text : "Bacs à Sable"
},
"BacASable1" : {
type : 1,
text : "Bac à Sable 1",
scripturl : LocalURLBis + 'User:'+ mw.config.get('wgUserName') + '/BacASable1.js'
},
"BacASable2" : {
type : 1,
text : "Bac à Sable 2",
scripturl : LocalURLBis + 'User:'+ mw.config.get('wgUserName') + '/BacASable2.js'
},
"BacASable3" : {
type : 1,
text : "Bac à Sable 3",
scripturl : LocalURLBis + 'User:'+ mw.config.get('wgUserName') + '/BacASable3.js'
}
};
};
/* </source>
== Listage des scripts ==
<source lang=javascript> */
var Onscripturl = function(){
window.LTR = $(document.body).hasClass("ltr");
window.ScriptManager_CommStart = '//DebutSectionAuto';
window.ScriptManager_CommPlus = ' : Cette section est produite par le script [['+ScriptManagerOptions.HelpPage+']]';
window.ScriptManager_CommConfig = '//ConfigSectionAuto';
window.ScriptManager_CommEnd = '//FinSectionAuto';
if( typeof(ScriptManager_getUserScripts) === "function" ){
try{
ScriptManager_getUserScripts();
}catch(e){
ScriptManager_getDefaultScripts();
}
}else{
ScriptManager_getDefaultScripts();
}
var URL = ScriptManagerOptions.LocalURLBis + mw.config.get('wgPageName') + "&action=raw";
$.ajax({url:URL, complete: PageContentLoaded});
};
window.OldPageContent = "";
var PageContentLoaded = function(Req){
var Text = Req.responseText;
if(typeof(Text)==="string"){
window.OldPageContent = Text;
var Lines = Text.split('\n');
for(var a=0,l=Lines.length;a<l;a++){
var Line = Lines[a];
if(Line.indexOf(ScriptManager_CommConfig) === -1) continue;
for(var scriptitem in ScriptManager_UserScriptList){
if(ScriptManager_UserScriptList[scriptitem].type !== 1) continue;
if(Line.indexOf(' setup-'+scriptitem+'.js ') === -1) continue;
ScriptManager_UserScriptList[scriptitem].installed = true;
}
}
}
CreateForm();
};
var ManageLTR = function(Side){
if(LTR) return Side;
else if(Side == "right") return "left";
else return "right";
};
var CreateForm = function(){
var DivRepere = document.getElementById('siteNotice');
if(!DivRepere) return;
var Form = document.createElement('div');
Form.id = "ScriptManager_MainDiv";
DivRepere.parentNode.insertBefore(Form, DivRepere);
DivRepere.style.display = 'none';
var OKInput = ''
+ '<p>'
+ '<input name="AddScript" type="button" class="ScriptManager_Input" '
+ 'onclick="ScriptManager_CreateNewScript();" '
+ 'onselect="ScriptManager_CreateNewScript();" '
+ 'value="'+ScriptManager_Texts.InputOK+'" />'
+ ' '
+ '<input name="scripturl" type="button" class="ScriptManager_Input" '
+ 'disabled="disabled" '
+ 'onclick="ScriptManager_SaveNewPersonalScripts();" '
+ 'onselect="ScriptManager_SaveNewPersonalScripts();" '
+ 'value="'+ScriptManager_Texts.InputPersonal+'" />'
+ ' '
+ '<input name="RAZ" type="button" class="ScriptManager_Input" '
+ 'disabled="disabled" '
+ 'onclick="ScriptManager_RAZFormContent();" '
+ 'onselect="ScriptManager_RAZFormContent();" '
+ 'value="'+ScriptManager_Texts.InputRAZ+'" />'
+ '</p>';
var FormContent = ''
+ '<fieldset id="ScriptManager_Options" >'
+ '<legend>'
+ '<span style="font-size:120%;">'+ScriptManager_Texts.ScriptOptions.split("$3").join('<a id="ScriptManager_ToggleOptionsLink" href="javascript:ScriptManager_ToggleOptions();">'+ScriptManager_Texts.Hide+'</a>') + '</span>'
+ '</legend>'
+ '<div id="ScriptManager_OptionList">'
+ '</div></fieldset>'
+ '<fieldset id="ScriptManager_Fieldset" >'
+ '<legend>'
+ '<span style="font-size:120%;">'+ScriptManager_Texts.SelectScripts.split("$1").join('<b>' + mw.config.get('wgPageName').replace(/_/g," ") + '</b>').split("$2").join('<sup><small><a href="' + ScriptManagerOptions.HelpPageURL + '">'+ScriptManager_Texts.Help+'</a></small></sup>').split("$3").join('<a id="ScriptManager_ToggleScriptsLink" href="javascript:ScriptManager_ToggleScripts();">'+ScriptManager_Texts.Hide+'</a>')
+ '</span>'
+ '</legend>'
+ '<div id="ScriptManager_ScriptList">'
+ '<form id="ScriptManager_Form">'
+ OKInput
+ '<div id="ScriptManager_Content"></div>'
+ '<div id="AddItemForm" class="AddItemForm"></div>'
+ OKInput
+ '</form><div id="ScriptManager_Running"></div></div></fieldset>';
Form.innerHTML = FormContent;
ScriptManager_FillOptions();
ScriptManager_ToggleOptions();
ScriptManager_RAZFormContent();
};
window.ScriptManager_ToggleScripts = function(SHOW){
var Link = document.getElementById("ScriptManager_ToggleScriptsLink");
var Liste = document.getElementById("ScriptManager_ScriptList");
if((!Link)||(!Liste)) return;
if((typeof(SHOW) === "boolean" && !SHOW) || Link.innerHTML == ScriptManager_Texts.Hide){
Liste.style.display = "none";
Link.innerHTML = ScriptManager_Texts.Show;
}else{
Liste.style.display = "block";
Link.innerHTML = ScriptManager_Texts.Hide;
}
};
window.ScriptManager_ToggleOptions = function(SHOW){
var Link = document.getElementById("ScriptManager_ToggleOptionsLink");
var Liste = document.getElementById("ScriptManager_OptionList");
if((!Link)||(!Liste)) return;
if( (typeof(SHOW) === "boolean" && !SHOW) || Link.innerHTML == ScriptManager_Texts.Hide){
Liste.style.display = "none";
Link.innerHTML = ScriptManager_Texts.Show;
}else{
Liste.style.display = "block";
Link.innerHTML = ScriptManager_Texts.Hide;
}
};
var ScriptManager_FillOptions = function(){
var optionList = document.getElementById("ScriptManager_OptionList");
if(!optionList) return;
while(optionList.firstChild){ optionList.removeChild(optionList.firstChild); }
var optionsnames = [
"HelpPage",
"HelpPageURL",
"ScriptURL",
"ScriptsURL",
"ScriptsAPIbase",
"OptionsURL",
"RunningSkins",
"InputSize",
"MouseHoverToggle",
"AddMainScript"
];
for(var a=0,l=optionsnames.length;a<l;a++){
var optionname = optionsnames[a];
var optionvalue = ScriptManagerOptions[optionname];
var optiontype = typeof(optionvalue);
if(optiontype==="boolean") optionList.appendChild(CreateInput(optionname, optionvalue, "checkbox", optionvalue));
else optionList.appendChild(CreateInput(optionname, optionvalue, "text"));
optionList.appendChild(document.createTextNode(" "));
optionList.appendChild(CreateLabel(optionname, ScriptManager_Texts["Desc_"+optionname] ));
optionList.appendChild(document.createElement("br"));
}
optionList.appendChild(CreateInput("OK", ScriptManager_Texts.SaveOptions, "button", false, false, ScriptManager_SaveOptions));
optionList.appendChild(CreateInput("RAZ", ScriptManager_Texts.RAZOptions, "button", false, false, ScriptManager_RAZOptions ));
optionList.appendChild(CreateInput("Cancel", ScriptManager_Texts.InputRAZ, "button", false, false, ScriptManager_FillOptions ));
if(ScriptManagerOptions.MouseHoverToggle){
var OptionsFieldset = document.getElementById("ScriptManager_Options");
if(OptionsFieldset){
OptionsFieldset.onmouseover = function(){ ScriptManager_ToggleOptions(true) };
OptionsFieldset.onmouseout = function(){ ScriptManager_ToggleOptions(false) };
}
var ScriptsFieldset = document.getElementById("ScriptManager_Fieldset");
if(ScriptsFieldset){
ScriptsFieldset.onmouseover = function(){ ScriptManager_ToggleScripts(true) };
ScriptsFieldset.onmouseout = function(){ ScriptManager_ToggleScripts(false) };
}
}
};
var FillFormElement = function(Script, scriptitem){
if(!Script) return;
var type = Script.type;
var text = Script.text;
var scripturl = (Script.scripturl || "");
var installed = (Script.installed || false);
if( [1,2,3,4,5,6].indexOf(type) === -1 ) return;
CreateNewElement(scriptitem, type, text, scripturl, installed);
};
var CreateNewElement = function(scriptitem, type, text, scripturl, installed){
var Form = document.getElementById("ScriptManager_Content");
if(!Form) return;
var Container = document.createElement('div');
Container.className = "ScriptManager_Container";
var VisibleDiv = document.createElement('div');
VisibleDiv.className = "ScriptManager_FormElement";
Container.appendChild(VisibleDiv);
var Buttons = document.createElement('span');
Buttons.style.float = ManageLTR('right');
CreateActionButtons(Buttons);
VisibleDiv.appendChild(Buttons);
if(type == 1) ScriptManager_CreateNewScriptElement(VisibleDiv, scriptitem, text, scripturl, installed);
else CreateNewH(VisibleDiv, text, type);
var EditDiv = document.createElement('div');
EditDiv.className = "ScriptManager_EditDiv";
EditDiv.style.display = "none";
Container.appendChild(EditDiv);
CreateEditDivContent(EditDiv, scriptitem, type, text, scripturl, installed);
var HiddenDiv = document.createElement('div');
HiddenDiv.className = "ScriptManager_Values";
HiddenDiv.style.display = "none";
HiddenDiv.appendChild(CreateInput("scriptitem", scriptitem));
HiddenDiv.appendChild(CreateInput("type", type));
HiddenDiv.appendChild(CreateInput("text", text));
HiddenDiv.appendChild(CreateInput("scripturl", scripturl));
Container.appendChild(HiddenDiv);
Form.appendChild(Container);
return Container;
};
var CreateActionButtons = function(Buttons){
var DeleteLink = document.createElement('a');
DeleteLink.innerHTML = ScriptManager_Texts.deletetext;
DeleteLink.title = ScriptManager_Texts.deletetitle;
DeleteLink.href = "javascript:;";
DeleteLink.onclick = function(){
DeleteItem(this);
};
DeleteLink.onmouseover = function(){
HighlightParentContainer(this, true);
};
DeleteLink.onmouseout = function(){
HighlightParentContainer(this, false);
};
var EditLink = document.createElement('a');
EditLink.innerHTML = ScriptManager_Texts.edittext;
EditLink.title = ScriptManager_Texts.edittitle;
EditLink.href = "javascript:;";
EditLink.onclick = function(){
EditItem(this);
};
EditLink.onmouseover = function(){
HighlightParentContainer(this, true);
};
EditLink.onmouseout = function(){
HighlightParentContainer(this, false);
};
var MoveUPLink = document.createElement('a');
MoveUPLink.innerHTML = ScriptManager_Texts.moveuptext;
MoveUPLink.title = ScriptManager_Texts.moveuptitle;
MoveUPLink.className = "moveuplink";
MoveUPLink.href = "javascript:;";
MoveUPLink.onclick = function(){
MoveItem(this, 1);
};
MoveUPLink.onmouseover = function(){
HighlightParentContainer(this, true);
}
MoveUPLink.onmouseout = function(){
HighlightParentContainer(this, false);
};
var MoveDOWNLink = document.createElement('a');
MoveDOWNLink.innerHTML = ScriptManager_Texts.movedowntext;
MoveDOWNLink.title = ScriptManager_Texts.movedowntitle;
MoveDOWNLink.className = "movedownlink";
MoveDOWNLink.href = "javascript:;";
MoveDOWNLink.onclick = function(){
MoveItem(this, 0);
};
MoveDOWNLink.onmouseover = function(){
HighlightParentContainer(this, true);
};
MoveDOWNLink.onmouseout = function(){
HighlightParentContainer(this, false);
};
if(LTR){
Buttons.appendChild(DeleteLink);
Buttons.appendChild(document.createTextNode(" — "));
Buttons.appendChild(EditLink);
Buttons.appendChild(document.createTextNode(" — "));
Buttons.appendChild(MoveUPLink);
Buttons.appendChild(document.createTextNode(" "));
Buttons.appendChild(MoveDOWNLink);
Buttons.appendChild(document.createTextNode(" "));
}else{
Buttons.appendChild(document.createTextNode(" "));
Buttons.appendChild(MoveDOWNLink);
Buttons.appendChild(document.createTextNode(" "));
Buttons.appendChild(MoveUPLink);
Buttons.appendChild(document.createTextNode(" — "));
Buttons.appendChild(EditLink);
Buttons.appendChild(document.createTextNode(" — "));
Buttons.appendChild(DeleteLink);
}
};
var HighlightParentContainer = function(link, HighLight){
var Parent = getParentElement(link, "div", "ScriptManager_Container");
if(HighLight) $(Parent).addClass("highlighted");
else $(Parent).removeClass("highlighted");
};
var DeleteItem = function(link){
var Parent = getParentElement(link, "div", "ScriptManager_Container");
if(!Parent) return;
Parent.parentNode.removeChild(Parent);
ScriptUpdated();
UpdateMoveStatus();
};
var MoveItem = function(link, where){
var Parent = getParentElement(link, "div", "ScriptManager_Container");
var Target;
if(where === 1){
Target = Parent.previousSibling;
Target.parentNode.removeChild(Target);
Parent.parentNode.insertBefore(Target, Parent.nextSibling);
}else{
Target = Parent.nextSibling;
Target.parentNode.removeChild(Target);
Parent.parentNode.insertBefore(Target, Parent);
}
ScriptUpdated();
UpdateMoveStatus();
};
var UpdateMoveStatus = function(){
var Content = document.getElementById("ScriptManager_Content");
if(!Content) return;
var Containers = $.makeArray( $(Content).find("div.ScriptManager_Container"));
var Length = Containers.length;
for(var a=0,l=Length;a<l;a++){
$(Containers[a]).removeClass("cantmoveup");
$(Containers[a]).removeClass("cantmovedown");
}
$(Containers[0]).addClass("cantmoveup");
$(Containers[(Length-1)]).addClass("cantmovedown");
};
var getParentElement = function(node, Tag, Class){
var Parent = node.parentNode;
while(Parent){
if(Parent && (Tag && Parent.tagName && Parent.tagName.toLowerCase() === Tag) && (Class && $(Parent).hasClass(Class))) break;
Parent = Parent.parentNode;
}
return Parent;
};
var CreateEditDivContent = function(EditDiv, scriptitem, type, text, scripturl, installed){
EditDiv.appendChild(CreateSelect("type", {
"1":ScriptManager_Texts.type1,
"2":ScriptManager_Texts.type2,
"3":ScriptManager_Texts.type3,
"4":ScriptManager_Texts.type4,
"5":ScriptManager_Texts.type5,
"6":ScriptManager_Texts.type6
}, type, typeSelectOnchange));
EditDiv.appendChild(document.createTextNode(" "));
EditDiv.appendChild(CreateLabel("type", ScriptManager_Texts.Desc_type ));
var Span = document.createElement('span');
$(Span).addClass("installedseparator");
Span.appendChild(document.createTextNode(" ♦ "));
EditDiv.appendChild(Span);
EditDiv.appendChild(CreateInput("installed", 1, "checkbox", installed));
EditDiv.appendChild(document.createTextNode(" "));
EditDiv.appendChild(CreateLabel("installed", ScriptManager_Texts.Desc_installed ));
EditDiv.appendChild(document.createElement("br"));
EditDiv.appendChild(CreateInput("scriptitem", scriptitem, "text", false, false, false, scriptitemInputOnkeyup));
EditDiv.appendChild(document.createTextNode(" "));
EditDiv.appendChild(CreateLabel("scriptitem", ScriptManager_Texts.Desc_scriptitem ));
EditDiv.appendChild(document.createTextNode(" "));
var ErrorSpan = document.createElement('span')
ErrorSpan.className = "error";
ErrorSpan.innerHTML = Parse(ScriptManager_Texts.IDexistError);
$(EditDiv).addClass("noerror");
EditDiv.appendChild(ErrorSpan);
EditDiv.appendChild(document.createElement("br"));
EditDiv.appendChild(CreateInput("text", text, "text"));
EditDiv.appendChild(document.createTextNode(" "));
EditDiv.appendChild(CreateLabel("text", ScriptManager_Texts.Desc_text ));
EditDiv.appendChild(document.createElement("br"));
EditDiv.appendChild(CreateInput("scripturl", scripturl, "text"));
EditDiv.appendChild(document.createTextNode(" "));
EditDiv.appendChild(CreateLabel("scripturl", ScriptManager_Texts.Desc_scripturl ));
EditDiv.appendChild(document.createElement("br"));
EditDiv.appendChild(CreateInput("cancel", ScriptManager_Texts.cancel, "button", false, false, EditItem ));
EditDiv.appendChild(CreateInput("OK", ScriptManager_Texts.OK, "button", false, false, UpdateItem ));
typeSelectOnchange(EditDiv.getElementsByTagName('select')[0]);
};
var typeSelectOnchange = function(select){
var script = (select.value == "1");
var disabled = (script ? false : "disabled");
var visibility = (script ? "visible" : "hidden");
var P = select.parentNode;
var names = ["installed", "scripturl"];
var Inputs = P.getElementsByTagName('input');
for(var a=0,l=Inputs.length;a<l;a++){
var Input = Inputs[a];
if(!Input.name || names.indexOf(Input.name) === -1) continue;
Input.disabled = disabled;
Input.style.visibility = visibility;
}
var Labels = P.getElementsByTagName('label');
for(var a=0,l=Labels.length;a<l;a++){
var Label = Labels[a];
if(!Label.getAttribute('for') || names.indexOf(Label.getAttribute('for')) === -1) continue;
Label.style.visibility = visibility;
}
var SpanInstalled = $.makeArray( $(P).find('span.installedseparator'))[0];
if(SpanInstalled) SpanInstalled.style.visibility = visibility;
};
var scriptitemInputOnkeyup = function(input){
var EditDiv = getParentElement(input, "div", "ScriptManager_EditDiv");
var value = input.value;
if(!value){
if(!$(EditDiv).hasClass("noerror")) $(EditDiv).addClass("noerror");
return;
}
var Parent = getParentElement(input, "div", "ScriptManager_Container");
$(Parent).addClass("currentparent");
var ContainerDiv = document.getElementById("ScriptManager_Content");
var ItemNames = [];
var Inputs = ContainerDiv.getElementsByTagName('input');
for(var a=0,l=Inputs.length;a<l;a++){
var Input = Inputs[a];
if(Input.type !== "hidden" || Input.name !== "scriptitem") continue;
var InputParent = getParentElement(Input, "div", "ScriptManager_Container");
if($(InputParent).hasClass("currentparent")) continue;
ItemNames.push(Input.value);
}
if(ItemNames.indexOf(value) === -1){
if(!$(EditDiv).hasClass("noerror")) $(EditDiv).addClass("noerror");
}else{
if($(EditDiv).hasClass("noerror")) $(EditDiv).removeClass("noerror");
}
$(Parent).removeClass("currentparent");
}
var EditItem = function(link){
var Parent = getParentElement(link, "div", "ScriptManager_Container");
var VisibleDiv = $.makeArray( $(Parent).find(".ScriptManager_FormElement"))[0];
var EditDiv = $.makeArray( $(Parent).find(".ScriptManager_EditDiv"))[0];
if(!VisibleDiv || !EditDiv ) return;
if(EditDiv.style.display == "none"){
EditDiv.style.display = "";
VisibleDiv.style.display = "none";
}else{
EditDiv.style.display = "none";
VisibleDiv.style.display = "";
}
};
var UpdateItem = function(link){
var Parent = getParentElement(link, "div", "ScriptManager_Container");
var EditDiv = $.makeArray( $(Parent).find(".ScriptManager_EditDiv"))[0];
if(!$(EditDiv).hasClass("noerror")) return;
var NeededParams = ["scriptitem", "text"];
var Params = { installed:false, scripturl : ""};
Params.type = EditDiv.getElementsByTagName('select')[0].value;
var Inputs = EditDiv.getElementsByTagName('input');
for(var a=0,l=Inputs.length;a<l;a++){
var Input = Inputs[a];
var Name = Input.name;
if(!Name) continue;
if(Name === "installed" && Params.type == 1) Params.installed = Input.checked;
if(Name === "scripturl" && Params.type == 1) Params.scripturl = Input.value;
if(NeededParams.indexOf(Name) === -1) continue;
Params[Name] = Input.value;
}
var NewContainer = CreateNewElement(Params.scriptitem, Params.type, Params.text, Params.scripturl, Params.installed);
Parent.parentNode.insertBefore(NewContainer, Parent);
Parent.parentNode.removeChild(Parent);
UpdateMoveStatus();
ScriptUpdated();
};
var ScriptUpdated = function(){
var Form = document.getElementById("ScriptManager_Form");
if(!Form) return;
var UpdateScriptsInputs = $.makeArray( $(Form).find("input.ScriptManager_Input"))
for(var a=0,l=UpdateScriptsInputs.length;a<l;a++){
UpdateScriptsInputs[a].disabled = false;
}
}
var CreateLabel = function(For, text){
var Label = document.createElement('label');
Label.setAttribute('for', For);
Label.innerHTML = Parse(text);
return Label;
};
var CreateInput = function(name, value, type, checked, disabled, onclick, onkeyup){
var Input = document.createElement('input');
Input.type = (type || "hidden");
Input.name = name;
Input.value = value;
if(type !== "hidden") Input.size = ScriptManagerOptions.InputSize;
if(checked) Input.checked = "checked";
if(disabled) Input.disabled = "disabled";
if(onclick){
Input.onclick = function(){ onclick(this); };
Input.onselect = function(){ onclick(this); };
}
if(onkeyup){
Input.onkeyup = function(){ onkeyup(this); };
}
return Input;
};
var CreateSelect = function(name, values, selectedvalue, onchange){
var Select = document.createElement('select');
Select.name = name;
if(typeof(values) === "object"){
for(var value in values){
var text = values[value];
var option = document.createElement('option');
option.value = value;
if(value == selectedvalue) option.selected = "selected";
option.innerHTML = text;
Select.appendChild(option);
}
}
if(typeof(onchange)==="function"){
Select.onchange = function(){
onchange(this);
}
}
return Select;
}
var Parse = function(text){
if(!text) return "";
var ThisReg = new RegExp("\\[\\[[^\\|\\]]*\\|[^\\|\\]]*\\]\\]", "g");
var Matches = text.match(ThisReg);
if(Matches !== null){
for(var a=0,l=Matches.length;a<l;a++){
var linkedpage = Matches[a].replace(/[\[\]]*/g, "").replace(/\|.*/g, "");
var linktext = Matches[a].replace(/[\[\]]*/g, "").replace(/.*\|/g, "");
text = text.replace(Matches[a], '<a href="'+ScriptManagerOptions.LocalURL+linkedpage+'" title="'+linkedpage+'">'+linktext+'</a>');
}
}
ThisReg = new RegExp("\\[\\[[^\\|\\]]*\\]\\]", "g");
Matches = text.match(ThisReg);
if(Matches !== null){
for(var a=0,l=Matches.length;a<l;a++){
var linkedpage = Matches[a].replace(/[\[\]]*/g, "");
text = text.replace(Matches[a], '<a href="'+ScriptManagerOptions.LocalURL+linkedpage+'" title="'+linkedpage+'">'+linkedpage+'</a>');
}
}
ThisReg = new RegExp("\\{\\{[^\\}]*\\}\\}", "g");
Matches = text.match(ThisReg);
if(Matches !== null){
for(var a=0,l=Matches.length;a<l;a++){
var linkedpage = "Template:"+Matches[a].replace(/[\{\}]*/g, "").replace(/\|.*/g, "");
var linktext = Matches[a].replace(/\|/g, "%7C");
text = text.replace(Matches[a], '<a href="'+ScriptManagerOptions.LocalURL+linkedpage+'" title="'+linkedpage+'">'+linktext+'</a>');
}
}
ThisReg = new RegExp("'''", "g");
Matches = text.match(ThisReg);
if(Matches !== null){
for(var a=0,l=Matches.length;a<l;a++){
var insidetext = Matches[a].replace(/'''/, ( a%2 === 0 ? "<b>" : "</b>"));
text = text.replace(Matches[a], insidetext);
}
}
ThisReg = new RegExp("''", "g");
Matches = text.match(ThisReg);
if(Matches !== null){
for(var a=0,l=Matches.length;a<l;a++){
var insidetext = Matches[a].replace(/''/, ( a%2 === 0 ? "<i>" : "</i>"));
text = text.replace(Matches[a], insidetext);
}
}
return text;
};
var CreateNewH = function(Container, text, type){
var H = document.createElement("h"+type);
H.innerHTML = Parse(text);
Container.appendChild(H);
};
var ScriptManager_CreateNewScriptElement = function(Container, scriptitem, text, scripturl, installed){
var P = document.createElement('p');
var Input = document.createElement('input');
Input.type = "checkbox";
Input.className = "installedscript";
if(installed) Input.checked = "checked";
var Link = document.createElement('a');
Link.innerHTML = scriptitem;
Link.title = scriptitem;
Link.href = scripturl;
var Desc = document.createElement('span');
Desc.innerHTML = Parse(text);
if(LTR){
P.appendChild(Input);
P.appendChild(document.createTextNode(" "));
P.appendChild(Link);
P.appendChild(document.createTextNode(" : "));
P.appendChild(Desc);
}else{
P.appendChild(Desc);
P.appendChild(document.createTextNode(" : "));
P.appendChild(Link);
P.appendChild(document.createTextNode(" "));
P.appendChild(Input);
}
Container.appendChild(P);
};
var CreateNewScriptForm = function(){
var AddItemForm = document.getElementById("AddItemForm");
if(!AddItemForm) return;
AddItemForm.className = "ScriptManager_Container";
while(AddItemForm.firstChild){ AddItemForm.removeChild(AddItemForm.firstChild); }
var VisibleDiv = document.createElement('div');
VisibleDiv.className = "ScriptManager_FormElement";
var Buttons = document.createElement('span');
Buttons.style.float = ManageLTR('right');
var NewItemLink = document.createElement('a');
NewItemLink.innerHTML = ScriptManager_Texts.newitemtext;
NewItemLink.title = ScriptManager_Texts.newitemtitle;
NewItemLink.className = "addnewlink";
NewItemLink.href = "javascript:;";
NewItemLink.onclick = function(){
EditItem(this);
};
Buttons.appendChild(NewItemLink);
VisibleDiv.appendChild(Buttons);
AddItemForm.appendChild(VisibleDiv);
var EditDiv = document.createElement('div');
EditDiv.className = "ScriptManager_EditDiv noerror";
EditDiv.style.display = "none";
CreateEditDivContent(EditDiv, "", 1, "", "", false);
AddItemForm.appendChild(EditDiv);
var Inputs = EditDiv.getElementsByTagName('input');
for(var a=0,l=Inputs.length;a<l;a++){
if(Inputs[a].name === "OK"){
Inputs[a].onclick = function(){
CreateNewItem(this);
}
}
}
}
var CreateNewItem = function(input){
var EditDiv = getParentElement(input, "div", "ScriptManager_EditDiv");
if(!$(EditDiv).hasClass("noerror")) return;
var NeededParams = ["scriptitem", "text"];
var Params = { installed:false, scripturl : ""};
Params.type = EditDiv.getElementsByTagName('select')[0].value;
var Inputs = EditDiv.getElementsByTagName('input');
for(var a=0,l=Inputs.length;a<l;a++){
var Input = Inputs[a];
var Name = Input.name;
if(!Name) continue;
if(Name === "installed" && Params.type == 1) Params.installed = Input.checked;
if(Name === "scripturl" && Params.type == 1) Params.scripturl = Input.value;
if(NeededParams.indexOf(Name) === -1) continue;
Params[Name] = Input.value;
}
var NewContainer = CreateNewElement(Params.scriptitem, Params.type, Params.text, Params.scripturl, Params.installed);
CreateNewScriptForm();
UpdateMoveStatus();
ScriptUpdated();
}
var GetNewScript = function(){
var Form = document.getElementById('ScriptManager_Form');
var Content = document.getElementById('ScriptManager_Content');
if(!Form || !Content ) return;
var NewScripts = {};
var Containers = $.makeArray( $(Content).find("div.ScriptManager_Container"));
for(var c=0,clen=Containers.length;c<clen;c++){
var ThisScript = {};
var scriptitem = false;
var Container = Containers[c];
var ContInputs = Container.getElementsByTagName('input');
for(var ci=0,cilen=ContInputs.length;ci<cilen;ci++){
var HInput = ContInputs[ci];
if(HInput.type === "checkbox" && $(HInput).hasClass("installedscript")) ThisScript["installed"] = HInput.checked;
if(HInput.type !== "hidden") continue;
var Iname = HInput.name;
var Ivalue = HInput.value;
if(Iname === "scriptitem") scriptitem = Ivalue;
else ThisScript[Iname] = Ivalue;
}
if(scriptitem){
NewScripts[scriptitem] = ThisScript;
}
}
return NewScripts;
}
var TextEscape = function(str){
return "'" + (""+str).replace(/\\/g, '\\\\').replace(/[\\]+n/g, '\\n').replace(/'/g, "\\'") + "'";
}
var EditFormGetParamValue = function(ParentNodeID, ParamName){
var ParentNode = document.getElementById(ParentNodeID);
var a,l,params = {};
var Inputs = ParentNode.getElementsByTagName('input');
for(a=0,l=Inputs.length;a<l;a++){
var Input = Inputs[a];
if(ParamName && Input.name && Input.name === ParamName){
if( ["checkbox","radio"].indexOf(Input.type) === -1 || Input.checked ) return Input.value;
}else if(!ParamName && Input.name){
if( ["checkbox","radio"].indexOf(Input.type) === -1 || Input.checked ) params[Input.name] = Input.value;
}
}
var Textareas = ParentNode.getElementsByTagName('textarea');
for(a=0,l=Textareas.length;a<l;a++){
var Textarea = Textareas[a];
if(ParamName && Textarea.name && Textarea.name === ParamName) return ParamName.value;
else if(!ParamName && Textarea.name) params[Textarea.name] = Textarea.value;
}
var Selects = ParentNode.getElementsByTagName('select');
for(a=0,l=Selects.length;a<l;a++){
var Select = Selects[a];
if(ParamName && Select.name && Select.name === ParamName) return Select.value;
else if(!ParamName && Select.name) params[Select.name] = Select.value;
}
if(!ParamName) return null;
return params;
}
window.ScriptManager_CreateNewScript = function(){
ScriptManager_DisableInputs(true);
var NewScripts = GetNewScript();
var ScriptTemplate = ""
+ ScriptManager_CommStart + ScriptManager_CommPlus+"\n"
+ "//<sour"+"ce lang=javascript>\n"
+ ScriptManager_CommConfig + " $1\n\n"
+ (ScriptManagerOptions.AddMainScript ? "mw.loader.load(" + TextEscape(ScriptManagerOptions.LocalURLBis + ScriptManagerOptions.HomePage +"&action=raw&ctype=text/javascript") +");\n\n" : "")
+ "$2\n\n"
+ "//</sour"+"ce>\n"
+ ScriptManager_CommEnd;
var ScriptList = [];
var Setup = [];
for(var scriptitem in NewScripts){
var Script = NewScripts[scriptitem];
var Type = parseInt(Script.type);
if(Type != 1) continue;
if(!Script.installed) continue;
Setup.push(" setup-"+scriptitem+".js ");
var scripturl = Script.scripturl;
var Text = "// " + ScriptManager_Texts.LoadingComment.split("$1").join(scripturl) + "\n"
+ "mw.loader.load(" + TextEscape(scripturl +"&action=raw&ctype=text/javascript") +");"
ScriptList.push(Text);
}
window.textToSave = ScriptTemplate.split("$1").join(Setup.join("")).split("$2").join(ScriptList.join("\n\n"));
var OldContent = window.OldPageContent;
if(OldContent !== "" && OldContent.indexOf(ScriptManager_CommStart) !== -1 && OldContent.indexOf(ScriptManager_CommEnd) !== -1){
var Before = OldContent.split(ScriptManager_CommStart)[0];
var After = OldContent.split(ScriptManager_CommEnd)[1];
window.textToSave = Before + window.textToSave + After;
}else{
window.textToSave = window.textToSave + (OldContent || "");
}
var URL = ScriptManagerOptions.LocalURLBis + encodeURIComponent(mw.config.get('wgPageName')) +'&action=edit';
$.ajax({url:URL, complete: SaveNewScriptLoaded});
}
var SaveNewScriptLoaded = function(Req){
var TempElement = document.createElement('div');
TempElement.style.display = "none";
document.body.insertBefore(TempElement, document.body.firstChild);
TempElement.innerHTML = Req.responseText;
var queryopt = {
action : 'edit',
title : mw.config.get('wgPageName'),
text : window.textToSave,
summary : ScriptManager_Texts.NewScriptSavingSummary,
contentformat : EditFormGetParamValue("editform",'format'),
contentmodel : EditFormGetParamValue("editform",'model'),
minor : 1,
watchlist : 'nochange',
token : EditFormGetParamValue("editform",'wpEditToken')
}
var api = new mw.Api();
api.post( queryopt, {contentType:'application/x-www-form-urlencoded'} ).then( function ( data ) {
TempElement.parentNode.removeChild(TempElement);
window.location.reload();
});
}
window.ScriptManager_SaveNewPersonalScripts = function(){
ScriptManager_DisableInputs(false);
var NewScripts = GetNewScript();
var ScriptTemplate = ""
+ "//<sour"+"ce lang=javascript>\n"
+ "window.ScriptManager_getUserScripts = function(){\n"
+ " window.ScriptManager_UserScriptList = {\n"
+ "$1\n"
+ " }\n"
+ "}\n"
+ "//</sour"+"ce>\n";
var ScriptList = [];
for(var scriptitem in NewScripts){
var Text = " "+TextEscape(scriptitem)+" : {\n";
var Script = NewScripts[scriptitem];
var items = [];
for(var item in Script){
var ScriptItem = Script[item];
if(item !== "installed") items.push(" "+TextEscape(item)+" : "+(item === 'type' ? ScriptItem : TextEscape(ScriptItem) )) ;
}
Text += items.join(",\n") + "\n"
+ " }";
ScriptList.push(Text);
}
window.textToSave = ScriptTemplate.split("$1").join(ScriptList.join(",\n"));
if(ScriptManagerOptions.ScriptsURL.indexOf(mw.config.get('wgServer')) !== -1){ // Interne
var URL = ScriptManagerOptions.LocalURLBis + 'User:'+encodeURIComponent(mw.config.get('wgUserName'))+ '/ScriptManager-Scripts.js&action=edit';
$.ajax({ url : URL, complete : SaveNewPersonalScriptsLoaded});
}else{ // Externe
GetCentralauthtoken(function(Args){
var RevURL = ScriptManagerOptions.ScriptsAPIbase
+ '?format=json'
+ '&action=query'
+ '&meta=tokens'
+ '&prop=revisions'
+ '&rvprop=timestamp'
+ '&rvlimit=1'
+ '&titles=User:' + mw.config.get('wgUserName')+ '/ScriptManager-Scripts.js'
+ '&origin='+ encodeURIComponent(window.location.protocol + mw.config.get('wgServer'))
+ '¢ralauthtoken=' + Args.centralauthtoken
+ '&curtimestamp='
+ '&continue=';
$.ajax({url:RevURL, complete:function(data){
var NewArgs = {};
NewArgs.curtimestamp = data.curtimestamp;
NewArgs.edittoken = data.query.tokens.csrftoken;
var pages = data.query.pages;
for(var id in pages){
NewArgs.timestamp = pages[id].revisions[0].timestamp;
GetCentralauthtoken(function(args){
var EditURL = ScriptManagerOptions.ScriptsAPIbase
+ '?action=edit'
+ '&title=User:' + encodeURIComponent(mw.config.get('wgUserName')+ '/ScriptManager-Scripts.js')
+ '&text=' + encodeURIComponent(window.textToSave)
+ '&summary=' + ScriptManager_Texts.ScriptsSavingSummary
+ '&basetimestamp=' + args.timestamp
+ '&starttimestamp=' + args.curtimestamp
+ '&contentformat=text/javascript'
+ '&contentmodel=javascript'
+ '&minor=1'
+ '&watchlist=nochange'
+ '&token=' + args.edittoken
+ '&origin='+ encodeURIComponent(window.location.protocol + mw.config.get('wgServer'))
+ '¢ralauthtoken=' + args.centralauthtoken;
$.ajax({url:EditURL,method:"POST",headers:{'Content-Type':'application/x-www-form-urlencoded'}, complete:function(data){
window.location.reload();
}});
}, NewArgs);
}
}});
});
}
};
var GetCentralauthtoken = function(CallBack, Args){
if(!Args) Args = {};
var api = new mw.Api();
api.get({action:'centralauthtoken'}).then(function(data) {
Args.centralauthtoken = data.centralauthtoken.centralauthtoken;
if(typeof(CallBack)==="function") CallBack(Args);
});
};
var SaveNewPersonalScriptsLoaded = function(Req){
var TempElement = document.createElement('div');
TempElement.style.display = "none";
document.body.insertBefore(TempElement, document.body.firstChild);
TempElement.innerHTML = Req.responseText;
var queryopt = {
action : 'edit',
title : 'User:' + mw.config.get('wgUserName')+ '/ScriptManager-Scripts.js',
text : window.textToSave,
summary : ScriptManager_Texts.ScriptsSavingSummary,
contentformat : EditFormGetParamValue("editform",'format'),
contentmodel : EditFormGetParamValue("editform",'model'),
minor : 1,
watchlist : 'nochange',
token : EditFormGetParamValue("editform",'wpEditToken')
}
var api = new mw.Api();
api.post( queryopt, {contentType:'application/x-www-form-urlencoded'} ).then( function ( data ) {
TempElement.parentNode.removeChild(TempElement);
window.location.reload();
});
};
window.ScriptManager_RAZFormContent = function(){
var Form = document.getElementById("ScriptManager_Content");
if(Form) while(Form.firstChild){ Form.removeChild(Form.firstChild); }
for(var scriptitem in ScriptManager_UserScriptList){
FillFormElement(ScriptManager_UserScriptList[scriptitem], scriptitem);
}
CreateNewScriptForm();
UpdateMoveStatus();
if(ScriptManagerOptions.MouseHoverToggle) ScriptManager_ToggleScripts();
};
var ScriptManager_DisableInputs = function(disablecheckboxes){
var ScriptsForm = document.getElementById("ScriptManager_Form");
if(ScriptsForm){
var AllInputs = $.makeArray( $(ScriptsForm).find("input.ScriptManager_Input"));
for(var a=0,l=AllInputs.length;a<l;a++){
AllInputs[a].disabled = "disabled";
}
if(disablecheckboxes){
var CheckBoxes = $.makeArray( $(ScriptsForm).find("input.installedscript"));
for(var a=0,l=CheckBoxes.length;a<l;a++){
CheckBoxes[a].disabled = "disabled";
}
}
}
var OptionsForm = document.getElementById("ScriptManager_OptionList");
if(OptionsForm){
var AllInputs = OptionsForm.getElementsByTagName('input');
for(var a=0,l=AllInputs.length;a<l;a++){
AllInputs[a].disabled = "disabled";
}
}
};
window.ScriptManager_RAZOptions = function(){
ScriptManager_SaveOptions(true);
}
window.ScriptManager_SaveOptions = function(RAZ){
var OptionList = document.getElementById("ScriptManager_OptionList");
if(!OptionList) return;
ScriptManager_DisableInputs(true);
var ScriptTemplate = ""
+ "//<sour"+"ce lang=javascript>\n"
+ "window.ScriptManager_getUserCustom = function(){\n"
+ "$1\n"
+ "}\n"
+ "//</sour"+"ce>\n";
var Options = [];
var Inputs = OptionList.getElementsByTagName('input');
for(var a=0,l=Inputs.length;a<l;a++){
if(Inputs[a].type == "button") continue;
var optionname = Inputs[a].name;
var optionvalue = Inputs[a].value;
if(!optionvalue) continue;
Options.push(" ScriptManagerOptions."+optionname+" = "+TextEscape(optionvalue)+";");
}
window.textToSave = ( RAZ === true ? '' : ScriptTemplate.split("$1").join(Options.join("\n")));
var URL = ScriptManagerOptions.LocalURLBis + 'User:'+ encodeURIComponent(mw.config.get('wgUserName')) +'/ScriptManager-Options.js&action=edit';
$.ajax({url:URL, complete: SaveOptionsLoaded});
}
var SaveOptionsLoaded = function(Req){
var TempElement = document.createElement('div');
TempElement.style.display = "none";
document.body.insertBefore(TempElement, document.body.firstChild);
TempElement.innerHTML = Req.responseText;
var queryopt = {
action : 'edit',
title : 'User:'+ mw.config.get('wgUserName') +'/ScriptManager-Options.js',
text : window.textToSave,
summary : ScriptManager_Texts.OptionsSavingSummary,
contentformat : EditFormGetParamValue("editform",'format'),
contentmodel : EditFormGetParamValue("editform",'model'),
minor : 1,
watchlist : 'nochange',
token : EditFormGetParamValue("editform",'wpEditToken')
}
var api = new mw.Api();
api.post( queryopt, {contentType:'application/x-www-form-urlencoded'} ).then( function ( data ) {
TempElement.parentNode.removeChild(TempElement);
window.location.reload();
});
}
/* </source>
== Ajout des liens dans les outils personnels ==
<source lang=javascript> */
var AddLinks = function(){
var Links = {
jspage : '<a href="' + ScriptManagerOptions.LocalURL + "User:"+ mw.config.get('wgUserName') + '/' + mw.config.get('skin') + '.js">' + mw.config.get('skin') + '.js</a>',
jscommon : '<a href="' + ScriptManagerOptions.LocalURL + "User:"+ mw.config.get('wgUserName') + '/common.js">common.js</a>',
jsglobal : '<a href="' + ScriptManagerOptions.MetaGlobalURL + '">global.js</a>'
};
window.LTR = $(document.body).hasClass("ltr");
var Skin = mw.config.get('skin');
var ManagerLinks = '';
if(["monobook","vector","modern"].indexOf(Skin) !== -1 ){
for(var link in Links){
ManagerLinks += '<li id="pt-'+link+'" >' + Links[link] + '</li>';
}
var conteneurDiv = document.getElementById("p-personal");
if(!conteneurDiv) return;
var conteneur = conteneurDiv.getElementsByTagName('ul')[0];
conteneur.innerHTML = conteneur.innerHTML + ManagerLinks ;
}else if( ["cologneblue"].indexOf(Skin) !== -1 ){
ManagerLinks = '<small><center>';
var count = 0;
for(var link in Links){
ManagerLinks += (count==0 ? '' : ' - ') + Links[link];
count++;
}
ManagerLinks += '</center></small>';
var ManagerlinkDiv = document.createElement("div");
ManagerlinkDiv.id = "ManagerLink";
ManagerlinkDiv.innerHTML = ManagerLinks;
var contentNode = document.getElementById("article");
if(!contentNode) return;
contentNode.insertBefore(ManagerlinkDiv, contentNode.firstChild);
}
};
/* </source>
== Lancement ==
<source lang=javascript> */
var ModulesImplemented = false;
var CustomDone = false;
var ScriptsLoaded = false;
var ScriptManager_RunningPages = [];
var ScriptManager_CurrentRunningPage = false;
var Loading = function(func, needscripts){
if(typeof(func)!=="function") return;
var Modules = ['mediawiki.api', 'mediawiki.util'];
var Lang = mw.config.get('wgUserLanguage');
if(!Lang) Lang == mw.config.get('wgContentLanguage');
if(!ModulesImplemented){
ModulesImplemented = true;
if(Lang && Lang !== "fr"){
var LangURL = '//fr.wikipedia.org/w/index.php?title=MediaWiki:Gadget-ScriptManager.js/i18n/'+Lang+'.js&action=raw&ctype=text/javascript';
mw.loader.implement( "scriptmanagerlang", [ LangURL ], {}, {}, {} );
}
var OptionURL = ScriptManagerOptions.OptionsURL +'&action=raw&ctype=text/javascript';
mw.loader.implement( "scriptmanageroptions", [ OptionURL ], {}, {}, {} );
}
if(Lang && Lang !== "fr") Modules.push("scriptmanagerlang");
Modules.push("scriptmanageroptions");
mw.loader.using( Modules, function(){
if(!CustomDone){
CustomDone = true;
if( typeof(ScriptManager_getLangCustom) === "function" ) try{ ScriptManager_getLangCustom(); }catch(e){ }
if( typeof(ScriptManager_getSiteCustom) === "function" ) try{ ScriptManager_getSiteCustom(); }catch(e){ }
if( typeof(ScriptManager_getUserCustom) === "function" ) try{ ScriptManager_getUserCustom(); }catch(e){ }
ScriptManagerOptions.RunningSkins = ScriptManagerOptions.RunningSkins.split(",");
}
var isscripturl = false;
for(var a=0,l=ScriptManagerOptions.RunningSkins.length;a<l;a++){
var Action = mw.config.get('wgAction');
if(["history","delete","edit","submit"].indexOf(Action) === -1){
var thisSkin = ScriptManagerOptions.RunningSkins[a];
var ThisSkinTitle = mw.config.get('wgUserName') + '/' + thisSkin + '.js';
ScriptManager_RunningPages.push(ThisSkinTitle);
if( mw.config.get('wgNamespaceNumber') == 2 && mw.config.get('wgTitle') == ThisSkinTitle ){
ScriptManager_CurrentRunningPage = ThisSkinTitle;
isscripturl = true;
}
}
}
if(isscripturl && needscripts){
if(!ScriptsLoaded){
ScriptsLoaded = true;
var ScriptsURL = ScriptManagerOptions.ScriptsURL + '&action=raw&ctype=text/javascript';
mw.loader.implement( "scriptmanagerscripts", [ ScriptsURL ], {}, {}, {} );
}
mw.loader.using( "scriptmanagerscripts", function(){
$(func);
});
}else if(!needscripts){
$(func);
}
});
};
Loading(Onscripturl, true);
Loading(AddLinks, false);
return true; })(jQuery, mediaWiki);
//</source>