MediaWiki:Common.js: Difference between revisions

From Lost Waves Wiki
No edit summary
No edit summary
Line 30: Line 30:
         var elem = $(".mw-tmh-player");
         var elem = $(".mw-tmh-player");
         elem.find(".mw-tmh-play").on('click', function (e){
         elem.find(".mw-tmh-play").on('click', function (e){
            console.log("start");
             if(elem.width() <= 100)
             if(elem.width() <= 100)
             {
             {
                console.log("start");
                 elem.find(".js-volume-panel").hide();
                 elem.find(".js-volume-panel").hide();
             }
             }

Revision as of 22:52, 10 May 2024

/* Any JavaScript here will be loaded for all users on every page load. */

mw.loader.using(['mediawiki.api']).then(function () {
    function addToDMZ() {
        var api = new mw.Api();
        api.postWithToken('csrf', {
            action: 'edit',
            title: 'DMZ:Users',
            appendtext: '\n* ' + mw.config.get('wgUserName'),  // Append the current user's name
            summary: 'User self-added to DMZ'
        }).done(function (response) {
            if (response.edit && response.edit.result === 'Success') {
                alert('You have been added to the DMZ.');
                // Notify administrators
                api.postWithToken('csrf', {
                    action: 'edit',
                    title: 'User_talk:Admin',
                    appendtext: '\n* ' + mw.config.get('wgUserName') + ' added themselves to the DMZ.',
                    summary: 'Notifying admins of DMZ addition'
                });
            } else {
                alert('Error: Unable to add to DMZ.');
            }
        }).fail(function () {
            alert('Error contacting the API.');
        });
    }

    $(document).ready(function(){
         var elem = $(".mw-tmh-player");
         elem.find(".mw-tmh-play").on('click', function (e){
             if(elem.width() <= 100)
             {
                 console.log("start");
                 elem.find(".js-volume-panel").hide();
             }
         });
    });

    $(document).on('click', '.addToDMZLink', function (e) {
        e.preventDefault();
        addToDMZ();
    });
});