User:OldBee/getDatas.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.
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:OldBee/getDatas.js/datas1.js&action=raw&ctype=text/javascript');
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:OldBee/getDatas.js/datas2.js&action=raw&ctype=text/javascript');
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:OldBee/getDatas.js/datas3.js&action=raw&ctype=text/javascript');
var getDatas_ajax = {
http:function(bundle){ var xmlhttp; try{ xmlhttp = new XMLHttpRequest(); }catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ xmlhttp = false; }}}; if(xmlhttp){ xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4){ getDatas_ajax.httpComplete(xmlhttp,bundle);}}; xmlhttp.open(bundle.method ? bundle.method : "GET",bundle.url,bundle.async == false ? false : true); if (bundle.headers) { for (var field in bundle.headers){ try{ xmlhttp.setRequestHeader(field,bundle.headers[field]); }catch(err){}}}; xmlhttp.send(bundle.data ? bundle.data : null); }; return xmlhttp;},
httpComplete: function(xmlhttp,bundle){ if(xmlhttp.status == 200 || xmlhttp.status == 302){ if(bundle.onSuccess) bundle.onSuccess(xmlhttp,bundle); }else if(bundle.onFailure){ bundle.onFailure(xmlhttp,bundle); }else{ }}
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
window.getDatas_Encode = function(text){
return encodeURIComponent(text).replace(/%3A/g, ":").replace(/%2F/g, "/");
};
window.getDatas_GetPageURL = function(page) {
return mw.config.get('wgServer') + mw.config.get('wgArticlePath').split('$1').join(getDatas_Encode(page));
};
window.getDatas_GetUglyPageURL = function(page, params) {
return mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + getDatas_Encode(page)+ (params ? params : "");
};
window.getDatas_EscapeStr = function(str) {
return '"' + (""+str).replace(/\\/g, '\\\\').replace(/[\\]+n/g, '\\n').replace(/"/g, '\\"') + '"';
};
window.getDatas_ObjectToString = function(obj, level){
if(!level) level = 0;
var tab = "";
for(var a=-1,l=level;a<l;a++) tab += " ";
var str = "{"+(level===0 ?"\n":"");
var items = [];
for(var itemname in obj){
var itemvalue = obj[itemname];
if(typeof(itemvalue) === "object") items.push(getDatas_EscapeStr(itemname)+":"+getDatas_ObjectToString(itemvalue, (level+1)));
else if(typeof(itemvalue) === "string") items.push(getDatas_EscapeStr(itemname)+":"+getDatas_EscapeStr(itemvalue));
else items.push(getDatas_EscapeStr(itemname)+":"+itemvalue);
}
str += items.join(", "+(level===0 ?"\n"+tab:""))+(level===0 ?"\n":"")+"}";
return str;
};
function getDatas_getElementWithId( elementId , elementTagName , elementParentNode ){
if(!elementParentNode) elementParentNode = document.body;
if (elementParentNode.getElementById) return elementParentNode.getElementById(elementId);
var TheElement = false;
var Elements = elementParentNode.getElementsByTagName(elementTagName);
var elementcount = 0;
while(elementcount<Elements.length){
var Id = Elements[elementcount].getAttribute('id');
if(Id){
if(Id==elementId){
TheElement = Elements[elementcount];
break;
}
}
elementcount++;
}
if (! TheElement) return null;
return TheElement;
};
var getDatas_PageContentIds = ['bodyContent', 'article', 'mw_contentholder'];
function getPageContentDone(Req, datas){
var OldTemp = document.getElementById("TempDiv");
if(OldTemp) OldTemp.parentNode.removeChild(OldTemp);
if(Req===false) return;
var ID = datas.ID;
var func = datas.func;
var Temp = document.createElement('div');
Temp.id = "TempDiv";
Temp.style.display = "none";
document.body.appendChild(Temp);
Temp.innerHTML = Req.responseText;
var bC = null;
if(ID){
bC = getDatas_getElementWithId(ID, '*', Temp);
}else{
for(var a=0,l=getDatas_PageContentIds.length;a<l;a++){
if(bC == null) bC = getDatas_getElementWithId(getDatas_PageContentIds[a], '*', Temp);
}
if(bC == null) bC = Temp.getElementsByTagName('body')[0];
}
func(bC, datas);
};
function getPageContent(datas){
datas.onSuccess = getPageContentDone;
getDatas_ajax.http(datas);
}
function clearNode(node){
if(!node) return;
while(node.firstChild) node.removeChild(node.firstChild);
return node;
}
// #################################################################################################################################################################
// Datas 1
function getDatas_listPages(){
//alert("listPages");
var page = "Districts du Panama";
getPageContent({url:getDatas_GetPageURL(page),
ID:"mw-content-text",
func:function(content, datas){
//alert("Request OK !");
var RequestedDatas = {};
var Elmt = content.getElementsByTagName("table")[0];
if(!Elmt) alert("pas trouvé Elmt !");
var lines = Elmt.getElementsByTagName("tr");
for(var a=0,alen=lines.length;a<alen;a++){
var thisline = lines[a];
if(!thisline) alert("pas trouvé thisline !");
var TD = thisline.getElementsByTagName("td");
if(!TD[0]) continue;
var Prov = TD[0].getElementsByTagName("a");
if(Prov.length < 1) continue;
var prov = Prov[0];
if(prov.className && prov.className == "image") prov = Prov[1];
var provName = prov.innerHTML;
var provLink = prov.title;
var district = TD[1].getElementsByTagName("a")[0];
if(!district.className || district.className !== "new") continue;
var districtName = district.innerHTML;
var districtLink = district.title.split(" (page inexistante)").join("");
var districtcap = TD[2].getElementsByTagName("a")[0];
var districtcapName = districtcap.innerHTML;
var districtcapLink = districtcap.title.split(" (page inexistante)").join("");
var pop2010 = TD[3].innerHTML.replace(/[^0-9]/g, "");
var sup2010 = TD[4].innerHTML.replace(/[^0-9]/g, "");
var locImage = TD[5].getElementsByTagName("a")[0];
if(locImage) var locImageName = districtcap.alt;
else var locImage = "";
RequestedDatas[districtLink] = {
"DistrictName" : districtName,
"DistrictLink" : districtLink,
"DistrictLink_ES" : "",
"ProvinceName" : provName,
"ProvinceLink" : provLink,
"ProvinceLink_ES" : "",
"DistrictCapName" : districtcapName,
"DistrictCapLink" : districtcapLink,
"DistrictPop" : pop2010,
"DistrictSup" : sup2010,
"DistrictLoc" : locImage
}
}
getPageContentDone(false);
// getDatas_giveWikitext("window.getDatas_PageList = "+getDatas_ObjectToString(RequestedDatas), true);
}
});
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getDatas_getInfos(){
//alert("getInfos");
var count = 0;
window.getDatas_PageListDatas = {};
for(var Page in getDatas_PageList){
count++
ControlText(count);
getPageContent({
url : getDatas_GetUglyPageURL(Page, "&action=edit§ion=0"),
ID : "wpTextbox1",
page : Page,
thiscount : count,
func : function(content, datas){
var page = datas.page;
if(!getDatas_PageListDatas[page]) getDatas_PageListDatas[page] = {};
var text = content.value;
//if(datas.thiscount<2) alert(text);
text = getDatas_getInfosSpecialTreatment(text);
var textlines = text.split("\n");
var foundstart = false;
var foundend = false;
var arg, value;
for(var a=0,alen=textlines.length;a<alen;a++){
if(foundend) continue;
var line = textlines[a];
if(((new RegExp("}}").test(line)) && !(new RegExp("{{").test(line))) || line=="}}"){ foundend = true; continue; }
var Reg = new RegExp("Ficha ", "ig");
if(!Reg.test(line) && !foundstart) continue;
else if(!foundstart){ foundstart = true; continue; }
// if(datas.thiscount<2) alert("* "+page + "\n"+line);
var newarg = line.split("=")[0];
if(newarg === line || line.indexOf("|")===-1 || line.indexOf("|")>1){
getDatas_PageListDatas[page][arg] = value+line;
continue;
}
arg = newarg;
value = line.split(arg+"=").join("");
arg = arg.split("|").join("");
arg = arg.replace(/ /g, "").replace(/^ /g, "").replace(/ $/g, "");
value = value.replace(/ /g, "").replace(/^ /g, "").replace(/ $/g, "");
getDatas_PageListDatas[page][arg] = value;
}
count--;
ControlText(count);
if(count == 0) getDatas_giveWikitext("window.getDatas_PageListDatas = "+getDatas_ObjectToString(getDatas_PageListDatas), true);
}
});
}
}
function getDatas_getInfosSpecialTreatment(text){
var Reg = new RegExp("<ref[^>]><\\/ref>", "g");
var refs = text.match(Reg);
if(refs != null){
for(var a=0,alen=refs.length;a<alen;a++){
var thisref = refs[a];
var thisrefsubstr = thisref.substring(3, thisref.length);
if(thisrefsubstr.indexOf("<ref")!==-1) continue;
var thisrefcleaned = thisref.replace(/\n/g, "");
text = text.replace(thisref, thisrefcleaned);
}
}
return text;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getDatas_getParams(){
//alert("getParams");
var AllParams = "window.FichaDeEntidadSubnacional_Params = {\n";
for(var data in getDatas_PageListDatas){
var Page = getDatas_PageListDatas[data];
for(var param in Page){
if(!Page[param]) continue;
if(AllParams.indexOf(param)!==-1) continue;
AllParams += " '"+param+"' : [],\n";
}
}
AllParams += "}";
getDatas_giveWikitext(AllParams, true);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
window.getDatas_Template = ""
+ "{{Ébauche|localité de l'Équateur}}\n"
+ "{{Infobox Canton d'Équateur\n"
+ "$INFOBOX"
+ "}}\n"
+ "\n"
+ "'''$NOMSIMPLE''' est un [[canton (Équateur)|canton]] d'[[Équateur (pays)|Équateur]] situé dans la province $DELAPROVINCE[[$LIENPROVINCE]].\n"
+ "\n"
+ "== Toponymie ==\n"
+ "\n"
+ "{{...}}\n"
+ "\n"
+ "== Histoire ==\n"
+ "\n"
+ "{{...}}\n"
+ "\n"
+ "== Géographie ==\n"
+ "\n"
+ "=== Géographie physique ===\n"
+ "\n"
+ "{{...}}\n"
+ "\n"
+ "=== Découpage administratif ===\n"
+ "\n"
+ "{{...}}\n"
+ "\n"
+ "== Climat ==\n"
+ "\n"
+ "{{...}}\n"
+ "\n"
+ "== Démographie ==\n"
+ "\n"
+ "{{...}}\n"
+ "\n"
+ "== Politique ==\n"
+ "\n"
+ "{{...}}\n"
+ "\n"
+ "== Économie ==\n"
+ "\n"
+ "{{...}}\n"
+ "\n"
+ "== Références ==\n"
+ "{{Références}}\n"
+ "\n"
+ "{{Palette|Cantons de la province $DELAPROVINCE$NOMPROVINCE}}\n"
+ "\n"
+ "{{Portail|Équateur}}\n"
+ "\n"
+ "[[Catégorie:Canton de la province $DELAPROVINCE$NOMPROVINCE|$NOMSIMPLE]]\n";
window.getDatas_InfoboxParams = [
"nom",
"image",
"légende",
"fondation",
"prov",
"drapeau",
"légende drapeau",
"capitale",
"maire",
"mandat maire",
"gentilé",
"population",
"année_pop",
"langues",
"groupes ethniques",
"superficie",
"latitude",
"longitude",
"altitude",
"altitude min",
"altitude max",
"climat",
"géolocalisation",
"imageloc",
"site"
];
window.getDatas_InfoboxParamMaxLength = 17;
window.getDatas_ProvTemplate = {
'Azuay' : 'A',
'Bolívar' : 'B',
'Cañar' : 'F',
'Carchi' : 'C',
'Cotopaxi' : 'X',
'Chimborazo' : 'H',
'El Oro' : 'O',
'Esmeraldas' : 'E',
'Galápagos' : 'W',
'Guayas' : 'G',
'Imbabura' : 'I',
'Loja' : 'EC-L',
'Los Ríos' : 'R',
'Manabí' : 'M',
'Morona-Santiago' : 'S',
'Napo' : 'N',
'Orellana' : 'D',
'Pastaza' : 'Y',
'Pichincha' : 'P',
'Santa Elena' : 'SE',
'Santo Domingo de los Tsáchilas' : 'SD',
'Sucumbíos' : 'U',
'Tungurahua' : 'T',
'Zamora-Chinchipe' : 'Z',
};
function getDatas_createPages(index){
//alert("createPages");
if(!index) index = 0;
getPageContentDone(false);
var count = -1,text = getDatas_Template;
for(var Canton in CantonsEcuadorDatas){
count++
if(count != index) continue;
var titrepage = CantonsEcuadorDatas[Canton]['CantonTitre'];
getPageContent({
datas : CantonsEcuadorDatas[Canton],
ID : "editform",
index : index,
url : getDatas_GetUglyPageURL(titrepage, '&action=edit&redlink=1'),
func : function(editform, datas){
if(!editform){ // page existante
getPageContentDone(false);
getDatas_createPages((datas.index+1));
return;
}
var Menu = document.getElementById("getDatas_Menu");
if(!Menu) return;
clearNode(Menu);
Menu.appendChild(editform);
var cantondatas = datas.datas;
var titrepage = cantondatas['CantonTitre'];
var nomcanton = cantondatas['CantonSimple'];
var titreprov = cantondatas['ProvinceTitre'];
var nomprov = cantondatas['ProvinceSimple'];
var ofProvince = (getDatas_StartWithVoyelle(nomprov) ? "d'" : "de ");
var lienProvince = titreprov + (titreprov == nomprov ? "" : "|"+nomprov);
var Titre = document.getElementById("firstHeading");
if(!Titre) Titre = document.getElementsByTagName('h1')[0];
if(Titre){
Titre.innerHTML = titrepage + " [index = "+index+"]";
}
text = text.split("$NOMSIMPLE").join(nomcanton);
text = text.split("$NOMPROVINCE").join(nomprov);
text = text.split("$DELAPROVINCE").join(ofProvince);
text = text.split("$LIENPROVINCE").join(lienProvince);
var Infobox = {};
var InfoboxText = "";
var treatedparams = [];
for(var data in cantondatas){
var thisdata = cantondatas[data];
for(var param in CantonsEcuadorAllParams){
var thisparam = CantonsEcuadorAllParams[param];
if(thisparam.length > 0 && data == param && !Infobox[thisparam]){
if(Infobox[thisparam]) Infobox[thisparam] += " " + cantondatas[data];
else Infobox[thisparam] = cantondatas[data];
treatedparams.push(thisparam);
}
}
}
Infobox["nom"] = "Canton "+(getDatas_StartWithVoyelle(nomcanton) ? "d'" : "de ") + nomcanton;
Infobox["prov"] = getDatas_ProvTemplate[nomprov];
//alert("|"+treatedparams.join("| |")+"|\n\n"+getDatas_ObjectToString(Infobox))
for(var a=0,alen=getDatas_InfoboxParams.length;a<alen;a++){
var p = getDatas_InfoboxParams[a];
var v = (Infobox[p] ? Infobox[p] : "");
InfoboxText = InfoboxText += " | "+getDatas_AddBlanks(p, getDatas_InfoboxParamMaxLength)+" = "+v+"\n";
}
text = text.split("$INFOBOX").join(InfoboxText);
text = text.split("[[Español (idioma)|Español]]").join("[[Espagnol]]");
text = text.split("[[Idioma español|Español]]").join("[[Espagnol]]");
text = getDatas_DoBiblioTemplatesTranslation(text);
var Textarea = getDatas_getElementWithId("wpTextbox1", 'textarea', Menu);
Textarea.value = text;
getDatas_ModifyEditButtons(Menu, titrepage, index);
}
});
}
}
function getDatas_ModifyEditButtons(node, titrepage, index){
var inputs = ["wpSave", "wpPreview", "wpDiff"];
for(var a=0,l=inputs.length;a<l;a++){
var Input = getDatas_getElementWithId(inputs[a], 'input', node);
if(!Input) continue;
var NewInput = document.createElement('input');
NewInput.type = "button";
NewInput.id = "Live_" + Input.id;
NewInput.value = (Input.value + " (LIVE)");
if(Input.className) NewInput.className = Input.className;
NewInput.onclick = function(){ getDatas_processEdit(this, titrepage, index)}
NewInput.onselect = function(){ getDatas_processEdit(this, titrepage, index)}
Input.parentNode.insertBefore(NewInput, Input);
Input.style.display = "none";
}
}
function getDatas_StartWithVoyelle(text){
var FistLetter = text.substr(0, 1);
return (["a","e", "i","o","u","y","A","E","I","O","U","Y"].indexOf(FistLetter)!==-1)
}
function getDatas_AddBlanks(text, totalsize){
while(text.length<totalsize){
if(text.length == totalsize) break;
text = text + " ";
if(text.length == totalsize) break;
}
return text;
}
function getDatas_processEdit(button, titrepage, index){
//alert(index);
var Form = getDatas_getFormFromThisInput(button);
var Params = getDatas_getFormParams(Form);
var ParamsInURL = [];
for(var P in Params){
if(typeof(Params[P])=="string") ParamsInURL.push(P+"="+encodeURIComponent(Params[P]));
}
var Type = button.id.replace(/.*_/g, "");
ParamsInURL = ParamsInURL.join("&")+"&"+Type+"=1";
var action = Form.action;
getPageContent({
index : index,
titrepage : titrepage,
url : action,
data : ParamsInURL,
method : "POST",
headers : {'Content-Type':'application/x-www-form-urlencoded'},
func : function(content, datas){
var titrepage = datas.titrepage;
var index = datas.index;
var Menu = document.getElementById("getDatas_Menu");
if(!Menu) return;
clearNode(Menu);
Menu.appendChild(content);
getPageContentDone(false);
getDatas_ModifyEditButtons(Menu, titrepage, index);
var Titre = document.getElementById("firstHeading");
if(!Titre) Titre = document.getElementsByTagName('h1')[0];
if(Titre){
Titre.innerHTML = titrepage + " [index = "+index+"]";
var Textarea = getDatas_getElementWithId("wpTextbox1", 'textarea', Menu);
if(Textarea) return;
var NewInput = document.createElement('input');
NewInput.type = "button";
NewInput.value = "Page suivante";
NewInput.onclick = function(){ getDatas_createPages((index+1)); }
NewInput.onselect = function(){ getDatas_createPages((index+1)); }
Titre.appendChild(document.createTextNode(" "));
Titre.appendChild(NewInput);
}
}
});
}
window.getDatas_getFormFromThisInput = function(Input){
//if(!Input) return null;
var Element = Input.parentNode;
while(Element){
if(Element.tagName && Element.tagName.toLowerCase() == 'form') return Element;
Element = Element.parentNode;
}
return null
};
window.getDatas_getFormParams = function(Form, searchedname){
var Params = {};
var Tags = ["textarea", "select", "input"];
for(var a=0,l=Tags.length;a<l;a++){
var tag = Tags[a].toLowerCase();
var Elements = Form.getElementsByTagName(Tags[a]);
for(var b=0,m=Elements.length;b<m;b++){
var Element = Elements[b];
var ElName = Element.name;
if(!ElName) continue;
if(searchedname && ElName == searchedname) return Element;
var ElValue = Element.value;
var ElType = Element.type;
if(tag=='input' && (ElType == "checkbox" || ElType == "radio") && Element.checked){
Params[ElName] = ElValue;
}else if(tag=='input' && (ElType == "text" || ElType == "hidden") ){
Params[ElName] = ElValue;
}else if(tag!='input'){
Params[ElName] = ElValue;
}
}
}
if(searchedname) return null;
return Params;
};
window.getDatas_BiblioTemplatesNames = {
"Ouvrage" : ["Cita libro", "Ref-libro", "Citalibro", "Cite book", "Ref libro"],
"Article" : ["Cita publicación", "Cite paper", "Cita revista", "Cite document", "Cite journal", "Citar jornal", "Cite magazine"],
"Lien web" : ["Cita web", "CW", "CB"]
};
window.getDatas_BiblioTemplates = {};
getDatas_BiblioTemplates["Ouvrage"] = {
"langue" : ["idioma"],
"prénom1" : ["nombre"],
"nom1" : ["apellidos", "apellido"],
"lien auteur1" : ["enlaceautor"],
"titre" : ["título"],
"numéro d'édition" : ["edición"],
"éditeur" : ["editorial"],
"lieu" : ["ubicación"],
"année" : ["año"],
"volume" : ["volumen"],
"pages totales" : ["páginas"],
"passage" : ["capítulo"],
"consulté le" : ["fechaacceso"]
};
getDatas_BiblioTemplates["Article"] = {
"langue" : ["idioma"],
"prénom1" : ["nombre"],
"nom1" : ["apellidos", "apellido"],
"lien auteur1" : ["enlaceautor"],
"titre" : ["título"],
"périodique" : ["revista","publicación"],
"éditeur" : ["editor"],
"volume" : ["volumen"],
"numéro" : ["número"],
"année" : ["año"],
"date" : ["fecha"],
"pages" : ["páginas"],
"consulté le" : ["fechaacceso"]
};
getDatas_BiblioTemplates["Lien web"] = {
"url" : ["url"],
"titre" : ["título"],
"auteur" : ["autor"],
"lien auteur" : ["enlaceautor"],
"date" : ["fecha"],
"année" : ["año"],
"mois" : ["mes"],
"éditeur" : ["editor"],
"page" : ["página"],
"citation" : ["cita"],
"consulté le" : ["fechaacceso"]
};
window.getDatas_DoBiblioTemplatesNamesTranslation = function(PageToTranslateContent){
for(var templatename in getDatas_BiblioTemplatesNames){
if(!getDatas_BiblioTemplatesNames.hasOwnProperty(templatename)) continue;
var thistemplatename = "("+getDatas_BiblioTemplatesNames[templatename].join("|")+")";
var TemplateRegExp = new RegExp("\\{\\{[ ]*"+thistemplatename+"[ ]*\\|", "ig");
var Matches = PageToTranslateContent.match(TemplateRegExp);
if(Matches==null) continue;
for(var a=0,l=Matches.length;a<l;a++){
var ThisTemplate = Matches[a];
PageToTranslateContent = PageToTranslateContent.replace(Matches[a],"{{" + templatename + "|");
}
}
return PageToTranslateContent;
}
window.getDatas_DoBiblioTemplatesTranslation = function(PageToTranslateContent){
PageToTranslateContent = getDatas_DoBiblioTemplatesNamesTranslation(PageToTranslateContent);
for(var Template in getDatas_BiblioTemplates){
if(!getDatas_BiblioTemplates.hasOwnProperty(Template)) continue;
var TemplateRegExp = new RegExp("\\{\\{[ ]*"+Template+"[ ]*\\|[^\\}]*\\}\\}", "ig");
var Matches = PageToTranslateContent.match(TemplateRegExp);
if(Matches==null) continue;
for(var a=0,l=Matches.length;a<l;a++){
var ThisTemplate = Matches[a];
//alert(ThisTemplate);
for(var Param in getDatas_BiblioTemplates[Template]){
if(getDatas_BiblioTemplates[Template].hasOwnProperty(Param)){
var ThisParam = getDatas_BiblioTemplates[Template][Param];
if(ThisParam){
if(typeof(ThisParam)==="object") ThisParam = "("+ThisParam.join("|")+")";
var ParamRegExp = new RegExp("\\|[ ]*"+ThisParam+"[ ]*=", "g");
var ParamMatches = ThisTemplate.match(ParamRegExp);
if(ParamMatches!=null){
ThisTemplate = ThisTemplate.replace(ParamRegExp, "|"+Param+"=");
}
}
}
}
PageToTranslateContent = PageToTranslateContent.replace(Matches[a], ThisTemplate);
}
}
return PageToTranslateContent;
}
// #################################################################################################################################################################
function getDatas_giveWikitext(text, addlinks){
var Menu = document.getElementById("getDatas_Menu");
if(!Menu) return;
var Textarea = document.getElementById("getDatas_Textarea");
if(!Textarea){
Textarea = document.createElement("textarea");
Textarea.id = "getDatas_Textarea";
Textarea.setAttribute("rows",25);
Textarea.setAttribute("cols",80);
}
Textarea.value = text;
Menu.appendChild(Textarea);
if(addlinks){
for(var a=0,alen=3;a<alen;a++){
var A = document.createElement("a");
A.id = "MenuButton_Save";
A.title = "Sauvegarder";
A.innerHTML = "Sauvegarder ("+(a+1)+")";
A.href="//meta.wikimedia.org/w/index.php?title=User:OldBee/getDatas.js/datas"+(a+1)+".js&action=edit";
Menu.appendChild(document.createTextNode(" "));
Menu.appendChild(A);
}
}
return Menu;
}
function getDatas_AddLink(){
var Titre = document.getElementById("firstHeading");
if(!Titre) Titre = document.getElementsByTagName('h1')[0];
if(!Titre) return;
var Small = document.createElement("small");
Small.setAttribute("style", "text-size:40% !important");
var Link = document.createElement("a");
Link.title="Afficher le menu";
Link.href="javascript:getDatas_MakeMenu();";
Link.innerHTML = "[getDatas]";
Small.setAttribute("style", "text-size:40% !important");
Small.appendChild(Link);
var Sup = document.createElement("sup");
Sup.setAttribute("style", "font-size:10px !important");
Sup.title="Voir ou modifier l'outil";
var SupLink = document.createElement("a");
SupLink.href="//meta.wikimedia.org/wiki/User:OldBee/getDatas.js";
SupLink.innerHTML = "outil";
var SupLink1 = document.createElement("a");
SupLink1.href="//meta.wikimedia.org/wiki/User:OldBee/getDatas.js/datas1.js";
SupLink1.innerHTML = "1";
var SupLink2 = document.createElement("a");
SupLink2.href="//meta.wikimedia.org/wiki/User:OldBee/getDatas.js/datas2.js";
SupLink2.innerHTML = "2";
var SupLink3 = document.createElement("a");
SupLink3.href="//meta.wikimedia.org/wiki/User:OldBee/getDatas.js/datas3.js";
SupLink3.innerHTML = "3";
Sup.appendChild(document.createTextNode("("));
Sup.appendChild(SupLink);
Sup.appendChild(document.createTextNode("-"));
Sup.appendChild(SupLink1);
Sup.appendChild(document.createTextNode("-"));
Sup.appendChild(SupLink2);
Sup.appendChild(document.createTextNode("-"));
Sup.appendChild(SupLink3);
Sup.appendChild(document.createTextNode(")"));
Small.appendChild(Link);
Small.appendChild(document.createTextNode(" "));
Small.appendChild(Sup);
Titre.appendChild(document.createTextNode(" - "));
Titre.appendChild(Small);
}
function getDatas_HideMenu(){
var MenuPages = document.getElementById("getDatas_Menu");
if(MenuPages) MenuPages.parentNode.removeChild(MenuPages);
}
window.getDatas_Inputs = [
{value:"Annuler",func:getDatas_HideMenu},
{value:"Lister pages",func:getDatas_listPages},
{value:"Récupérer infos",func:getDatas_getInfos},
{value:"Récupérer paramètres",func:getDatas_getParams},
{value:"Créer pages",func:getDatas_createPages}
];
function getDatas_MakeMenu(){
if(document.getElementById("getDatas_Menu")) return;
var Titre = document.getElementById("firstHeading");
if(!Titre) Titre = document.getElementsByTagName('h1')[0];
if(!Titre) return;
var MenuPages = document.createElement('div');
MenuPages.id = "getDatas_Menu";
for(var a=0;a<getDatas_Inputs.length;a++){
var thisInput = getDatas_Inputs[a];
var Input = document.createElement("input");
Input.id = "MenuButton_"+a;
Input.type = "button";
Input.value = thisInput.value;
Input.onclick = function(){ getDatas_Inputs[getDatas_getIndex(this)].func(); };
Input.onselect = function(){ getDatas_Inputs[getDatas_getIndex(this)].func(); };
MenuPages.appendChild(Input);
}
var ControlSpan = document.createElement("span");
ControlSpan.id = "ControlSpan";
MenuPages.appendChild(ControlSpan);
Titre.parentNode.insertBefore(MenuPages, Titre.nextSibling);
while(MenuPages.nextSibling){ MenuPages.parentNode.removeChild(MenuPages.nextSibling); }
}
function ControlText(text){
var ControlSpan = document.getElementById("ControlSpan");
if(!ControlSpan) return;
if(!text) ControlSpan.innerHTML = "";
else ControlSpan.innerHTML = text;
}
function getDatas_getIndex(Element){
return parseInt(Element.id.replace(/[^0-9]/g, ""));
}
if((mw.config.get('wgNamespaceNumber')>-1)&&( ["view","purge"].indexOf(mw.config.get('wgAction'))!= -1)){
$(getDatas_AddLink);
}