×
Create a new article
Write your page title here:
We currently have 30 articles on Ghost Machine Wiki. Type your article name above or create one of the articles listed here!



    Ghost Machine Wiki

    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.
    /**
     * Quick Delete
     * Deletes all the pages in a specific category
     *
     * @author: [[w:User:Fubuki風吹]]
     */
    (function ($, mw) {
        'use strict';
        var config = mw.config.get([
            'wgServer',
            'wgScriptPath',
            'wgNamespaceNumber',
            'wgTitle',
            'wgUserGroups'
        ]),
        edittoken = mw.user.tokens.values.editToken,
        category = window.category || window.categories,
        deletionDelay = window.quickDeleteDelay || 500;
    
        if (
            window.QuickDeleteLoaded ||
            [14].indexOf(config.wgNamespaceNumber) === -1 ||
            !/sysop|content-moderator|content-volunteer|vstf|staff|helper|wiki-manager|content-team-member/.test(config.wgUserGroups.join())
        ) {
         //   return;
        }
        window.QuickDeleteLoaded = true;
     
        if (
            typeof category === 'undefined' || 
            category.indexOf(config.wgTitle) !== -1
        ) {
            $('#mw-page-header-links').append(
                $('<a>', {
                    class: 'wds-is-squished wds-button wds-is-secondary deleteAll',
                    title: 'Delete all pages in this category',
                    text: 'Delete All'
                })
            );
        }
        $( '.deleteAll').click( checkDeletion );
     
        function checkDeletion () {
            $.showCustomModal( 'Reason for deletion', 'All pages including files in this category will be deleted with the reason being:' + '<input style="border:1px solid #aaa;-moz-border-radius:4px;border-radius:4px;padding:2px;width:250px" type="text" id="wpDelReason"><hr>' + 'Make sure to check if all the pages and files need to be deleted!', {
                id: 'deleteModal',
                width: 650,
                buttons: [ {
                    defaultButton: true,
                    message: 'Delete',
                    handler: function () {
                        deleteAll();
                    }
                }, {
                    message: 'Cancel',
                    handler: function () {
                        cancelDeletion();
                    }
                } ]
            } );
        }
     
        function deleteAll () {
            cancelDeletion();
            var delItems = [];
            var deleteURL;
            var counter = 0;
            $( '#mw-pages .mw-content-ltr li' ).each( function () {
                delItems.push( $( this ).text() );
            } );
            $( '.gallery .gallerytext > a' ).each( function () {
                delItems.push( $( this ).attr( 'title' ).replace( / /g, '_' ) );
            } );
            var reason = $( '#wpDelReason' ).val() || window.reason || 'Marked for deletion';
            if ( delItems.length > 0 ) {
                var deletionInterval = setInterval(function () {
                    if (counter === delItems.length) {
                        clearInterval(deletionInterval);
                    } else {
                        deleteURL = config.wgServer + config.wgScriptPath + '/api.php?action=delete&title=' + encodeURIComponent( delItems[ counter ] ) + '&token=' + encodeURIComponent( edittoken ) + '&reason=' + encodeURIComponent( reason );
                        $.post( deleteURL );
                        counter++;
                    }
                }, deletionDelay);
     
                $.showCustomModal( 'Deleted', 'All pages and files in this category have been deleted.', {
                    id: 'deleted',
                    width: 450,
                    buttons: [ {
                        defaultButton: true,
                        id: 'refresh',
                        message: 'Refresh',
                        handler: function () {
                            window.location.reload();
                        }
                    } ]
                } );
            } else if ( delItems.length === 0 ) {
                $.showCustomModal( 'No items found', 'No pages or files found in this category.', {
                    id: 'no-delItems',
                    width: 450,
                    buttons: [ {
                        defaultButton: true,
                        message: 'OK',
                        handler: function () {
                            $( '#no-delItems' ).closeModal();
                        }
                    } ]
                } );
            }
        }
     
        function cancelDeletion () {
            $( '#deleteModal' ).closeModal();
        }
    } ) ( jQuery, mediaWiki );
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.