MediaWiki:Common.js

From Gawler History
Revision as of 16:09, 18 November 2024 by Samwilson (talk | contribs) (Do not show if no About Us found.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */


// Live clock.
( function() {
    const currentTimeLi = document.createElement( 'li' );
    const aboutUs = document.getElementById( 'n-About-Us' );
    if ( aboutUs === null ) {
        return;
    }
    aboutUs.after( currentTimeLi );
    var options = {
        timeZone: "Australia/Adelaide",
        hour12: false,
        hour: 'numeric', minute: 'numeric', second: 'numeric'
    };
    const formatter = new Intl.DateTimeFormat( [], options );
    setInterval( function () {
        currentTimeLi.textContent = 'Gawler time: ' + formatter.format( new Date() );
    }, 1000 );
} )();


// Google Analytics.
mw.loader.load( 'https://www.googletagmanager.com/gtag/js?id=G-GKLZ2KRTE5' );
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-GKLZ2KRTE5');