MediaWiki:Gadget-LiveRC.js/Extensions/DiffExtension.js

Une page de Wikipédia, l'encyclopédie libre.
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) ;

Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
/* 
 --------------------------------------------------------------------------------------
 ---------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