MediaWiki:Gadget-NamespaceNotice.js

From Wikimedia Foundation Governance Wiki
Revision as of 01:52, 16 July 2012 by MZMcBride (talk | contribs) (hmm)

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.
/* Show a notice inside <div id="contentSub"></div> on pages in the Talk namespace */
if ( ( mw.config.get( 'wgNamespaceNumber' ) == 1 ) &&
     ( mw.config.get( 'wgAction') == 'view' ) &&
     ( mw.config.get( 'wgUserName' ) == null ) ) {
  var text = $.getJSON(
        wgScriptPath + '/api.php?',
        {
            action: 'parse',
            prop: 'text',
            page: 'Template:Contribute',
            format: 'json'
        },
        function( data ) {
            if ( data ) {
                var text = data.parse.text['*'];
                $('#contentSub').html(text).css({'margin':'1em 0', 'color':'#000'});
            }
        }
  )
}