Utilisateur:Dr Brains/LiveRC/RevocationExtension.js
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./* ************************************************************************************************************************************************
// Extension de LiveRC
// Révocation dans la fenêtre de prévisualisation (pas au point !!!!!)
{{Projet:JavaScript/Script|LiveRC}}
************************************************************************************************************************************************ */
if (typeof(lrcHooks)!="undefined") { // DÉBUT IF
/* ************************************************************************************************************************************************ */
function LiveRC_RevocationExtension_ModifyLink(){
var Content = document.getElementById("livePreview");
if(!Content) return;
var rollbackLink = Content.getElementsByTagName("span");
for (var a=0,m=rollbackLink.length;a<m;a++) {
if ($(rollbackLink[a]).hasClass( "mw-rollback-link" )){
var thisLink = rollbackLink[a].getElementsByTagName("a");
for (var i=0,l=thisLink.length;i<l;i++) {
var URL = thisLink[i].getAttribute("href");
if(URL.indexOf(mw.config.get('wgServer'))==-1) URL = mw.config.get('wgServer') + URL;
thisLink[i].setAttribute("href", "javascript:LiveRC_RevocationExtension_Process('"+encodeURIComponent(URL)+"');");
}
}
}
}
function LiveRC_RevocationExtension_Process(URL){
URL = decodeURIComponent(URL);
var http = new sajax_init_object() ;
http.open('POST', URL, true);
http.onreadystatechange = function () {
if (http.readyState != 4) return;
LiveRC_RevocationExtension_Done(http.responseText);
}
http.send(null);
}
function LiveRC_RevocationExtension_Done(Text){
var Content = document.getElementById("livePreview");
if(!Content) return;
Content.innerHTML = '<div class="lrcRevocationMessage">'+Text+'</div>' + Content.innerHTML;
}
LiveRC_AddHook("AfterPreviewDiff", LiveRC_RevocationExtension_ModifyLink);
LiveRC_AddHook("AfterPreviewHistory", LiveRC_RevocationExtension_ModifyLink);
LiveRC_AddHook("AfterPreviewContribs", LiveRC_RevocationExtension_ModifyLink);
/* ************************************************************************************************************************************************ */
} // FIN IF