Jump to content

User:Plighting Engineerd/common.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
mw.loader.load( '/w/index.php?title=User:Evad37/rater.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Evad37/rater.js]]
mw.loader.load( '/w/index.php?title=User:Evad37/duplinks-alt.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Evad37/duplinks-alt.js]]
importScript('User:SD0001/GAN-helper.js'); // Backlink: [[User:SD0001/GAN-helper.js]]
importScript('Wikipedia:AutoEd/complete.js'); // Backlink: [[Wikipedia:AutoEd/complete.js]]

autoEdLinkName = "AutoEd";

// UTC clock with modifications
mw.loader.using(['mediawiki.util', 'mediawiki.api', 'user']).then(function() {

    function padWithZeroes(num) {
        return num < 10 ? '0' + num.toString() : num.toString();
    }

    function showTime($target) {
        var now = new Date();
        var timezone = window.LiveClockTimeZone || 'UTC';
        var hh, mm, ss;
        if (timezone === "UTC") {
            hh = now.getUTCHours();
            mm = now.getUTCMinutes();
            ss = now.getUTCSeconds();
        } else if (timezone === "local") {
            hh = now.getHours();
            mm = now.getMinutes();
            ss = now.getSeconds();
        } else {
            var newNow;
            try {
                newNow = new Date(now.toLocaleString("en-US", { timeZone: timezone }));
                hh = newNow.getHours();
                mm = newNow.getMinutes();
                ss = newNow.getSeconds();
            } catch (err) {
                console.log("LiveClock - error creating Date object with timezone '" + timezone + "': " + err.name);
                timezone = "UTC";
                newNow = now;
                hh = now.getUTCHours();
                mm = now.getUTCMinutes();
                ss = now.getUTCSeconds();
            }
        }
        
        var time = padWithZeroes(hh) + ':' + padWithZeroes(mm);
        $target.text(time);
        
        var ms = now.getUTCMilliseconds();
        setTimeout(function() {
            showTime($target);
        }, 1100 - ms);
    }

    function addLiveClockInstance(clockLocation) {
        var node = document.createElement('span'); // Changed from div to span
        node.id = 'utcdate';
        node.style.cssText = 'font-weight: bold; font-size: 120%; display: inline-block;'; // Ensure it's inline
        var container = document.getElementById(clockLocation);
        if (container) {
            var list = container.querySelector('ul'); // Ensuring it's added to a list if it exists
            if (list) {
                var listItem = document.createElement('li');
                listItem.appendChild(node);
                list.appendChild(listItem); // Adding it as a list item
            } else {
                container.appendChild(node); // Fallback if no list
            }
            showTime($(node));
        }
    }

    function liveClock() {
        var dbName = mw.config.get('wgDBname');
        var showOutsideDropdown = dbName === 'mediawikiwiki' || dbName === 'enwiki';
        var clockLocation = document.getElementById('p-vector-user-menu-overflow') && showOutsideDropdown ? 'p-vector-user-menu-overflow' : 'p-personal';
        addLiveClockInstance(clockLocation);
        addLiveClockInstance('p-personal-sticky-header');
    }

    $(liveClock);
});

// Cite RCDB
$('head').one('reftoolbarbase', function() {
new citeTemplate('Cite RCDB', 'Cite RCDB',
[ // Basic fields
{"field": "coaster_name", "label":"Coaster name"},
{"field": "location", "label":"Location"}, 
{"field": "rcdb_number", "label":"RCDB number"},
{"field": "accessdate", "label":"Access date"},
{"field": "url", "label":"URL"}
],
[ // Expanded fields
]);
});
importScript('User:Polygnotus/DuplicateReferences.js'); // Backlink: [[User:Polygnotus/DuplicateReferences.js]]
importScript('User:Mesidast/Tidy citations.js'); // Backlink: [[User:Mesidast/Tidy citations.js]]
importScript('User:Nardog/RefRenamer.js'); // Backlink: [[User:Nardog/RefRenamer.js]]
importScript('User:Ohconfucius/script/Sources.js'); // Backlink: [[User:Ohconfucius/script/Sources.js]]