Namespaces
Variants
Actions

MediaWiki:Common.js

From cppreference.com

Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences
/* Any JavaScript here will be loaded for all users on every page load. */
 
// Replace GeSHi-generated placeholder links with the real thing
// Update [[Template:cpp/placeholder message]] 
// and [[Template:cpp/is placeholder]] when adding to this list
 
var placeholder_configs = [
    { 
      pattern: 'experimental/ranges',
      placeholder: 'cpp/ranges-placeholder',
      matched: 'cpp/experimental/ranges',
      unmatched: 'cpp'
    },
    { 
      pattern: 'experimental/ranges',
      placeholder: 'cpp/ranges-functional-placeholder',
      matched: 'cpp/experimental/ranges/functional',
      unmatched: 'cpp/utility/functional/ranges'
    },
    { 
      pattern: 'experimental/ranges',
      placeholder: 'cpp/ranges-algorithm-placeholder',
      matched: 'cpp/experimental/ranges/algorithm',
      unmatched: 'cpp/algorithm/ranges'
    },
    { 
      pattern: 'experimental/ranges',
      placeholder: 'cpp/ranges-utility-placeholder',
      matched: 'cpp/experimental/ranges/utility',
      unmatched: 'cpp/utility/ranges'
    },
    { 
      pattern: 'experimental/ranges',
      placeholder: 'cpp/ranges-iterator-placeholder',
      matched: 'cpp/experimental/ranges/iterator',
      unmatched: 'cpp/iterator/ranges'
    },
    { 
      pattern: 'experimental/ranges',
      placeholder: 'cpp/ranges-dangling-placeholder',
      matched: 'cpp/experimental/ranges/iterator',
      unmatched: 'cpp/ranges'
    },
    { 
      pattern: 'experimental/ranges',
      placeholder: 'cpp/ranges-ranges-placeholder',
      matched: 'cpp/experimental/ranges/range',
      unmatched: 'cpp/ranges'
    }
];
 
$.each(placeholder_configs, function(i, cf) {
    if(mw.config.get('wgTitle').includes(cf.pattern)){
        $(function() {
            $('a[href*="' + cf.placeholder + '"]').each(function() {
                this.href = this.href.replace(cf.placeholder, cf.matched);
            });
        });
    }
    else {
        $(function() {
            $('a[href*="' + cf.placeholder + '"]').each(function() { 
                this.href = this.href.replace(cf.placeholder, cf.unmatched);
            });
        });
    }
});