Difference between revisions of "MediaWiki:Common.js"

From CompetenceBase
(Created page with " $(document).ready(function() { // Listen for language changes from the ULS $(document).on('languagechange', function() { // Remove the 'uselang' parameter fro...")
 
(Blanked the page)
Tag: Blanking
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
  
$(document).ready(function() {
 
    // Listen for language changes from the ULS
 
    $(document).on('languagechange', function() {
 
        // Remove the 'uselang' parameter from the URL
 
        var url = new URL(window.location.href);
 
        url.searchParams.delete('uselang');
 
 
        // Use the History API to update the URL without reloading
 
        window.history.replaceState({}, '', url.toString());
 
    });
 
 
    // Trigger language change when the ULS triggers a language switch
 
    mw.hook('uls.language.change').add(function() {
 
        // Manually trigger the language change event
 
        $(document).trigger('languagechange');
 
    });
 
});
 

Latest revision as of 11:34, 5 August 2024


Wikidata