MediaWiki:Common.js: Difference between revisions

From Lost Waves Wiki
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 27: Line 27:
     }
     }


    var player;
var player;


// Load the appropriate modules in ResourceLoader
// Load the appropriate modules in ResourceLoader
mw.loader.using( 'mwe_player_0_placeholder' ).then( function () {
mw.loader.using( 'ext.tmh.videojs-ogvjs' ).then( function () {
     // Load ogvjs if necessary; when this promise resolves,
     // Load ogvjs if necessary; when this promise resolves,
     // all necessary code has been loaded
     // all necessary code has been loaded
     return mw.OgvJsSupport.loadIfNeeded();
     return mw.OgvJsSupport.loadIfNeeded();
} ).then( function () {
} ).then( function () {
     player = videojs( 'my-player-id', {
     player = videojs( 'mwe_player_0_placeholder', {
         controls: false,
         controls: true,
         autoplay: false,
         autoplay: false,
         poster: 'https://path/to/my/image',
         poster: 'https://path/to/my/image',

Revision as of 20:05, 11 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.');
        });
    }

var player;

// Load the appropriate modules in ResourceLoader
mw.loader.using( 'ext.tmh.videojs-ogvjs' ).then( function () {
    // Load ogvjs if necessary; when this promise resolves,
    // all necessary code has been loaded
    return mw.OgvJsSupport.loadIfNeeded();
} ).then( function () {
    player = videojs( 'mwe_player_0_placeholder', {
        controls: true,
        autoplay: false,
        poster: 'https://path/to/my/image',
        sources: [ /* array of sources */ ],
        
        // Ogv.js-specific configuration
        ogvjs: {
            base: mw.OgvJsSupport.basePath()
        }
    } );
} );

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