From Wikipedia, the free encyclopedia
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.

$( function() {

    // 10 is "Template:" and 828 is "Module:"

    if ( ( mw.config.get( "wgNamespaceNumber" ) === 10 || mw.config.get( "wgNamespaceNumber" ) === 828 ) && mw.config.get( "wgPageName" ).includes( "/sandbox" ) ) {

        var link = mw.util.addPortletLink(

            "p-cactions",

            "#",

            "Sync with main",

            "ca-sync",

            "Overwrite the sandbox code with the code from the main template"

        );

        mw.loader.using( "mediawiki.api", function () {

            link.addEventListener( "click", function () {

                var api = new mw.Api();

                api.get( {

                    prop: 'revisions',

                    rvprop: 'content',

                    rvlimit: 1,

                    titles: mw.config.get( "wgPageName" ).replace( "/sandbox", "" )

                } ).done( function ( data ) {

                    if ( !data.query || !data.query.pages ) return;

                    var pageid = Object.getOwnPropertyNames( data.query.pages )[0],

                        text = data.query.pagespageid].revisions0]["*"];

                    api.postWithEditToken( {

                        action: "edit",

                        title: mw.config.get( "wgPageName" ),

                        summary: "Syncing sandbox code with main template ([[User:APerson/sync-template-sandbox|sync-template-sandbox.js]])",

                        text: text

                    } ).done ( function ( data ) {

                        if ( data && data. && data..result && data..result == 'Success' ) {

                            mw.notify( "Synced successfully! Reloading in 5 seconds..." );

                            window.setTimeout( function () {

                                document.location.reload( true );

                            }, 5000 );

                        }

                    } );

                } );

            } );

        } );

    }

} );
From Wikipedia, the free encyclopedia
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.

$( function() {

    // 10 is "Template:" and 828 is "Module:"

    if ( ( mw.config.get( "wgNamespaceNumber" ) === 10 || mw.config.get( "wgNamespaceNumber" ) === 828 ) && mw.config.get( "wgPageName" ).includes( "/sandbox" ) ) {

        var link = mw.util.addPortletLink(

            "p-cactions",

            "#",

            "Sync with main",

            "ca-sync",

            "Overwrite the sandbox code with the code from the main template"

        );

        mw.loader.using( "mediawiki.api", function () {

            link.addEventListener( "click", function () {

                var api = new mw.Api();

                api.get( {

                    prop: 'revisions',

                    rvprop: 'content',

                    rvlimit: 1,

                    titles: mw.config.get( "wgPageName" ).replace( "/sandbox", "" )

                } ).done( function ( data ) {

                    if ( !data.query || !data.query.pages ) return;

                    var pageid = Object.getOwnPropertyNames( data.query.pages )[0],

                        text = data.query.pagespageid].revisions0]["*"];

                    api.postWithEditToken( {

                        action: "edit",

                        title: mw.config.get( "wgPageName" ),

                        summary: "Syncing sandbox code with main template ([[User:APerson/sync-template-sandbox|sync-template-sandbox.js]])",

                        text: text

                    } ).done ( function ( data ) {

                        if ( data && data. && data..result && data..result == 'Success' ) {

                            mw.notify( "Synced successfully! Reloading in 5 seconds..." );

                            window.setTimeout( function () {

                                document.location.reload( true );

                            }, 5000 );

                        }

                    } );

                } );

            } );

        } );

    }

} );

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook