|
|
| Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */ | | /* Site JS — loaded on every page (MediaWiki:Common.js). */ |
|
| |
|
| // Discord link | | /* SEO fixes (Lighthouse "meta description" + "image alt"). Citizen renders |
| $(document).ready(function() {
| | og:description but not <meta name="description">, and MediaWiki renders inline |
| var discordElement = $(`
| | images with no alt attribute, so we backfill both client-side. */ |
| <div class="g-discord citizen-header__item citizen-dropdown" style="display: flex; justify-content: center; align-items: center;">
| | ( function () { |
| <a href="https://discord.gg/gscripts" target="_blank">
| | // 1. Mirror og:description into a real meta description if missing. |
| <img src="https://wiki.gscripts.co/images/4/4b/Discord_30_30.png" alt="Discord" width="30" height="30">
| | if ( !document.querySelector( 'meta[name="description"]' ) ) { |
| </a>
| | var og = document.querySelector( 'meta[property="og:description"]' ); |
| </div>
| | if ( og && og.content ) { |
| `);
| | var m = document.createElement( 'meta' ); |
| $(".citizen-header .citizen-header__logo").after(discordElement);
| | m.setAttribute( 'name', 'description' ); |
| }); | | m.setAttribute( 'content', og.content ); |
| | document.head.appendChild( m ); |
| | } |
| | } |
|
| |
|
| /* $(document).ready(function() { | | // 2. Give every image an alt attribute if it lacks one, derived from the |
| var $sections = $('.accordion-section');
| | // wrapping link's title (page/script name) or the file name. |
| | | document.querySelectorAll( 'img:not([alt])' ).forEach( function ( img ) { |
| // Initialize: disable links in all headers by default (since all start collapsed)
| | var link = img.closest( 'a' ); |
| $sections.find('.accordion-header a').css('pointer-events', 'none');
| | var alt = ( link && link.getAttribute( 'title' ) ) || ''; |
| | | if ( !alt ) { |
| // Handle header clicks
| | var src = img.getAttribute( 'src' ) || ''; |
| $('.accordion-header').on('click', function(e) {
| | alt = decodeURIComponent( src.split( '/' ).pop() || '' ) |
| var $section = $(this).closest('.accordion-section');
| | .replace( /^\d+px-/, '' ) |
| var $content = $section.find('.accordion-content');
| | .replace( /\.[a-z0-9]+$/i, '' ) |
| var isHidden = $content.is(':hidden');
| | .replace( /[_-]+/g, ' ' ) |
| | | .trim(); |
| if (isHidden) {
| | } |
| // Collapse all other sections
| | img.setAttribute( 'alt', alt ); |
| $sections.not($section).find('.accordion-content').slideUp(200);
| | } ); |
| $sections.not($section).removeClass('expanded');
| | }() ); |
| $sections.not($section).find('.accordion-header a').css('pointer-events', 'none');
| |
| | |
| // Expand this section
| |
| $content.slideDown(200);
| |
| $section.addClass('expanded');
| |
| $section.find('.accordion-header a').css('pointer-events', 'auto');
| |
| } else {
| |
| // Collapse this section
| |
| $content.slideUp(200);
| |
| $section.removeClass('expanded');
| |
| $section.find('.accordion-header a').css('pointer-events', 'none');
| |
| }
| |
| | |
| // Prevent link click if content is hidden
| |
| if (e.target.tagName === 'A' && $content.is(':hidden')) {
| |
| e.preventDefault();
| |
| }
| |
| });
| |
| }); */ | |
| | |
| // Load Citizen.js if using Citizen skin
| |
| if (mw.config.get('skin') === 'citizen') {
| |
| mw.loader.load('/index.php?title=MediaWiki:Citizen.js&action=raw&ctype=text/javascript');
| |
| }
| |