MediaWiki:Vector-2022.js: Difference between revisions

    From Nonbinary Wiki
    No edit summary
    (update logo flags with self-hosted version)
     
    (16 intermediate revisions by the same user not shown)
    Line 1: Line 1:
    /* Adds all the CSS so that if JS doesn't load, nothing will change. */
    /* ---- RANDOM PRIDE FLAGS IN THE LOGO ---- */
    function addStyle(styleString) {
    var picArr = {"neutrois": "https://nonbinary.wiki/images/thumb/c/c1/Neutrois.png/320px-Neutrois.png",
      const style = document.createElement('style');
    "nonbinary": "https://nonbinary.wiki/images/thumb/c/c0/Nonbinary.png/320px-Nonbinary.png",
      style.textContent = styleString;
    "transgender": "https://nonbinary.wiki/images/thumb/c/cd/Transgender.png/320px-Transgender.png",
      document.head.append(style);
    "genderqueer": "https://nonbinary.wiki/images/thumb/b/b5/Genderqueer.png/320px-Genderqueer.png",
    }
    "genderfluid": "https://nonbinary.wiki/images/thumb/1/12/Genderfluid.png/320px-Genderfluid.png",
    "genderflux": "https://nonbinary.wiki/images/thumb/a/ae/Genderflux.png/320px-Genderflux.png",
    "agender": "https://nonbinary.wiki/images/thumb/8/83/Agender.png/320px-Agender.png",
    "androgyne": "https://nonbinary.wiki/images/thumb/7/73/Androgyne.png/320px-Androgyne.png",
    "ambonec": "https://nonbinary.wiki/images/thumb/2/2e/Ambonec.png/320px-Ambonec.png",
    "aporagender": "https://nonbinary.wiki/images/thumb/4/48/Aporagender.png/320px-Aporagender.png",
    "bigender": "https://nonbinary.wiki/images/thumb/7/7c/Bigender_by_no-bucks-for-this-doe.png/320px-Bigender_by_no-bucks-for-this-doe.png",
    "deminonbinary": "https://nonbinary.wiki/images/thumb/e/ee/Deminonbinary.png/320px-Deminonbinary.png",
    "graygender": "https://nonbinary.wiki/images/a/a2/Graygender_flag.png",
    "intergender": "https://nonbinary.wiki/images/thumb/d/d3/Intergender.png/320px-Intergender.png",
    "multigender": "https://nonbinary.wiki/images/thumb/3/3b/Multigender.png/320px-Multigender.png",
    "maverique": "https://nonbinary.wiki/images/thumb/e/e2/Maverique.png/320px-Maverique.png",
    "polygender": "https://nonbinary.wiki/images/thumb/8/87/Polygender.png/320px-Polygender.png",
    "trigender": "https://nonbinary.wiki/images/thumb/4/40/Trigender.png/320px-Trigender.png",
    "demiboy": "https://nonbinary.wiki/images/thumb/5/5c/Demiboy.png/320px-Demiboy.png",
    "demigirl": "https://nonbinary.wiki/images/thumb/8/80/Demigirl.png/320px-Demigirl.png",
    "gender neutral": "https://nonbinary.wiki/images/thumb/f/f1/Gender_neutral_2_by_enbygsrd.png/320px-Gender_neutral_2_by_enbygsrd.png",
    "transmasculine": "https://nonbinary.wiki/images/thumb/8/8d/Transmasculine_pride_flag.png/320px-Transmasculine_pride_flag.png",
    "transfeminine": "https://nonbinary.wiki/images/thumb/b/b4/Transfeminine_pride_flag.png/320px-Transfeminine_pride_flag.png",
    "xenogender": "https://nonbinary.wiki/images/thumb/7/7b/Xenogender.png/320px-Xenogender.png",
    "firegender": "https://nonbinary.wiki/images/3/3a/Firegender-1.png",
    "genderfuck": "https://nonbinary.wiki/images/thumb/e/e1/Genderfuck_by_januceit.png/320px-Genderfuck_by_januceit.png",
    "genderfaun": "https://nonbinary.wiki/images/5/52/Genderfaunet.png",
    "genderfaer": "https://nonbinary.wiki/images/2/29/Genderfaer_1.png",
    "nonbinary man": "https://nonbinary.wiki/images/thumb/a/ac/Nonbinary_man_by_bulldykebutch.png/320px-Nonbinary_man_by_bulldykebutch.png",
    "nonbinary woman": "https://nonbinary.wiki/images/thumb/a/a8/Nonbinary_woman_by_bulldykebutch.png/320px-Nonbinary_woman_by_bulldykebutch.png",
    "libramasculine": "https://nonbinary.wiki/images/thumb/f/fb/Libramasculine.png/320px-Libramasculine.png",
    "librafeminine": "https://nonbinary.wiki/images/thumb/a/a8/Librafeminine.png/320px-Librafeminine.png",
    "faesari": "https://nonbinary.wiki/images/thumb/7/70/Faesari.png/320px-Faesari.png"
    };


    addStyle(`
    var myNumber = Math.floor((Math.random() * 33));
      /* Defaults to the nonbinary flag */
    #mw-head {
      background: white;
      background-repeat: repeat-x;
      background-size: contain;
    }
     
    /* Style article tabs for the flags */
    .vector-menu-tabs .selected {
      background: rgba(255, 255, 255, .7);
    }
    .vector-menu-tabs li {
      background: rgba(255, 255, 255, .3);
    }
    .vector-menu-tabs li:hover {
      background: rgba(255, 255, 255, .7);
    }
    .vector-menu-tabs a {
      background-image: none;
    }
     
    /* "Happy Nonbinary Awareness Week" banner */
    .nbweek-banner {
        background: rgba(255,255,255,.4);
        padding: 7px;
        position: absolute;
        bottom: 0;
        font-weight: bold;
    }
    .nbweek-flag {
      font-size: 80%;
      font-weight: normal;
      font-style: italic;
    }
     
    /* Adds transparent backgrouund to top user menu for better readability */
    #p-personal {
        background: rgba(255, 255, 255, .7);
        top: 0;
        right: 0;
        padding-top: 5px;
        padding-right: 15px;
        border-radius: 0 0 0 5px;
        display: inline;
        right: 0;
    }
    #p-personal ul {
        padding: 0;
    }
    `);
     
    var picArr = {"neutrois": "https://static.miraheze.org/nonbinarywiki/c/c1/Neutrois.png",
    "nonbinary": "https://static.miraheze.org/nonbinarywiki/thumb/c/c0/Nonbinary.png/800px-Nonbinary.png",
    "transgender": "https://static.miraheze.org/nonbinarywiki/c/cd/Transgender.png",
    "genderqueer": "https://static.miraheze.org/nonbinarywiki/b/b5/Genderqueer.png",
    "genderfluid": "https://static.miraheze.org/nonbinarywiki/1/12/Genderfluid.png",
    "genderflux": "https://static.miraheze.org/nonbinarywiki/a/ae/Genderflux.png",
    "agender": "https://static.miraheze.org/nonbinarywiki/8/83/Agender.png",
    "androgyne": "https://static.miraheze.org/nonbinarywiki/7/73/Androgyne.png",
    "ambonec": "https://static.miraheze.org/nonbinarywiki/2/2e/Ambonec.png",
    "aporagender": "https://static.miraheze.org/nonbinarywiki/4/48/Aporagender.png",
    "bigender": "https://static.miraheze.org/nonbinarywiki/7/7c/Bigender_by_no-bucks-for-this-doe.png",
    "deminonbinary": "https://static.miraheze.org/nonbinarywiki/e/ee/Deminonbinary.png",
    "graygender": "https://static.miraheze.org/nonbinarywiki/a/a2/Graygender_flag.png",
    "intergender": "https://nonbinary.wiki/wiki/File:Intergender.png",
    "multigender": "https://static.miraheze.org/nonbinarywiki/3/3b/Multigender.png",
    "maverique": "https://static.miraheze.org/nonbinarywiki/e/e2/Maverique.png",
    "polygender": "https://static.miraheze.org/nonbinarywiki/8/87/Polygender.png",
    "trigender": "https://static.miraheze.org/nonbinarywiki/4/40/Trigender.png",
    "demiboy": "https://static.miraheze.org/nonbinarywiki/5/5c/Demiboy.png",
    "demigirl": "https://static.miraheze.org/nonbinarywiki/8/80/Demigirl.png",
    "gender neutral": "https://static.miraheze.org/nonbinarywiki/f/f1/Gender_neutral_2_by_enbygsrd.png",
    "transmasculine": "https://static.miraheze.org/nonbinarywiki/8/8d/Transmasculine_pride_flag.png",
    "transfeminine": "https://static.miraheze.org/nonbinarywiki/b/b4/Transfeminine_pride_flag.png"};
     
    var myNumber = Math.floor((Math.random() * 23));
    var key = Object.keys(picArr)[myNumber];
    var key = Object.keys(picArr)[myNumber];


    var div = document.getElementById("mw-head");
    document.getElementsByClassName("mw-logo-icon")[0].src=picArr[key];
    div.style.backgroundImage="linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1)), url('" + picArr[key] + "')";
    document.getElementsByClassName("mw-logo")[0].title="Currently showing the " + key + " flag!";
    div.innerHTML += '<span class="nbweek-banner">Happy <a href="https://nonbinary.wiki/wiki/International_Nonbinary_Day">Nonbinary Awareness Week</a>!<br><span class="nbweek-flag">Currently showing the <a href="https://nonbinary.wiki/wiki/' + key + '">' + key + '</a> flag.</span></span>';

    Latest revision as of 23:19, 23 June 2023

    /* ---- RANDOM PRIDE FLAGS IN THE LOGO ---- */
    var picArr = {"neutrois": "https://nonbinary.wiki/images/thumb/c/c1/Neutrois.png/320px-Neutrois.png",
    "nonbinary": "https://nonbinary.wiki/images/thumb/c/c0/Nonbinary.png/320px-Nonbinary.png",
    "transgender": "https://nonbinary.wiki/images/thumb/c/cd/Transgender.png/320px-Transgender.png",
    "genderqueer": "https://nonbinary.wiki/images/thumb/b/b5/Genderqueer.png/320px-Genderqueer.png",
    "genderfluid": "https://nonbinary.wiki/images/thumb/1/12/Genderfluid.png/320px-Genderfluid.png",
    "genderflux": "https://nonbinary.wiki/images/thumb/a/ae/Genderflux.png/320px-Genderflux.png",
    "agender": "https://nonbinary.wiki/images/thumb/8/83/Agender.png/320px-Agender.png",
    "androgyne": "https://nonbinary.wiki/images/thumb/7/73/Androgyne.png/320px-Androgyne.png",
    "ambonec": "https://nonbinary.wiki/images/thumb/2/2e/Ambonec.png/320px-Ambonec.png",
    "aporagender": "https://nonbinary.wiki/images/thumb/4/48/Aporagender.png/320px-Aporagender.png",
    "bigender": "https://nonbinary.wiki/images/thumb/7/7c/Bigender_by_no-bucks-for-this-doe.png/320px-Bigender_by_no-bucks-for-this-doe.png",
    "deminonbinary": "https://nonbinary.wiki/images/thumb/e/ee/Deminonbinary.png/320px-Deminonbinary.png",
    "graygender": "https://nonbinary.wiki/images/a/a2/Graygender_flag.png",
    "intergender": "https://nonbinary.wiki/images/thumb/d/d3/Intergender.png/320px-Intergender.png",
    "multigender": "https://nonbinary.wiki/images/thumb/3/3b/Multigender.png/320px-Multigender.png",
    "maverique": "https://nonbinary.wiki/images/thumb/e/e2/Maverique.png/320px-Maverique.png",
    "polygender": "https://nonbinary.wiki/images/thumb/8/87/Polygender.png/320px-Polygender.png",
    "trigender": "https://nonbinary.wiki/images/thumb/4/40/Trigender.png/320px-Trigender.png",
    "demiboy": "https://nonbinary.wiki/images/thumb/5/5c/Demiboy.png/320px-Demiboy.png",
    "demigirl": "https://nonbinary.wiki/images/thumb/8/80/Demigirl.png/320px-Demigirl.png",
    "gender neutral": "https://nonbinary.wiki/images/thumb/f/f1/Gender_neutral_2_by_enbygsrd.png/320px-Gender_neutral_2_by_enbygsrd.png",
    "transmasculine": "https://nonbinary.wiki/images/thumb/8/8d/Transmasculine_pride_flag.png/320px-Transmasculine_pride_flag.png",
    "transfeminine": "https://nonbinary.wiki/images/thumb/b/b4/Transfeminine_pride_flag.png/320px-Transfeminine_pride_flag.png",
    "xenogender": "https://nonbinary.wiki/images/thumb/7/7b/Xenogender.png/320px-Xenogender.png",
    "firegender": "https://nonbinary.wiki/images/3/3a/Firegender-1.png",
    "genderfuck": "https://nonbinary.wiki/images/thumb/e/e1/Genderfuck_by_januceit.png/320px-Genderfuck_by_januceit.png",
    "genderfaun": "https://nonbinary.wiki/images/5/52/Genderfaunet.png",
    "genderfaer": "https://nonbinary.wiki/images/2/29/Genderfaer_1.png",
    "nonbinary man": "https://nonbinary.wiki/images/thumb/a/ac/Nonbinary_man_by_bulldykebutch.png/320px-Nonbinary_man_by_bulldykebutch.png",
    "nonbinary woman": "https://nonbinary.wiki/images/thumb/a/a8/Nonbinary_woman_by_bulldykebutch.png/320px-Nonbinary_woman_by_bulldykebutch.png",
    "libramasculine": "https://nonbinary.wiki/images/thumb/f/fb/Libramasculine.png/320px-Libramasculine.png",
    "librafeminine": "https://nonbinary.wiki/images/thumb/a/a8/Librafeminine.png/320px-Librafeminine.png",
    "faesari": "https://nonbinary.wiki/images/thumb/7/70/Faesari.png/320px-Faesari.png"
    };
    
    var myNumber = Math.floor((Math.random() * 33));
    var key = Object.keys(picArr)[myNumber];
    
    document.getElementsByClassName("mw-logo-icon")[0].src=picArr[key];
    document.getElementsByClassName("mw-logo")[0].title="Currently showing the " + key + " flag!";