User:Dr Brains/GlobalManager.js

//  /*************************************************************************************************************** *  GLOBAL-MANAGER                                                                                             * * Pour installer et configurer ce gestionnaire : Voir Discussion utilisateur:Dr Brains/GlobalManager.js  * ***************************************************************************************************************/

////////////////////////////// PARTIE PERSONNALISABLE (1/8) : DÉFINITION DU SKIN ACTIF ET DES SKINS SUPPORTÉS //////////////////////////////////////////////////////////////////////

if( skin == "monobook" ){ var cspSkin = "monobook"; var cspSkinalt1 = "modern"; var cspSkinalt2 = "vector"; var cspSkinalt3 = "cologneblue"; var cspSkinalt4 = "chick"; var cspSkinalt5 = "simple"; var cspSkinalt6 = "nostalgia"; var cspSkinalt7 = "standard"; var cspSkinalt8 = "myskin"; } if( skin == "modern" ){ var cspSkin = "modern"; var cspSkinalt1 = "monobook"; var cspSkinalt2 = "vector"; var cspSkinalt3 = "cologneblue"; var cspSkinalt4 = "chick"; var cspSkinalt5 = "simple"; var cspSkinalt6 = "nostalgia"; var cspSkinalt7 = "standard"; var cspSkinalt8 = "myskin"; } if( skin == "vector" ){ var cspSkin = "vector"; var cspSkinalt1 = "monobook"; var cspSkinalt2 = "modern"; var cspSkinalt3 = "cologneblue"; var cspSkinalt4 = "chick"; var cspSkinalt5 = "simple"; var cspSkinalt6 = "nostalgia"; var cspSkinalt7 = "standard"; var cspSkinalt8 = "myskin"; } if( skin == "cologneblue" ){ var cspSkin = "cologneblue"; var cspSkinalt1 = "monobook"; var cspSkinalt2 = "modern"; var cspSkinalt3 = "vector"; var cspSkinalt4 = "chick"; var cspSkinalt5 = "simple"; var cspSkinalt6 = "nostalgia"; var cspSkinalt7 = "standard"; var cspSkinalt8 = "myskin"; } if( skin == "chick" ){ var cspSkin = "chick"; var cspSkinalt1 = "monobook"; var cspSkinalt2 = "modern"; var cspSkinalt3 = "vector"; var cspSkinalt4 = "cologneblue"; var cspSkinalt5 = "simple"; var cspSkinalt6 = "nostalgia"; var cspSkinalt7 = "standard"; var cspSkinalt8 = "myskin"; } if( skin == "nostalgia" ){ var cspSkin = "nostalgia"; var cspSkinalt1 = "monobook"; var cspSkinalt2 = "modern"; var cspSkinalt3 = "vector"; var cspSkinalt4 = "cologneblue"; var cspSkinalt5 = "chick"; var cspSkinalt6 = "simple"; var cspSkinalt7 = "standard"; var cspSkinalt8 = "myskin"; } if( skin == "standard" ){ var cspSkin = "standard"; var cspSkinalt1 = "monobook"; var cspSkinalt2 = "modern"; var cspSkinalt3 = "vector"; var cspSkinalt4 = "cologneblue"; var cspSkinalt5 = "chick"; var cspSkinalt6 = "simple"; var cspSkinalt7 = "nostalgia"; var cspSkinalt8 = "myskin"; } if( skin == "myskin" ){ var cspSkin = "myskin"; var cspSkinalt1 = "monobook"; var cspSkinalt2 = "modern"; var cspSkinalt3 = "vector"; var cspSkinalt4 = "cologneblue"; var cspSkinalt5 = "chick"; var cspSkinalt6 = "simple"; var cspSkinalt7 = "nostalgia"; var cspSkinalt8 = "standard"; } if( skin == "simple" ){ var cspSkin = "simple"; var cspSkinalt1 = "monobook"; var cspSkinalt2 = "modern"; var cspSkinalt3 = "vector"; var cspSkinalt4 = "cologneblue"; var cspSkinalt5 = "chick"; var cspSkinalt6 = "myskin"; var cspSkinalt7 = "nostalgia"; var cspSkinalt8 = "standard"; } var cspEntryPage = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkin + '.js';                            //Pages JS où le script s'active var cspEntryPagealt1 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt1 + '.js'; var cspEntryPagealt2 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt2 + '.js'; var cspEntryPagealt3 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt3 + '.js'; var cspEntryPagealt4 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt4 + '.js'; var cspEntryPagealt5 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt5 + '.js'; var cspEntryPagealt6 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt6 + '.js'; var cspEntryPagealt7 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt7 + '.js'; var cspEntryPagealt8 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt8 + '.js';

var cspCssPage = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkin + '.css';                             //Pages CSS où le script s'active var cspCssPagealt1 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt1 + '.css'; var cspCssPagealt2 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt2 + '.css'; var cspCssPagealt3 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt3 + '.css'; var cspCssPagealt4 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt4 + '.css'; var cspCssPagealt5 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt5 + '.css'; var cspCssPagealt6 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt6 + '.css'; var cspCssPagealt7 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt7 + '.css'; var cspCssPagealt8 = 'User:' + wgUserName.replace(/ /g,"_") + '/' + cspSkinalt8 + '.css';

////////////////////////////// PARTIE PERSONNALISABLE (2/8) : PARAMÈTRES ///////////////////////////////////////////////////////////////////////////////////////////////////////////

//Adresses du site : var SiteURL = 'http://www.mediawiki.org/wiki/'                                                                      //* Adresse normale var SiteURLbis = 'http://www.mediawiki.org/w/index.php?title='                                                      //* Adresse en cours d'action

var cspCssRepos = 'User:' + wgUserName.replace(/ /g,"_") + '/';                                                    //Répertoire par défaut des pages personnelles css var cspCssLinks = SiteURL + cspCssRepos ;                                                                          //Url du répertoire par défaut des pages personnelles css var cspScriptRepos = 'User:' + wgUserName.replace(/ /g,"_") + '/';                                                 //Répertoire par défaut des scripts personnels var cspScriptLinks = SiteURL + cspScriptRepos ;                                                                    //Url du répertoire par défaut var cspGadgetsRepos = 'MediaWiki:Gadget-';                                                                         //Répertoire des gadgets var cspGadgetsLinks = SiteURL + cspGadgetsRepos ;                                                                  //Url du répertoire des gadgets

var cspMainScript = 'User:' + wgUserName.replace(/ /g,"_") + '/GlobalManager.js';                             //Page où est copié le code du manager

var cspSummary = 'Mise &agrave; jour avec ' + cspMainScript + ;                                                      //Résumé de modification JS var cspCssSummary = 'Mise &agrave; jour avec ' + cspMainScript + ;                                                    //Résumé de modification CSS

var cspCssStartComment = '/\* jncsp-start';                                                                         //Commentaire inséré au début du .css var cspCssStartComment2 = ' La section ci-dessous est produite par le script : ' + cspMainScript + ' \*/';      //Commentaire supplémentaire inséré au début du .css var cspCssConfigComment = '/\* jncsp-config';                                                                       //Commentaire de configuration du .css var cspCssEndComment = '/\* jncsp-end \*/';                                                                         //Commentaire inséré à la fin du .css

var cspStartComment = '// jncsp-start';                                                                             //Commentaire inséré au début du .js var cspStartComment2 = ' La section ci-dessous est produite par le script : ' + cspMainScript + '';              //Commentaire supplémentaire inséré au début du .js var cspConfigComment = '// jncsp-config';                                                                            //Commentaire de configuration du .js var cspEndComment = '// jncsp-end';                                                                                  //Commentaire inséré à la fin du .js

var ID_Div = "siteNotice";                                                                                          // id du div remplacé par le script ////////////////////////////// PARTIE PERSONNALISABLE (3/8) : DÉFINITION CSS ///////////////////////////////////////////////////////////////////////////////////////////////////////////// var cspCssFragments = [

/********************************************************************************************************************************************** *  id   = un identifiant unique, généralement le nom de la fonction principale                                                              * *  type = 0 (défaut) : inclusion d'une page .css                                                                                            * *         1 : le contenu de la variable page est recopié dans la page css                                                                   * *         2 : Titre de chapitre niveau 2                                                                                                    * *         3 : Titre de chapitre niveau 3                                                                                                    * *         4 : Titre de chapitre niveau 4                                                                                                    * *         5 : Titre de chapitre niveau 5                                                                                                    * *         6 : Titre de chapitre niveau 6                                                                                                    * *         8 : Texte normal (HTML)                                                                                                           * *  page = nom de la page où le css à inclure est stocké                                                                                     * *  rev  = numéro de révision de la page (si inclusion d'une page archivée)                                                                  * *  desc = description du css                                                                                                                * **********************************************************************************************************************************************/

{ desc: 'Comment ça marche ?', type: 2 },

{ desc: 'Insertion d\'une page personnelle', type: 3 },

{ id: 'setup-BacASable', page: cspCssRepos + 'BacASable.css', type: 0, desc: 'BacASable' },

{ id: 'setup-MagicSidebox', page: 'Utilisateur:Dr_Brains/MagicSidebox.css', type: 0, desc: 'MagicSidebox' },

{ id: 'setup-MenuActions', page: 'Utilisateur:Dr_Brains/MenuActions.css', type: 0, desc: 'MenuActions' },

{ id: 'setup-FixSidebar', page: 'Utilisateur:Dr_Brains/FixSidebar.css', type: 0, desc: 'FixSidebar' },

{ desc: 'Composition', type: 3 }, { desc: 'Liens', type: 4 },

{ id: 'setup-Liens-Roses', page: 'a {text-decoration: none;color:#ff00ff;background: none;}', type: 1, desc: 'Rose ' }, { id: 'setup-Liens-Rouges', page: 'a {text-decoration: none;color:#ff0000;background: none;}', type: 1, desc: 'Rouge ' }, { id: 'setup-Liens-Bleus', page: 'a {text-decoration: none;color:#0000ff;background: none;}', type: 1, desc: 'Bleu ' }, { id: 'setup-Liens-Verts', page: 'a {text-decoration: none;color:#00ff00;background: none;}', type: 1, desc: 'Vert ' }, { id: 'setup-Liens-Noirs', page: 'a {text-decoration: none;color:#000000;background: none;}', type: 1, desc: 'Noir ' },

{ desc: 'Liens visités', type: 4 },

{ id: 'setup-Liens-Visités-Roses', page: 'a:visited {color: #ff00ff;}', type: 1, desc: 'Rose ' }, { id: 'setup-Liens-Visités-Rouges', page: 'a:visited {color: #ff0000;}', type: 1, desc: 'Rouge ' }, { id: 'setup-Liens-Visités-Bleus', page: 'a:visited {color: #0000ff;}', type: 1, desc: 'Bleu ' }, { id: 'setup-Liens-Visités-Verts', page: 'a:visited {color: #00ff00;}', type: 1, desc: 'Vert ' }, { id: 'setup-Liens-Visités-Noirs', page: 'a:visited {color: #ffffff;}', type: 1, desc: 'Noir ' },

{ desc: 'Liens actif', type: 4 },

{ id: 'setup-Liens-Actifs-Roses', page: 'a:active {color: #ff00ff;}', type: 1, desc: 'Rose ' }, { id: 'setup-LiensActifs-Rouges', page: 'a:active {color: #ff0000;}', type: 1, desc: 'Rouge ' }, { id: 'setup-Liens-Actifs-Bleus', page: 'a:active {color: #0000ff;}', type: 1, desc: 'Bleu ' }, { id: 'setup-Liens-Actifs-Verts', page: 'a:active {color: #00ff00;}', type: 1, desc: 'Vert ' }, { id: 'setup-Liens-Actifs-Noirs', page: 'a:active {color: #ffffff;}', type: 1, desc: 'Noir ' },

]; ////////////////////////////// PARTIE PERSONNALISABLE (4/8) : DÉFINITION JS ///////////////////////////////////////////////////////////////////////////////////////////////////////////// var cspFragments = [

/********************************************************************************************************************************************** *  id   = un identifiant unique, généralement le nom de la fonction principale                                                              * *  type = 0 (défaut) : Le script sera entièrement recopié dans la page. (Peut se révéler problématique avec certains caractères spéciaux.) * *         1 : Le script sera inclus par un élément (solution préférable)                                                           * *         2 : Titre de chapitre niveau 2                                                                                                    * *         3 : Titre de chapitre niveau 3                                                                                                    * *         4 : Titre de chapitre niveau 4                                                                                                    * *         5 : Titre de chapitre niveau 5                                                                                                    * *         6 : Titre de chapitre niveau 6                                                                                                    * *         8 : Texte normal (HTML)                                                                                                           * *  page = nom de la page où le script à inclure est stocké                                                                                  * *  rev  = numéro de révision de la page (si inclusion d'une page archivée)                                                                  * *  deps = liste des dépendances, à ignorer si il n'y en a pas                                                                               * *  desc = description du script                                                                                                             * **********************************************************************************************************************************************/

{ desc: 'Scripts obsolètes ou archivés', type: 2 },

{ id: 'setup-FullScreen', page: 'Utilisateur:Dr_Brains/FullScreen.js', type: 1, desc: 'Fullscreen' },

{ id: 'setup-favoris', page: 'Utilisateur:Dr_Brains/favoris.js', type: 1, desc: 'favoris' },

{ id: 'setup-myName', page: 'Utilisateur:Dr_Brains/myName.js', type: 1, desc: 'myName' },

{ id: 'setup-CacheLiens', page: 'Utilisateur:Dr_Brains/CacheLiens.js', type: 1, desc: 'CacheLiens' },

{ id: 'setup-CollapseSidebox', page: 'Utilisateur:Dr_Brains/CollapseSidebox.js', type: 1, desc: 'CollapseSidebox</a>' },

{ id: 'setup-TailleEdit', page: 'Utilisateur:Dr_Brains/TailleEdit.js', type: 1, desc: 'TailleEdit</a>' },

{ id: 'setup-Balise', page: 'Utilisateur:Dr_Brains/Balise.js', type: 1, desc: 'Balise</a>' },

{ desc: 'Tests', type: 2 },

{ id: 'setup-BacASable', page: 'Utilisateur:Dr_Brains/BacASable.js', type: 1, desc: 'BacASable</a>' },

{ id: 'setup-VectorMagicSidebox', page: 'Utilisateur:Dr_Brains/VectorMagicSidebox.js', type: 1, desc: 'VectorMagicSidebox</a>' },

{ id: 'setup-QuickEdit', page: 'Utilisateur:Dr_Brains/QuickEdit.js', type: 1, desc: 'QuickEdit</a>' },

{ desc: 'Scripts fonctionnels', type: 2 },

{ id: 'setup-MenuClicDroit', page: 'Utilisateur:Dr_Brains/MenuClicDroit.js', type: 1, desc: 'MenuClicDroit</a>' },

{ id: 'setup-Remplace', page: 'Utilisateur:Dr_Brains/Remplace.js', type: 1, desc: 'Remplace</a>' },

{ id: 'setup-DoubleActions', page: 'Utilisateur:Dr_Brains/DoubleActions.js', type: 1, desc: 'DoubleActions</a>' },

{ id: 'setup-Google', page: 'Utilisateur:Dr_Brains/Google.js', type: 1, desc: 'Google</a>' },

{ id: 'setup-FixSidebar', page: 'Utilisateur:Dr_Brains/FixSidebar.js', type: 1, desc: 'FixSidebar</a>' },

{ id: 'setup-Consult', page: 'Utilisateur:Dr_Brains/Consult.js', type: 1, desc: 'Consult</a>' },

{ id: 'setup-MagicSidebox', page: 'Utilisateur:Dr_Brains/MagicSidebox.js', type: 1, desc: 'MagicSidebox</a>' },

{ id: 'setup-SkinManager', page: 'Utilisateur:Dr_Brains/SkinManager.js', type: 1, desc: 'SkinManager</a>' },

{ desc: 'Gadgets modifiés', type: 2 },

{ id: 'setup-TestExist', page: 'Utilisateur:Dr_Brains/TestExist.js', type: 1, desc: 'TestExist</a>' },

{ id: 'setup-Edit', page: 'Utilisateur:Dr_Brains/Edit.js', type: 1, desc: 'Edit</a>' },

{ id: 'setup-Evaluation', page: 'Utilisateur:Dr_Brains/Evaluation.js', type: 1, desc: '<a href=http://fr.wikipedia.org/wiki/Utilisateur:Dr_Brains/Evaluation.js>Evaluation</a>' },

{ id: 'setup-BlocNote', page: 'Utilisateur:Dr_Brains/BlocNote.js', type: 1, desc: '<a href=http://fr.wikipedia.org/wiki/Utilisateur:Dr_Brains/BlocNote.js>BlocNote</a>' },

{ id: 'setup-MenuActions', page: 'Utilisateur:Dr_Brains/MenuActions.js', type: 1, desc: '<a href=http://fr.wikipedia.org/wiki/Utilisateur:Dr_Brains/MenuActions.js>MenuActions</a>' },

{ desc: 'Gadgets', type: 2 },

{ id: 'setup-Popups', page: 'Utilisateur:Dr_Brains/Popups.js', type: 1, desc: '<a href=http://fr.wikipedia.org/wiki/Utilisateur:Dr_Brains/Popups.js>Popups</a>' },

{ id: 'setup-wikEd', page: 'Utilisateur:Dr_Brains/wikEd.js', type: 1, desc: '<a href=http://fr.wikipedia.org/wiki/Utilisateur:Dr_Brains/wikEd.js>wikEd</a>' },

{ id: 'setup-HotCats', page: 'MediaWiki:Gadget-HotCats.js', type: 1, desc: '<a href=http://fr.wikipedia.org/wiki/MediaWiki:Gadget-HotCats.js>HotCats</a>' },

{ id: 'setup-SuiviCat', page: 'Utilisateur:Dr_Brains/SuiviCat.js', type: 1, desc: '<a href=http://fr.wikipedia.org/wiki/Utilisateur:Dr_Brains/SuiviCat.js>SuiviCat</a>' },

{ id: 'setup-LiveRC', page: 'User:EDUCA33E/LiveRC.js', type: 1, desc: '<a href=http://fr.wikipedia.org/wiki/User:EDUCA33E/LiveRC>LiveRC</a>' },

{ id: 'setup-demineur', page: 'Utilisateur:Dr_Brains/demineur.js', type: 1, desc: '<a href=http://fr.wikipedia.org/wiki/Utilisateur:Delhovlyn/Démineur>Démineur</a>' },

];

//////////////////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE ///////////////////////////////////////////////////////////////////////////////////////////////////////////

// LANCEMENT DU BOUZIN ...

addOnloadHook(RunManager);

if( ( wgPageName.match( cspEntryPage ) || wgPageName.match( cspEntryPagealt1 )|| wgPageName.match( cspEntryPagealt2 )|| wgPageName.match( cspEntryPagealt3 )|| wgPageName.match( cspEntryPagealt4 )|| wgPageName.match( cspEntryPagealt5 )|| wgPageName.match( cspEntryPagealt6 )|| wgPageName.match( cspEntryPagealt7 )|| wgPageName.match( cspEntryPagealt8 ) ) && wgAction=="view" ){ addOnloadHook(clientSidePreferencesLoadFunction); } if( ( wgPageName.match( cspCssPage ) || wgPageName.match( cspCssPagealt1 )|| wgPageName.match( cspCssPagealt2 )|| wgPageName.match( cspCssPagealt3 )|| wgPageName.match( cspCssPagealt4 )|| wgPageName.match( cspCssPagealt5 )|| wgPageName.match( cspCssPagealt6 )|| wgPageName.match( cspCssPagealt7 )|| wgPageName.match( cspCssPagealt8 ) ) && wgAction=="view" ){ addOnloadHook(CSSclientSidePreferencesLoadFunction); }

function cspCSSGetForm(CSS_oldconfig){ var f, i, CSS_res; //////////////////////////////////////// PARTIE PERSONNALISABLE (5/8) : ENTÊTE CSS /////////////////////////////////////////////////////////////////////////////////////////////////////

CSS_res = '<hr style="margin-top:1em;margin-bottom:1em;border:1px solid red;" />' + ' ' + ' Sélectionner les styles à ajouter à la page : ' + wgPageName.replace(/_/g," ") + ' ' + '<a href=http://fr.wikipedia.org/wiki/Discussion_Utilisateur:Dr_Brains/GlobalManager.js>(Aide)</a> ' + ' \n';

//////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE ///////////////////////////////////////////////////////////////////////////////////////////////////////////

for (i=0; i<cspCssFragments.length; i++) { f = cspCssFragments[i]; if (!f.desc) continue; if (f.type == 2) { if (i != 0) CSS_res += ' \n'; CSS_res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 3) { if (i != 0) CSS_res += ' \n'; CSS_res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 4) { if (i != 0) CSS_res += ' \n'; CSS_res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 5) { if (i != 0) CSS_res += ' \n'; CSS_res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 6) { if (i != 0) CSS_res += ' \n'; CSS_res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 8) { if (i != 0) CSS_res += ' \n'; CSS_res += f.desc + ' \n'; } else { CSS_res += '<input type="checkbox" name="' + f.id + '" '; if (CSS_oldconfig.indexOf(f.id) != -1) CSS_res += 'checked '; CSS_res += '/> ' + f.desc + '\n'; }                 }               }            }         }      }   } if ( wgPageName.match( cspMainScript )){ CSS_res += '

<input type="button" onclick="window.location.reload;" value="<Générer le style> Masquer le menu" /> \n' + '<hr style="margin-top:1em;border:1px solid red;" />'; + ' \n'; } else { CSS_res += '

<input type="button" onclick="cspCSSProcessForm;" value="Générer le style" /> \n' + '<hr style="margin-top:1em;border:1px solid red;" />'; + ' \n'; }  return CSS_res; }

function cspGetForm(oldconfig){ var f, i, res;

//////////////////////////////////////// PARTIE PERSONNALISABLE (6/8) : ENTÊTE JS /////////////////////////////////////////////////////////////////////////////////////////////////////

res = '<hr style="margin-top:1em;margin-bottom:1em;border:1px solid red;" />' + ' ' + ' Sélectionner les scripts à ajouter à la page : ' + wgPageName.replace(/_/g," ") + ' ' + '<a href=http://fr.wikipedia.org/wiki/Discussion_Utilisateur:Dr_Brains/GlobalManager.js>(Aide)</a> ' + ' \n';

//////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

for (i=0; i<cspFragments.length; i++) { f = cspFragments[i]; if (!f.desc) continue; if (f.type == 2) { if (i != 0) res += ' \n'; res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 3) { if (i != 0) res += ' \n'; res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 4) { if (i != 0) res += ' \n'; res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 5) { if (i != 0) res += ' \n'; res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 6) { if (i != 0) res += ' \n'; res += ' ' + f.desc + ' \n' + ' \n'; } else { if (f.type == 8) { if (i != 0) res += ' \n'; res += f.desc + ' \n'; } else { res += '<input type="checkbox" name="' + f.id + '" '; if (oldconfig.indexOf(f.id) != -1) res += 'checked '; res += '/> ' + f.desc + ' \n'; }                 }               }            }         }      }   } if ( wgPageName.match( cspMainScript )){ res += '

<input type="button" onclick="window.location.reload;" value="<Générer le script> Masquer le menu" /> \n' + '<hr style="margin-top:1em;border:1px solid red;" />'; + ' \n'; } else { res += '

<input type="button" onclick="cspProcessForm;" value="Générer le script" /> \n' + '<hr style="margin-top:1em;border:1px solid red;" />'; + ' \n';

}  return res; }

//*********************************

function RunManager{

//////////////////////////////////////// PARTIE PERSONNALISABLE (7/8) : PETITS LIENS PERMANENTS (1/2) ///////////////////////////////////////////////////////////////////////////////////////////////////// if((cspSkin == "monobook")|| (cspSkin == "vector")|| (cspSkin == "modern") || (cspSkin == "chick")|| (cspSkin == "myskin")|| (cspSkin == "simple")){

var ManagerLinks = "" + "<li id=\"pt-manager\" ><a href=" + SiteURL + cspMainScript + ">GlobalManager</a></li>" + "<li id=\"pt-csspage\" ><a href=" + SiteURL + cspCssPage + ">" + cspSkin + ".css</a></li>" + "<li id=\"pt-jspage\" ><a href=" + SiteURL + cspEntryPage + ">" + cspSkin + ".js</a></li>";

var ManagerTestLinks = ""

if(wgPageName.match( cspMainScript )){

ManagerTestLinks += "<li id=\"pt-cssmenu\" ><a href=\"javascript:CSSclientSidePreferencesLoadFunction\">Menu CSS</a></li>" + "<li id=\"pt-jsmenu\" ><a href=\"javascript:clientSidePreferencesLoadFunction\">MENU JS</a></li>";

}

//////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var conteneur = document.getElementById("p-personal").getElementsByTagName('ul')[0]; conteneur.innerHTML = conteneur.innerHTML + ManagerLinks + ManagerTestLinks ;

}

//////////////////////////////////////// PARTIE PERSONNALISABLE (7/8) : PETITS LIENS PERMANENTS (2/2) ///////////////////////////////////////////////////////////////////////////////////////////////////// if((cspSkin == "cologneblue")|| ( skin == "standard" )|| ( skin == "nostalgia" )){

var ManagerLinks = " " + "<a href=" + SiteURL + cspCssPage + ">" + cspSkin + ".js</a> • " + "<a href=" + SiteURL + cspMainScript + ">GlobalManager</a> • " + "<a href=" + SiteURL + cspEntryPage + ">" + cspSkin + ".css</a>" + " ";

var ManagerTestLinks = ""

if(wgPageName.match( cspMainScript )){

ManagerTestLinks += " <a href=\"javascript:CSSclientSidePreferencesLoadFunction\">Menu CSS</a> • " + "<a href=\"javascript:clientSidePreferencesLoadFunction\">MENU JS</a> ";

}

//////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var ManagerlinkDiv = document.createElement("div"); ManagerlinkDiv.innerHTML = ManagerLinks + ManagerTestLinks; var contentNode = document.getElementById("article"); contentNode.insertBefore(ManagerlinkDiv, contentNode.firstChild); ManagerlinkDiv.id = "ManagerLink"; } }

function cspReplacePage(x){

//////////////////////////////////////// PARTIE PERSONNALISABLE (8/8) : AFFICHAGE DU MENU /////////////////////////////////////////////////////////////////////////////////////////////////////

if(( skin == "monobook" )||( skin == "vector" )||( skin == "chick" )||( skin == "myskin" )||( skin == "simple" )){ var el = document.getElementById('content').childNodes[0]; }

if( skin == "modern" ){ var TopBoxesContainer = document.getElementById('mw_contentholder'); var TopBoxes = TopBoxesContainer.getElementsByTagName('div'); for(i=0;i<TopBoxes.length;i++){ if (hasClass(TopBoxes[i], "mw-topboxes" )){ var el = TopBoxes[i].childNodes[0]; }  } }

if(( skin == "cologneblue" )||( skin == "nostalgia" )||( skin == "standard" )){ var el = document.getElementById('article').childNodes[0]; }

while (el.nextSibling) { el = el.nextSibling; if ((el.tagName && el.tagName.toLowerCase == 'div')&&(el.id==ID_Div)) break; }  el.parentNode.replaceChild(x, el); }

function cspCSSReplacePage(x){

if(( skin == "monobook" )||( skin == "vector" )||( skin == "chick" )||( skin == "myskin" )||( skin == "simple" )){ var CSS_el = document.getElementById('content').childNodes[0]; }

if( skin == "modern" ){ var TopBoxesContainer = document.getElementById('mw_contentholder'); var TopBoxes = TopBoxesContainer.getElementsByTagName('div'); for(i=0;i<TopBoxes.length;i++){ if (hasClass(TopBoxes[i], "mw-topboxes" )){ var CSS_el = TopBoxes[i].childNodes[0]; }  } }

if(( skin == "cologneblue" )||( skin == "nostalgia" )||( skin == "standard" )){ var CSS_el = document.getElementById('article').childNodes[0]; }

while (CSS_el.nextSibling) { CSS_el = CSS_el.nextSibling; if ((CSS_el.tagName && CSS_el.tagName.toLowerCase == 'div')&&(CSS_el.id==ID_Div)) break; }  CSS_el.parentNode.replaceChild(x, CSS_el); }

//////////////////////////////////////// FIN DE LA PARTIE PERSONNALISABLE ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/* Construct an XMLHttpRequest **************************************************************************/ function cspCSSConstructHttpRequest {  var CSS_res; // Copied from http://developer.mozilla.org/en/docs/AJAX:Getting_Started if (window.XMLHttpRequest) { // Mozilla, Safari, ... CSS_res = new XMLHttpRequest; } else if (window.ActiveXObject) { // IE     CSS_res = new ActiveXObject("Microsoft.XMLHTTP"); }  return CSS_res; }

/**************************************************************************************************************/ function getCSSXmlObj(req) { if (req.responseXML && req.responseXML.documentElement) return req.responseXML; // Note: this doesn't work in konqueror, and the natural fix // var doc=document.implementation.createDocument; doc.loadXML(req.responseXML) // results in a segfault :-(  try {      var CSS_doc = new ActiveXObject("Microsoft.XMLDOM");      CSS_doc.async = "false";      CSS_doc.loadXML(req.responseText);   }    catch (err) {      return null;   }   return CSS_doc; } /* Checks whether the request has finished successfully   req = XMLHtmlRequest    Returns true or false **************************/ function cspCSSRequestDone(req) {   if (req.readyState != 4) {      // still not ready      return false;   }    if (window.http_request.status != 200) {      alert('Il y a eu un problème avec la requête.');      return false;   }   return true; } // Source: http://www.albionresearch.com/misc/urlencode.php ************************************************************ function URLEncode( plaintext ) {   // The Javascript escape and unescape functions do not correspond   // with what browsers actually do...   var SAFECHARS = "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "-_.!~*'"; var HEX = "0123456789ABCDEF"; var encoded = ""; for (var i = 0; i < plaintext.length; i++ ) { var ch = plaintext.charAt(i); if (ch == " ") { encoded += "+";				// x-www-urlencoded, rather than %20 } else if (SAFECHARS.indexOf(ch) != -1) { encoded += ch; } else { var charCode = ch.charCodeAt(0); if (charCode > 255) { alert( "Le caractère Unicode '" + ch + "' ne peut pas être encodé en URL standard.\n" +		  "(l'encodage URL supporte seulement les caractères de 8 bits.)\n" + 		   "Un espace (+) sera substitué." ); encoded += "+"; } else { encoded += "%"; encoded += HEX.charAt((charCode >> 4) & 0xF); encoded += HEX.charAt(charCode & 0xF); }     }   } // for return encoded; } /* Returns dictionary with form data *****************************************************************/ function cspCSSFormData(CSS_form) { var CSS_res = new Object; for (var i=0; i<CSS_form.elements.length; ++i) { var CSS_el = CSS_form.elements[i]; var CSS_data; if (!CSS_el.name) continue; if (CSS_el.tagname && CSS_el.tagname == 'textarea') CSS_data = CSS_el.childNodes[0].CSS_data; else if (CSS_el.checked) CSS_data = ((CSS_el.checked == 'checked') ? 'on' : 'off'); else if (CSS_el.value) CSS_data = CSS_el.value; else continue; CSS_res[CSS_el.name] = CSS_data; }  return CSS_res; } /* Returns index of fragment with given id in fraglist, or -1 if it is not there. ******************************************/ function cspCSSFindFragment(id, fraglist) {  for (var n=0; n<fraglist.length; n++) { if (fraglist[n].id == id) return n;  } return -1; } /* Add fragment f to the list of fragments to be downloaded */ function cspCSSAddFragment(f) {  var d, pos, i, tmp; /* If f is already on the list, we're done */ if (cspCSSFindFragment(f.id, window.fragments) != -1) return; pos = -1; if (f.deps) { /* Add all dependencies */ for (i=0; i<f.deps.length; i++) { tmp = cspCSSFindFragment(f.deps[i], cspCssFragments); if (tmp == -1) alert("Erreur dans cspCSSAddFragment : Impossible de trouver " + f.deps[i]); cspCSSAddFragment(cspCssFragments[tmp]); }     /* Find the last dependency */ for (i=0; i<f.deps.length; i++) { tmp = cspCssFindFragment(f.deps[i], window.fragments); if (tmp>pos) pos = tmp; }  }   /* Add f after all its dependencies */ window.fragments.splice(pos+1, 0, f); } /**************************************************************************************************** Main script ****************/ /* This function is called if the user visits the entry page. */ function CSSclientSidePreferencesLoadFunction {  var CSS_p = document.createElement("div"); CSS_p.id=ID_Div; CSS_p.innerHTML = "Veuillez patienter pendant l\'analyse de votre configuration …"; cspCSSReplacePage(CSS_p); window.http_request = cspCSSConstructHttpRequest; window.http_request.onreadystatechange = cspCSSReceivedOldScript; var url = SiteURLbis + wgPageName + '&action=raw'; /////////////////////////////////////////////////////////////////////////////////////////////////////////// Analyse window.http_request.open('GET', url, true); window.http_request.send(null); } /* This function is called when the old user script is received. ***********************************************/ function cspCSSReceivedOldScript {  if (!cspCSSRequestDone(window.http_request)) return; window.oldscript = window.http_request.responseText; var CSS_oldconfig = []; var i = window.oldscript.indexOf(cspCssConfigComment); if (i != -1) { var i2 = window.oldscript.indexOf('\n', i); var CSS_oldconfig = window.oldscript.substring(i+cspCssConfigComment.length+1, i2).split(' '); }  cspCSSDisplayForm(CSS_oldconfig); } /* Creates and display the HTML form. ****************************************************************************************************************/ function cspCSSDisplayForm(CSS_oldconfig) {  var cspCssForm = document.createElement("form"); cspCssForm.innerHTML = cspCSSGetForm(CSS_oldconfig); cspCssForm.name = 'cspCssForm'; cspCssForm.style.padding="1em"; cspCSSReplacePage(cspCssForm); } /* This function is called when the user presses the "Generate script" button. **************************************************************************  It collects all fragments that should be downloaded in window.fragments and starts building the new script in window.newscript */ function cspCSSProcessForm {  window.fragments = new Array; var CSS_newconfig = ''; for (var i=0; i<cspCssFragments.length; i++) { var f = cspCssFragments[i]; if (f.desc && f.type <= 1 && document.cspCssForm[f.id].checked) { cspCSSAddFragment(f); CSS_newconfig += ' ' + f.id; }  }   window.newscript = ''; var i = window.oldscript.indexOf(cspStartComment); if (i != -1) window.newscript += window.oldscript.substr(0, i)  window.newscript += cspCssStartComment + cspCssStartComment2 + '\n'; window.newscript += cspCssConfigComment + CSS_newconfig + " \*/" + '\n\n'; var s = ''; window.newscript += s;  window.bottom = document.cspCssForm; cspCSSGetFragments; } /* Go through the fragments listed in window.fragments and ************************************************************************ build window.newscript */ function cspCSSGetFragments {  if (window.fragments.length == 0) { cspCSSFinalizeScript; return; }   var f = window.fragments[0]; if (f.type == 1) cspCSSImportFragment(f); else cspCSSImportPage(f) } /* Callback for HTTP request initiated in cspDownloadFragment **********************************************************************************************/ function cspCSSReceivedFragment {  if (!cspCSSRequestDone(window.http_request)) return; var msg = document.createTextNode(' OK'); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.bottom = window.bottom.parentNode.insertBefore(document.createElement('BR'), bottom.nextSibling); var txt = window.http_request.responseText;

var tmp = /\/\/[ ]* [ ]*\n/.exec(txt); if (tmp) txt = txt.slice(tmp.index + tmp[0].length); tmp = /\/\/[ ]*<\/nowiki><\/pre>[ ]*(\n|$)/.exec(txt); if (tmp) txt = txt.slice(0, tmp.index); else { tmp = /\/\*.* .*\*\/\n/.exec(txt); if (tmp) txt = txt.slice(tmp.index + tmp[0].length); tmp = /\/\*.*<\/pre>.*\*\/(\n|$)/.exec(txt); if (tmp) txt = txt.slice(0, tmp.index); else { tmp = / [ ]*\n/.exec(txt); if (tmp) txt = txt.slice(tmp.index + tmp[0].length); tmp = /<\/pre>[ ]*(\n|$)/.exec(txt); if (tmp) txt = txt.slice(0, tmp.index); }  }   window.newscript += '\n/\* Copie de [[' + (window.fragments[0].page).replace('_', ' ')                        + ', revision ' + window.fragments[0].rev + '\n\n' + txt + ' \*/\n';   window.fragments = window.fragments.slice(1);   cspCSSGetFragments; } /*  *********************************************************************************************/ function cspCSSImportFragment(f) {   var msg = document.createTextNode('Copie de ' + f.page);   window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling);   window.bottom = window.bottom.parentNode.insertBefore(document.createElement('BR'), bottom.nextSibling);   window.newscript += '\n/\* Copie de ' + (window.fragments[0].page).replace('_', ' ') + ' \*/ \n\n'      +  f.page ;   window.fragments = window.fragments.slice(1);   cspCSSGetFragments; }

/* *********************************************************************************************/ function cspCSSImportPage(f) {  var msg = document.createTextNode('Importation de ' + f.page); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.bottom = window.bottom.parentNode.insertBefore(document.createElement('BR'), bottom.nextSibling); window.newscript += '\n/\* Importation de ' + (window.fragments[0].page).replace('_', ' ') + ' \*/\n\n' + '@import url(' + SiteURLbis + f.page + '&action=raw&ctype=text/css); \n'; window.fragments = window.fragments.slice(1); cspCSSGetFragments; }

/****************************************************************************************************/ function cspCSSFinalizeScript {  window.newscript += '\n' + cspCssEndComment; var i = window.oldscript.indexOf(cspCssEndComment); if (i != -1) window.newscript += window.oldscript.substr(i+cspCssEndComment.length) cspCSSLoadEditPage; }

/****************************************************************************************************/ function cspCSSLoadEditPage {  var msg = document.createTextNode('Chargement de votre style ...'); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.http_request = cspCSSConstructHttpRequest; window.http_request.overrideMimeType('text/xml'); window.http_request.onreadystatechange = cspCSSReceivedEditPage; var url = SiteURLbis + wgPageName + '&action=edit'; /////////////////////////////////////////////////////////////////////////////////////////////////////////// Édition

window.http_request.open('GET', url, true); window.http_request.send(null); }

/****************************************************************************************************/ function cspCSSReceivedEditPage {  if (!cspCSSRequestDone(window.http_request)) return; var doc = window.http_request.responseXML; var editform = doc.getElementById('editform'); var CSS_data = cspCSSFormData(editform); CSS_data['wpTextbox1'] = window.newscript; CSS_data['wpSummary'] = cspCssSummary; CSS_data['wpMinoredit'] = 'on'; CSS_data['wpPreview'] = null; CSS_data['wpDiff'] = null; var msg = document.createTextNode(' Sauvegarde de votre style ...'); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.http_request = cspCSSConstructHttpRequest; window.http_request.overrideMimeType('text/xml'); window.http_request.onreadystatechange = cspCSSEditPageSaved; var url = SiteURLbis + wgPageName + '&action=submit'; /////////////////////////////////////////////////////////////////////////////////////////////////////////// Sauvegarde window.http_request.open('POST', url, true); window.http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); CSS_sendMe = ''; for (var name in CSS_data) { if (CSS_data[name]) { if (CSS_sendMe.length > 0) CSS_sendMe += '&'; CSS_sendMe += URLEncode(name) + '=' + URLEncode(CSS_data[name]); }  }   window.http_request.send(CSS_sendMe); }

/****************************************************************************************************/ function cspCSSEditPageSaved {  if (!cspCSSRequestDone(window.http_request)) return; var msg = document.createTextNode(' OK'); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.bottom = window.bottom.parentNode.insertBefore(document.createElement('BR'), bottom.nextSibling); window.location.reload; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SCRIPT //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*********************************************************************************************************************************** * GLOBAL-SCRIPT-MANAGER                                                                                                          * * Permet de gérer une liste de scripts à la manière des gadgets mais pour n'importe quelle page. * * Pour installer et configurer ce gestionnaire : Voir Discussion utilisateur:Dr Brains/GlobalScriptManager.js                * ***********************************************************************************************************************************/

/* Construct an XMLHttpRequest */ function cspConstructHttpRequest {  var res; // Copied from http://developer.mozilla.org/en/docs/AJAX:Getting_Started if (window.XMLHttpRequest) { // Mozilla, Safari, ... res = new XMLHttpRequest; } else if (window.ActiveXObject) { // IE     res = new ActiveXObject("Microsoft.XMLHTTP"); }  return res; } function getXmlObj(req) { if (req.responseXML && req.responseXML.documentElement) return req.responseXML; // Note: this doesn't work in konqueror, and the natural fix // var doc=document.implementation.createDocument; doc.loadXML(req.responseXML) // results in a segfault :-(  try {      var doc = new ActiveXObject("Microsoft.XMLDOM");      doc.async = "false";      doc.loadXML(req.responseText);   }    catch (err) {      return null;   }   return doc; } /* Checks whether the request has finished successfully   req = XMLHtmlRequest    Returns true or false */ function cspRequestDone(req) {   if (req.readyState != 4) {      // still not ready      return false;   }    if (window.http_request.status != 200) {      alert('Il y a eu un problème avec la requête.');      return false;   }   return true; } // Source: http://www.albionresearch.com/misc/urlencode.php function URLEncode( plaintext ) {   // The Javascript escape and unescape functions do not correspond   // with what browsers actually do...   var SAFECHARS = "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "-_.!~*'";   var HEX = "0123456789ABCDEF"; var encoded = ""; for (var i = 0; i < plaintext.length; i++ ) { var ch = plaintext.charAt(i); if (ch == " ") { encoded += "+";				// x-www-urlencoded, rather than %20 } else if (SAFECHARS.indexOf(ch) != -1) { encoded += ch; } else { var charCode = ch.charCodeAt(0); if (charCode > 255) { alert( "Le caractère Unicode '" + ch + "' ne peut pas être encodé en URL standard.\n" +		  "(l'encodage URL supporte seulement les caractères de 8 bits.)\n" + 		   "Un espace (+) sera substitué." ); encoded += "+"; } else { encoded += "%"; encoded += HEX.charAt((charCode >> 4) & 0xF); encoded += HEX.charAt(charCode & 0xF); }     }   } // for return encoded; } /* Returns dictionary with form data */ function cspFormData(form) { var res = new Object; for (var i=0; i<form.elements.length; ++i) { var el = form.elements[i]; var data; if (!el.name) continue; if (el.tagname && el.tagname == 'textarea') data = el.childNodes[0].data; else if (el.checked) data = ((el.checked == 'checked') ? 'on' : 'off'); else if (el.value) data = el.value; else continue; res[el.name] = data; }  return res; } /* Returns index of fragment with given id in fraglist, or -1 if it is not there. */ function cspFindFragment(id, fraglist) {  for (var n=0; n<fraglist.length; n++) { if (fraglist[n].id == id) return n;  } return -1; } /* Add fragment f to the list of fragments to be downloaded */ function cspAddFragment(f) {  var d, pos, i, tmp; /* If f is already on the list, we're done */ if (cspFindFragment(f.id, window.fragments) != -1) return; pos = -1; if (f.deps) { /* Add all dependencies */ for (i=0; i<f.deps.length; i++) { tmp = cspFindFragment(f.deps[i], cspFragments); if (tmp == -1) alert("Erreur dans cspAddFragment : Impossible de trouver " + f.deps[i]); cspAddFragment(cspFragments[tmp]); }     /* Find the last dependency */ for (i=0; i<f.deps.length; i++) { tmp = cspFindFragment(f.deps[i], window.fragments); if (tmp>pos) pos = tmp; }  }   /* Add f after all its dependencies */ window.fragments.splice(pos+1, 0, f); } /********** Main script **********/ /* This function is called if the user visits the entry page. */ function clientSidePreferencesLoadFunction {  var p = document.createElement("div"); p.id=ID_Div; p.innerHTML = "Veuillez patienter pendant l'analyse de votre configuration …"; cspReplacePage(p); window.http_request = cspConstructHttpRequest; window.http_request.onreadystatechange = cspReceivedOldScript; var url = SiteURLbis + wgPageName + '&action=raw'; ////////////////////////////////////////////********************************************* window.http_request.open('GET', url, true); window.http_request.send(null); } /* This function is called when the old user script is received. */ function cspReceivedOldScript {  if (!cspRequestDone(window.http_request)) return; window.oldscript = window.http_request.responseText; var oldconfig = []; var i = window.oldscript.indexOf(cspConfigComment); if (i != -1) { var i2 = window.oldscript.indexOf('\n', i); var oldconfig = window.oldscript.substring(i+cspConfigComment.length+1, i2).split(' '); }  cspDisplayForm(oldconfig); } /* Creates and display the HTML form. */ function cspDisplayForm(oldconfig) {  var cspForm = document.createElement("form"); cspForm.innerHTML = cspGetForm(oldconfig); cspForm.name = 'cspForm'; cspForm.style.padding="1em"; cspReplacePage(cspForm); } /* This function is called when the user presses the "Generate script" button. It collects all fragments that should be downloaded in window.fragments and starts building the new script in window.newscript */ function cspProcessForm {  window.fragments = new Array; var newconfig = ''; for (var i=0; i<cspFragments.length; i++) { var f = cspFragments[i]; if (f.desc && f.type <= 1 && document.cspForm[f.id].checked) { cspAddFragment(f); newconfig += ' ' + f.id; }  }   window.newscript = ''; var i = window.oldscript.indexOf(cspStartComment); if (i != -1) window.newscript += window.oldscript.substr(0, i)  window.newscript += cspStartComment + cspStartComment2 + '\n'; window.newscript += cspConfigComment + newconfig + '\n\n'; var s = 'document.write(\'<script type="text/javascript" src="' + SiteURLbis + cspMainScript + '&action=raw&ctype=text/javascript"> \'); \n'; window.newscript += s;  window.bottom = document.cspForm; cspGetFragments; } /* Go through the fragments listed in window.fragments and build window.newscript */ function cspGetFragments {  if (window.fragments.length == 0) { cspFinalizeScript; return; }   var f = window.fragments[0]; if (f.type == 1) cspImportFragment(f); else cspDownloadFragment(f) } /* Download a JavaScript fragment to be included in the user script */ function cspDownloadFragment(f) {  var msg = document.createTextNode('Copie de ' + f.page + ' ...'); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.http_request = cspConstructHttpRequest; window.http_request.onreadystatechange = cspReceivedFragment; var url = + SiteURLbis + f.page + '&oldid=' + f.rev + '&action=raw&ctype=text/javascript'; window.http_request.open('GET', url, true); window.http_request.send(null); } /* Callback for HTTP request initiated in cspDownloadFragment */ function cspReceivedFragment {  if (!cspRequestDone(window.http_request)) return; var msg = document.createTextNode(' OK'); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.bottom = window.bottom.parentNode.insertBefore(document.createElement('BR'), bottom.nextSibling); var txt = window.http_request.responseText;

var tmp = /\/\/[ ]* [ ]*\n/.exec(txt); if (tmp) txt = txt.slice(tmp.index + tmp[0].length); tmp = /\/\/[ ]*<\/nowiki><\/pre>[ ]*(\n|$)/.exec(txt); if (tmp) txt = txt.slice(0, tmp.index); else { tmp = /\/\*.* .*\*\/\n/.exec(txt); if (tmp) txt = txt.slice(tmp.index + tmp[0].length); tmp = /\/\*.*<\/pre>.*\*\/(\n|$)/.exec(txt); if (tmp) txt = txt.slice(0, tmp.index); else { tmp = / [ ]*\n/.exec(txt); if (tmp) txt = txt.slice(tmp.index + tmp[0].length); tmp = /<\/pre>[ ]*(\n|$)/.exec(txt); if (tmp) txt = txt.slice(0, tmp.index); }  }   window.newscript += '\n// Copie de ' + (window.fragments[0].page).replace('_', ' ')                        + ', revision ' + window.fragments[0].rev + '\n\n' + txt + '\n'; window.fragments = window.fragments.slice(1); cspGetFragments; } /* Import JavaScript using a tag */ function cspImportFragment(f) {  var msg = document.createTextNode('Importation de ' + f.page); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.bottom = window.bottom.parentNode.insertBefore(document.createElement('BR'), bottom.nextSibling); window.newscript += '\n// Importation de ' + (window.fragments[0].page).replace('_', ' ') + '\n\n' + 'document.write(\'<script type="text/javascript" src="' + SiteURLbis + f.page + '&action=raw&ctype=text/javascript"> \'); \n'; window.fragments = window.fragments.slice(1); cspGetFragments; } function cspFinalizeScript {  window.newscript += '\n' + cspEndComment; var i = window.oldscript.indexOf(cspEndComment); if (i != -1) window.newscript += window.oldscript.substr(i+cspEndComment.length) cspLoadEditPage; } function cspLoadEditPage {  var msg = document.createTextNode('Chargement de votre script ...'); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.http_request = cspConstructHttpRequest; window.http_request.overrideMimeType('text/xml'); window.http_request.onreadystatechange = cspReceivedEditPage; var url = SiteURLbis + wgPageName + '&action=edit'; ////////////////////////////////////////******************************************************

window.http_request.open('GET', url, true); window.http_request.send(null); } function cspReceivedEditPage {  if (!cspRequestDone(window.http_request)) return; var doc = window.http_request.responseXML; var editform = doc.getElementById('editform'); var data = cspFormData(editform); data['wpTextbox1'] = window.newscript; data['wpSummary'] = cspSummary; data['wpMinoredit'] = 'on'; data['wpPreview'] = null; data['wpDiff'] = null; var msg = document.createTextNode(' Sauvegarde de votre script ...'); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.http_request = cspConstructHttpRequest; window.http_request.overrideMimeType('text/xml'); window.http_request.onreadystatechange = cspEditPageSaved; var url = SiteURLbis + wgPageName + '&action=submit'; ///////////////////////////////////****************************************** window.http_request.open('POST', url, true); window.http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); sendMe = ''; for (var name in data) { if (data[name]) { if (sendMe.length > 0) sendMe += '&'; sendMe += URLEncode(name) + '=' + URLEncode(data[name]); }  }   window.http_request.send(sendMe); } function cspEditPageSaved {  if (!cspRequestDone(window.http_request)) return; var msg = document.createTextNode(' OK'); window.bottom = window.bottom.parentNode.insertBefore(msg, bottom.nextSibling); window.bottom = window.bottom.parentNode.insertBefore(document.createElement('BR'), bottom.nextSibling); window.location.reload; }

/****************************************************************************************************/ //