« Utilisateur:Phe/Entete page.js » : différence entre les versions

Contenu supprimé Contenu ajouté
Phe (discussion | contributions)
mAucun résumé des modifications
Pathoschild (discussion | contributions)
updated scripts, migrated deprecated functions
 
Ligne 46 :
var page = Number(r.exec(rh)[1]) + 2;
rh = rh.replace(/\d+/, page);
 
header.value += rh;
 
return true;
}
catch(err) {
return false;
}
},
Ligne 74 :
 
header.value += rh;
 
return true
}
catch(err) {
return false;
}
Ligne 91 :
 
success = this.increment_arabic(header, rh);
 
if (!success)
success = this.increment_roman(header, rh);
 
// if both attempt fail, reuse the previous rh
if (!success)
header.value += rh;
 
var h = document.getElementById("prp_header");
if (h.style.cssText != '') {
Ligne 141 :
if (header && !r.test(header.value)) {
var r = new RegExp("(\\d+)$");
var page = Number(r.exec(mw.config.get('wgPageName'))[1]);
running_header.pagename = 'Page:' + mw.config.get('wgTitle').replace(/\d+$/g, page - 2);
running_header.hyphenname = 'Page:' + mw.config.get('wgTitle').replace(/\d+$/g, page - 1);
 
var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath')
+ "/api.php?action=query&prop=revisions&callback=running_header.fill_rh&rvprop=content"
+ "&format=json&titles="
+ encodeURIComponent(running_header.pagename) + '|'
+ encodeURIComponent(running_header.hyphenname);
running_headermw.create_script_objloader.load(url);
}
},
 
addButton2 : function(id, alt, comment, source, onclick) {
 
var tb = document.getElementById("toolbar");
if(tb) {
var image = document.createElement("img");
Ligne 170 :
tb.appendChild(image);
}
},
 
create_script_obj : function (url) {
var scriptObj = document.createElement("script");
scriptObj.setAttribute("type", "text/javascript");
scriptObj.setAttribute("src", url);
document.body.appendChild(scriptObj);
}
};
Ligne 186 ⟶ 179 :
}
 
$(document).ready(addRhButton);
 
 
/*
 
function rmflinks() {
/**
regexTool('Running header', 'set_running_header()');
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
}
* @see https://meta.wikimedia.org/wiki/TemplateScript
*/
* @update-token [[File:pathoschild/templatescript.js]]
*/
/*$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
pathoschild.TemplateScript.add([
{ name: regexTool('Running header', 'script:set_running_header()'); }
]);
});*/