MediaWiki:Common.js

    From UNITApedia
    Revision as of 07:03, 12 May 2025 by Horia Modran (talk | contribs)

    Note: After publishing, you may have to bypass your browser's cache to see the changes.

    • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
    • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
    • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
    • Opera: Press Ctrl-F5.
    mw.loader.using('mediawiki.util', function () {
      $(function(){
        // Get the list of categories assigned to this page
        var cats = mw.config.get('wgCategories') || [];
        // Specify the category you want to target
        var targetCat = 'InternationalizationForms';
    
        // Only proceed if the page is in that category
        if ( cats.indexOf(targetCat) !== -1 ) {
          // Create and style the button-like link
          $('<a>')
            .text('📄 Export this page to PDF')
            .attr('href','#')
            .css({
              display:'inline-block',
              padding:'0.5em 1em',
              background:'#007bff',
              color:'#fff',
              'border-radius':'4px',
              margin:'0.5em',
              'text-decoration':'none'
            })
            .click(function(e){
              e.preventDefault();
              window.print();
            })
            // Insert it above the content area
            .prependTo('#content');
        }
      });
    });