« MediaWiki:Common.js » : différence entre les versions

Page de l’interface de MediaWiki
(Adaptation pour ES5)
(Affichage du formulaire de nouvel article si l'utilisateur est connecté)
 
(8 versions intermédiaires par le même utilisateur non affichées)
Ligne 135 : Ligne 135 :
// ######## NEW CODE ########
// ######## NEW CODE ########
// Change table card to dark if it's has a color if isn't, apply this modification to the td (for buttons)
// Change table card to dark if it's has a color if isn't, apply this modification to the td (for buttons)
if (document.documentElement.classList.contains("skin-citizen-dark")) {
if (document.documentElement.classList.contains("skin-citizen-dark")&&window.location.pathname!=='/index.php/Accueil') {
   document.querySelectorAll("table").forEach(function(table){
   document.querySelectorAll("table").forEach(function(table){
     if (!(table.style.backgroundColor===""||table.style.backgroundColor==="transparent")) {
     if (!(table.style.backgroundColor===""||table.style.backgroundColor==="transparent")) {
Ligne 144 : Ligne 144 :
           td.style.backgroundColor="#212630"
           td.style.backgroundColor="#212630"
           td.style.border="2px solid rgb(101 133 209)"
           td.style.border="2px solid rgb(101 133 209)"
          td.style.margin="5px"
         }
         }
       })
       })
Ligne 149 : Ligne 150 :
   })  
   })  
}
}
fetch("https://wikithionville.fr/api.php?action=query&meta=userinfo&uiprop=rights&format=json").then(function(res) {
    return res.json()
})
.then(function(res) {
    if (res.query.userinfo.rights.includes("edit")) {
        document.getElementById("search_form").style.display="none"
        document.getElementById("new_article_form").style.display="block"
    }
})

Dernière version du 6 mai 2024 à 16:07

/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */
/**
 * Ajouter un bouton à la fin de la barre d'outils
 */
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) {
  // Supprimée car non fonctionelle
  // mwCustomEditButtons[mwCustomEditButtons.length] =
  //   {"imageId": imageId,
  //    "imageFile": imageFile,
  //    "speedTip": speedTip,
  //    "tagOpen": tagOpen,
  //    "tagClose": tagClose,
  //    "sampleText": sampleText};
}
 
/**
 * Insertion de nouveaux boutons dans la barre d'outil
 */
 



addCustomButton('http://upload.wikimedia.org/wikipedia/commons/1/1f/Button_mp3.png',
                'Insérer un fichier mp3',
                '<flashmp3> NomFichier.mp3 </flashmp3>',
                '',
                '',
                'mw-editbutton-mp3');


addCustomButton('http://upload.wikimedia.org/wikipedia/commons/9/92/Nuvola-Multimedia01.png',
                'Video',
                '{{',
                '}}',
                '#ev:service|code|taille',
                'mw-editbutton-video');

                


addCustomButton('http://upload.wikimedia.org/wikipedia/commons/0/04/Button_array.png',
                'Tableau',
                '{| border=1\n|-\n|\n|\n|}',
                '',
                '',
                'mw-editbutton-array');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/c/c9/Button_strike.png',
                'Rayer',
                '<s>',
                '</s>',
                '',
                'mw-editbutton-strike');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/8/88/Btn_toolbar_enum.png',
                'Énumération',
                '\n# élément 1\n# élément 2\n# élément 3',
                '',
                '',
                'mw-editbutton-enum');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/1/11/Btn_toolbar_liste.png',
                'Liste',
                '\n* élément A\n* élément B\n* élément C',
                '',
                '',
                'mw-editbutton-liste');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/9/9e/Btn_toolbar_gallery.png',
                'Galerie d\'images',
                '\n<!--Consultez l Anti-sèche pour les options de la galerie-->\n<center>\n<gallery caption="Donner un titre à votre galerie">\nImage:Exemple.jpg|légende\nImage:Exemple1.jpg|légende\nImage:Exemple2.jpg|légende\n</gallery>\n</center>',
                '',
                '',
                'mw-editbutton-gallery');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
                'Commentaire',
                '<!--',
                '-->',
                '',
                'mw-editbutton-comment');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/4/47/Button_redir.png',
                'Redirection',
                '#REDIRECT [[',
                ']]',
                'nom de la destination',
                'mw-editbutton-redir');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/b/b4/Button_category03.png',
                'Catégorie',
                '[[Catégorie:',
                ']]',
                'nom de la catégorie',
                'mw-editbutton-category');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/3/3b/Button_template_alt.png',
                'Modèle',
                '{{',
                '}}',
                'modèle ou page à inclure',
                'mw-editbutton-template');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/c/c4/Button_ref.png',
                'Référence',
                '<ref>',
                '</ref>',
                'référence, citation ou lien',
                'mw-editbutton-ref');

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/6/64/Buttonrefvs8.png',
                'Index des références',
                '== Notes et références ==\n<references />',
                '',
                '',
                'mw-editbutton-references');

var voirAussi = '<!-- Suggestion de présentation des annexes. Aide : http://fr.wikipedia.org/wiki/Aide:Note -->\n'
 + '== Annexes ==\n'
 + '=== Notes et références ===\n'
 + '<references/>\n'
 + '=== Articles connexes ===\n'
 + '* [[À remplacer]]\n'
 + '*\n'
 + '=== Liens et documents externes ===\n'
 + '*\n';
addCustomButton('http://upload.wikimedia.org/wikipedia/commons/b/bb/Seealso.png',
                'Section Voir aussi',
                voirAussi,
                '',
                '',
                'mw-editbutton-voiraussi');

// ######## NEW CODE ########
// Change table card to dark if it's has a color if isn't, apply this modification to the td (for buttons)
if (document.documentElement.classList.contains("skin-citizen-dark")&&window.location.pathname!=='/index.php/Accueil') {
  document.querySelectorAll("table").forEach(function(table){
    if (!(table.style.backgroundColor===""||table.style.backgroundColor==="transparent")) {
      table.style.backgroundColor="#212630"
    }else{
      table.querySelectorAll("td").forEach(function(td){
        if (!(td.style.backgroundColor===""||td.style.backgroundColor==="transparent")) {
          td.style.backgroundColor="#212630"
          td.style.border="2px solid rgb(101 133 209)"
          td.style.margin="5px"
        }
      })
    }
  }) 
}

fetch("https://wikithionville.fr/api.php?action=query&meta=userinfo&uiprop=rights&format=json").then(function(res) {
    return res.json()
})
.then(function(res) {
    if (res.query.userinfo.rights.includes("edit")) {
        document.getElementById("search_form").style.display="none"
        document.getElementById("new_article_form").style.display="block"
    }
})