MediaWiki:Gadget-CastSwitch.js

Revision as of 16:56, 18 February 2021 by Vish (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.
// English Cast Button
$(function() {
   $('.mw-englishButton').html($('<a>', {
       'class': 'mw-ui-button',
       text: 'English'
   })).click(function() {
       window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#ENG";
    }
)});

// Japanese Cast Button
$(function() {
   $('.mw-japaneseButton').html($('<a>', {
       'class': 'mw-ui-button',
       text: 'Japanese'
   })).click(function() {
       window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#JPN";
    }
)});

// French Cast Button
$(function() {
   $('.mw-frenchButton').html($('<a>', {
       'class': 'mw-ui-button',
       text: 'French'
   })).click(function() {
       window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#FR";
    }
)});

// Spanish Cast (Spain) Button
$(function() {
   $('.mw-spanishButton').html($('<a>', {
       'class': 'mw-ui-button',
       text: 'Spanish (European)'
   })).click(function() {
       window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#SPA";
    }
)});

// Spanish Cast (Latin America) Button
$(function() {
   $('.mw-spanishLatinButton').html($('<a>', {
       'class': 'mw-ui-button',
       text: 'Spanish (Latin American)'
   })).click(function() {
       window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#LA";
    }
)});

// Italian Cast Button
$(function() {
   $('.mw-italianButton').html($('<a>', {
       'class': 'mw-ui-button',
       text: 'Italian'
   })).click(function() {
       window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#ITA";
    }
)});

// German Cast Button
$(function() {
   $('.mw-germanButton').html($('<a>', {
       'class': 'mw-ui-button',
       text: 'German'
   })).click(function() {
       window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#DE";
    }
)});

// Portuguese Cast Button
$(function() {
   $('.mw-portugueseButton').html($('<a>', {
       'class': 'mw-ui-button',
       text: 'Portuguese'
   })).click(function() {
       window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#PT";
    }
)});

// Thai Cast Button
$(function() {
   $('.mw-thaiButton').html($('<a>', {
       'class': 'mw-ui-button',
       text: 'Thai'
   })).click(function() {
       window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#TH";
    }
)});