MediaWiki:Common.js

From Gawler History
Revision as of 16:25, 11 November 2024 by Samwilson (talk | contribs)
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. */

var currenttime = 'February 06, 2019 11:22:19' //PHP method of getting server date

var options = {
    timeZone: "Australia/Adelaide",
    hour12: false,
    hour: 'numeric', minute: 'numeric', second: 'numeric'
};

var formatter = new Intl.DateTimeFormat([], options);

var UTCTime = "2017-09-03T02:00:00Z";
var localTime = formatter.format(new Date());
var currentTime = formatter.format(new Date());

var gawlertime = new Date().toLocaleString("en-AU", {timeZone: "Australia/Adelaide"});
gawlertime = new Date(gawlertime);

function displaytime() {
    const currentTimeLi = document.createElement( 'li' );
    currentTimeLi.text = formatter.format( new Date() );
    console.log(currentTimeLi);
    document.getElementById( 'n-About-Us' ).after( currentTimeLi );
}

window.addEventListener( 'load', function() {
    console.log('loaded');
    window.setInterval( displaytime, 1000 );
} );

// Google Analytics.
//mw.loader.load( '/index.php?title=MediaWiki:GTAG.js&action=raw&ctype=text/javascript' );
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');