MediaWiki:Uniwiki.js

MediaWiki interface page
Revision as of 09:58, 8 January 2021 by imported>76561198018895007 (Created page with "→‎Any JavaScript here will be loaded for users using the UniWiki skin: const countDownDate = 'January 21 2021 05:00:00 GMT+0000'; function getTimeRemaining...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.
/* Any JavaScript here will be loaded for users using the UniWiki skin */
        const countDownDate = 'January 21 2021 05:00:00 GMT+0000';

        function getTimeRemaining(endtime) {
            const total = Date.parse(endtime) - Date.parse(new Date());
            const seconds = Math.floor((total / 1000) % 60);
            const minutes = Math.floor((total / 1000 / 60) % 60);
            const hours = Math.floor((total / (1000 * 60 * 60)) % 24);
            const days = Math.floor(total / (1000 * 60 * 60 * 24));
            return {total, days, hours,  minutes, seconds };
        }

        function initializeClock(id, endtime) {
            const clock = document.getElementById(id);
            const timeinterval = setInterval(() => {
                const t = getTimeRemaining(endtime);
                clock.innerHTML = t.days + "d " + t.hours + "h " + t.minutes + "m " + t.seconds + "s ";
                if (t.total <= 0) {
                    clearInterval(timeinterval);
                }
            }, 1000);
        }

        initializeClock('launch_timer', countDownDate);
🍪 We use cookies to keep session information to provide you a better experience.