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.
/* 
 * Adiutor: A gadget to assist various user actions
 * Author: Vikipolimer
 * Translation: Kadı
 * Licencing and attribution: [[WP:Adiutor#Licencing and attribution]]
 * Module: Creating speedy deletion requests
/* <nowiki> */
$.when(mw.loader.using(["mediawiki.user", "oojs-ui-core", "oojs-ui-windows", ]), $.ready).then(function() {
    var mwConfig = mw.config.get(["wgAction", "wgPageName", "wgTitle", "wgUserGroups", "wgUserName", "wgCanonicalNamespace", "wgNamespaceNumber"]);
    var revDelCount = 0;
    var CopVioURL;
    var api = new mw.Api();
    api.get({
        action: 'query',
        list: 'logevents',
        leaction: 'delete/delete',
        letprop: 'delete',
        letitle: mwConfig.wgPageName
    }).done(function(data) {
        if (data.query.logevents) {
            revDelCount = data.query.logevents.length;
        } else {
            revDelCount = 0;
        }
        var csdSendMessageToCreator = localStorage.getItem("csdSendMessageToCreator") == "true";
        // Example: A process dialog that uses an action set with modes.
        // Subclass ProcessDialog.
        function ProcessDialog(config) {
            ProcessDialog.super.call(this, config);
        }
        OO.inheritClass(ProcessDialog, OO.ui.ProcessDialog);
        // Specify a name for .addWindows()
        ProcessDialog.static.name = 'myDialog';
        // Specify a title and an action set that uses modes ('edit' and 'help' mode, in this example).
        ProcessDialog.static.title = 'Adiutor (Beta) - Create Speedy Deletion';
        ProcessDialog.static.actions = [{
            action: 'continue',
            modes: 'edit',
            label: 'Mark',
            flags: ['primary', 'progressive']
        }, {
            action: 'help',
            modes: 'edit',
            label: 'Help'
        }, {
            modes: 'edit',
            label: 'Cancel',
            flags: ['safe', 'close']
        }, {
            action: 'back',
            modes: 'help',
            label: 'Back',
            flags: ['safe', 'back']
        }];
        // Customize the initialize() method to add content and set up event handlers. 
        // This example uses a stack layout with two panels: one displayed for 
        // edit mode and one for help mode.
        ProcessDialog.prototype.initialize = function() {
            ProcessDialog.super.prototype.initialize.apply(this, arguments);
            switch (mwConfig.wgNamespaceNumber) {
                case 0:
                    NameSpaceDeletionReasons = new OO.ui.FieldsetLayout({
                        label: 'Article'
                    });
                    NameSpaceDeletionReasons.addItems([
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'A1',
                            data: '[[WP:CSD#A1|A1]]: No context',
                            selected: false
                        }), {
                            label: 'A1 - No context.',
                            align: 'inline',
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'A2',
                            data: '[[WP:CSD#A2|A2]]: Article in a foreign language that exists on another project',
                            selected: false
                        }), {
                            label: 'A2 -  Foreign language articles that exist on another Wikimedia project',
                            align: 'inline',
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'A3',
                            data: '[[WP:CSD#A3]]: No content',
                            selected: false
                        }), {
                            label: 'A3 - No content',
                            align: 'inline',
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'A5',
                            data: '[[WP:CSD#A5]]: Transwikied articles',
                            selected: false
                        }), {
                            label: 'A5 - Transwikied articles',
                            align: 'inline',
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'A7',
                            data: '[[WP:CSD#A7]]: No indication of importance (people, animals, organizations, web content, events)',
                            selected: false
                        }), {
                            label: 'A7 - No indication of importance (people, animals, organizations, web content, events)',
                            align: 'inline',
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'A9',
                            data: '[[WP:CSD#A9]]: No indication of importance (musical recordings)',
                            selected: false
                        }), {
                            label: 'A9 - No indication of importance (musical recordings)',
                            align: 'inline',
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'A10',
                            data: '[[WP:CSD#A10]]: Recently created article that duplicates an existing topic',
                            selected: false
                        }), {
                            label: 'A10 - Recently created article that duplicates an existing topic',
                            align: 'inline',
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'A11',
                            data: '[[WP:CSD#A11]]: Obviously invented',
                            selected: false
                        }), {
                            label: 'A11 - Obviously invented',
                            align: 'inline'
                        }),
                    ]);
                    break;
                case 6:
                    NameSpaceDeletionReasons = new OO.ui.FieldsetLayout({
                        label: 'Files'
                    });
                    NameSpaceDeletionReasons.addItems([
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F1',
                            data: '[[WP:CSD#F1|F1]]: Redundant',
                            selected: false
                        }), {
                            label: 'F1 - Redundant',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F2',
                            data: '[[WP:CSD#F2|F2]]: Corrupt, missing or empty file',
                            selected: false
                        }), {
                            label: 'F2 - Corrupt, missing or empty file',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F3',
                            data: '[[WP:CSD#F3|File 3]]: Improper license',
                            selected: false
                        }), {
                            label: 'F3 - Improper license',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F4',
                            data: '[[WP:CSD#F4|File 4]]: Lack of licensing information',
                            selected: false
                        }), {
                            label: 'F4 - Lack of licensing information',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F5',
                            data: '[[WP:CSD#F5|File 5]]: Orphaned non-free use images',
                            selected: false
                        }), {
                            label: 'F5 - Orphaned non-free use images',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F6',
                            data: '[[WP:CSD#F6|File 6]]: Missing non-free use rationale',
                            selected: false
                        }), {
                            label: 'F6 - Missing non-free use rationale',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F7',
                            data: '[[WP:CSD#F7|File 7]]: Invalid fair-use claim',
                            selected: false
                        }), {
                            label: 'F7 - Invalid fair-use claim',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F8',
                            data: '[[WP:CSD#F8|File 8]]: Images available as identical copies on Wikimedia Commons',
                            selected: false
                        }), {
                            label: 'F8 - Images available as identical copies on Wikimedia Commons',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F9',
                            data: '[[WP:CSD#F9|File 9]]: Unambiguous copyright infringement',
                            selected: false
                        }), {
                            label: 'F9 - Unambiguous copyright infringement',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F10',
                            data: '[[WP:CSD#F10|File 10]]: Useless non-media files',
                            selected: false
                        }), {
                            label: 'F10 -  Useless non-media files',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'F11',
                            data: '[[WP:CSD#F11|File 11]]: No evidence of permission',
                            selected: false
                        }), {
                            label: 'F11 -  No evidence of permission',
                            align: 'inline'
                        }),
                    ]);
                    break;
                case 14:
                    NameSpaceDeletionReasons = new OO.ui.FieldsetLayout({
                        label: 'Categories'
                    });
                    NameSpaceDeletionReasons.addItems([
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'C1',
                            data: '[[WP:CSD#C1|C1]]: Empty category',
                            selected: false
                        }), {
                            label: 'C1 - Empty category',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'C2',
                            data: '[[WP:CSD#C2|C2]]: Speedy renaming',
                            selected: false
                        }), {
                            label: 'C2 - Speedy renaming',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'G8',
                            data: '[[WP:CSD#G8|G8]]: Populated by deleted or retargeted template',
                            selected: false
                        }), {
                            label: 'G8 - Populated by deleted or retargeted template',
                            align: 'inline'
                        }),
                    ]);
                    break;
                case 2:
                case 3:
                    NameSpaceDeletionReasons = new OO.ui.FieldsetLayout({
                        label: 'User Pages'
                    });
                    NameSpaceDeletionReasons.addItems([
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'U1',
                            data: '[[WP:CSD#U1|U1]]: User request to delete page in own userspace',
                            selected: false
                        }), {
                            label: 'U1 - User request to delete page in own userspace',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'U2',
                            data: '[[WP:CSD#U2|U2]]: Userpage or subpage of a nonexistent user',
                            selected: false
                        }), {
                            label: 'U2 - Userpage or subpage of a nonexistent user',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'U3',
                            data: '[[WP:CSD#U3|U3]]: [[WP:NFC|Non-free]] [[Help:Gallery|gallery]]',
                            selected: false
                        }), {
                            label: 'U3 - Non-free gallery',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'U5',
                            data: '[[WP:CSD#U5|U5]]: [[WP:NOTWEBHOST|Misuse of Wikipedia as a web host]]',
                            selected: false
                        }), {
                            label: 'U5 - Misuse of Wikipedia as a web host',
                            align: 'inline'
                        }),
                    ]);
                    break;
                case 10:
                    NameSpaceDeletionReasons = new OO.ui.FieldsetLayout({
                        label: 'Templates'
                    });
                    NameSpaceDeletionReasons.addItems([
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'T1',
                            data: '[[WP:CSD#T1|Template 1]]: Divisive and inflammatory templates',
                            selected: false
                        }), {
                            label: 'T1 - BDivisive and inflammatory templates',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'T2',
                            data: '[[WP:CSD#T2|Template 2]]: Misrepresentation of policy',
                            selected: false
                        }), {
                            label: 'T2 - Misrepresentation of policy',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'T3',
                            data: '[[WP:CSD#T3|Template 3]]: Duplication and hardcoded instances',
                            selected: false
                        }), {
                            label: 'T3 - Duplication and hardcoded instances',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'T4',
                            data: '[[WP:CSD#T4|Template 4]]: Subpages of non-existent pages',
                            selected: false
                        }), {
                            label: 'T4 - Subpages of non-existent pages',
                            align: 'inline'
                        }),
                    ]);
                    break;
                case 100:
                    NameSpaceDeletionReasons = new OO.ui.FieldsetLayout({
                        label: 'Portals'
                    });
                    NameSpaceDeletionReasons.addItems([
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'P1',
                            data: '[[WP:CSD#P1]]: Any portal that would be subject to speedy deletion as an article',
                            selected: false
                        }), {
                            label: 'P1 - Portal page that does not meet the article criteria',
                            align: 'inline'
                        }),
                        new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                            value: 'P2',
                            data: '[[WP:CSD#P2]]: Underpopulated [[WP:P|portal]]',
                            selected: false
                        }), {
                            label: 'P2 - Underpopulated portal',
                            align: 'inline'
                        }),
                    ]);
                    break;
                default:
                    NameSpaceDeletionReasons = new OO.ui.FieldsetLayout({});
                    NameSpaceDeletionReasons.addItems([
                        new OO.ui.FieldLayout(new OO.ui.MessageWidget({
                            type: 'warning',
                            inline: true,
                            label: new OO.ui.HtmlSnippet('<strong>There is no speedy delete rationale for this namespace.</strong><br><small>please select one of the general rationales on the right.</small><br><hr><br>')
                        })),
                    ]);
                    break;
            }
            GeneralReasons = new OO.ui.FieldsetLayout({
                label: 'General reasons'
            });
            GeneralReasons.addItems([
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G1',
                    data: '[[WP:CSD#G1|G1]]: [[WP:PN|Patent nonsense]], meaningless, or incomprehensible',
                    selected: false
                }), {
                    label: 'G1 -  Patent nonsense',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G2',
                    data: '[[WP:CSD#G2|G2]]: Test page',
                    selected: false
                }), {
                    label: 'G2 - Test page',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G3',
                    data: '[[WP:CSD#G3|G3]]: [[WP:Vandalism|Vandalism]]',
                    selected: false
                }), {
                    label: 'G3 - Pure vandalism',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G3',
                    data: '[[WP:CSD#G3|G3]]: Blatant [[WP:Do not create hoaxes|hoax]]',
                    selected: false
                }), {
                    label: 'G3 - Blatant hoax',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G4',
                    data: '[[WP:CSD#G4|G4]]: Recreation of a page that was [[WP:DEL|deleted]] per a [[WP:XFD|deletion discussion]]',
                    selected: false
                }), {
                    label: 'G4 - Recreation of material deleted via a deletion discussion',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G5',
                    data: '[[WP:CSD#G5|G5]]: Creation by a [[WP:BLOCK|blocked]] or [[WP:BAN|banned]] user in violation of block or ban',
                    selected: false
                }), {
                    label: 'G5 - Created by a banned or blocked user',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G6',
                    data: '[[WP:CSD#G6|G6]]: Housekeeping and routine (non-controversial) cleanup',
                    selected: false
                }), {
                    label: 'G6 - Cleanup',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G7',
                    data: '[[WP:CSD#G7|G7]]: One author who has requested deletion',
                    selected: false
                }), {
                    label: 'G7 - Author requests deletion, or author blanked',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G8',
                    data: '[[WP:CSD#G8|G8]]: Page dependent on a deleted or nonexistent page',
                    selected: false
                }), {
                    label: 'G8 - Pages dependent on a non-existent or deleted page',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'attack',
                    data: '[[[WP:CSD#G10|G10]]: [[WP:ATP|Attack page]] or negative unsourced [[WP:BLP|BLP]]',
                    selected: false
                }), {
                    label: 'G10 - Attack page',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'negublp',
                    data: '[[WP:CSD#G10|G10]]: [[WP:ATP|Attack page]] or negative unsourced [[WP:BLP|BLP]]',
                    selected: false
                }), {
                    label: 'G10 - Wholly negative, unsourced BLP',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G11',
                    data: '[[WP:CSD#G11|G11]]: Unambiguous [[WP:NOTADVERTISING|advertising]] or promotion',
                    selected: false
                }), {
                    label: 'G11 - Unambiguous advertising or promotion',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G12',
                    data: '[[WP:CSD#G12|G12]]: Unambiguous [[WP:CV|copyright infringement]]',
                    selected: false
                }), {
                    label: 'G12 - Unambiguous copyright infringement',
                    align: 'inline',
                }),
                copyVioField = new OO.ui.FieldLayout(copyVioInput = new OO.ui.TextInputWidget({
                    placeholder: 'Violated URL',
                    value: '',
                    data: 'COV',
                    classes: ['adiutor-copvio-input'],
                }), {
                    label: 'URL',
                    align: 'inline',
                    classes: ['adiutor-copvio-container'],
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G13',
                    data: '[[WP:CSD#G13|G13]]: Abandoned draft or [[WP:AFC|Articles for Creation]] submission – to retrieve it, see [[WP:REFUND/G13]]',
                    selected: false
                }), {
                    label: 'G13 - Abandoned draft',
                    align: 'inline',
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    value: 'G14',
                    data: '[[WP:CSD#G14|G14]]: Unnecessary disambiguation page',
                    selected: false
                }), {
                    label: 'G14 - Unnecessary disambiguation page',
                    align: 'inline',
                }),
            ]);
            copyVioField.$element.hide();
            copyVioInput.$element.hide();
            isCopyVio = false;
            GeneralReasons.$element.on('click', function(item) {
                if (item.target.value === 'G12') {
                    copyVioField.$element.show();
                    copyVioInput.$element.show();
                }
            });
            //copyVioInput.on('change', function() {
            //    console.log(copyVioInput.value);
            //});
            DeletionOptions = new OO.ui.FieldsetLayout({
                label: 'Other Options'
            });
            DeletionOptions.addItems([
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    selected: false,
                    value: 'recreationProrection'
                }), {
                    label: 'Add Protection for Re-creation',
                    align: 'inline'
                }),
                new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                    selected: csdSendMessageToCreator,
                    value: 'informCreator'
                }), {
                    label: 'Notify Initial Contributor',
                    align: 'inline'
                })
            ]);
            HeaderBar = new OO.ui.MessageWidget({
                type: 'notice',
                inline: true,
                label: new OO.ui.HtmlSnippet('<strong>Choose criteria for speedy deletion</strong><br><small>Please choose one of the criteria below as a reason for deleting this page.</small>')
            });
            var left_panel = new OO.ui.PanelLayout({
                $content: [NameSpaceDeletionReasons.$element, DeletionOptions.$element],
                classes: ['one'],
                scrollable: false,
            });
            var right_panel = new OO.ui.PanelLayout({
                $content: GeneralReasons.$element,
                classes: ['two'],
                scrollable: false,
            });
            var stack = new OO.ui.StackLayout({
                items: [left_panel, right_panel],
                continuous: true,
                classes: ['adiutor-csd-modal-container']
            });
            this.panel1 = new OO.ui.PanelLayout({
                padded: true,
                expanded: false
            });
            if (revDelCount >= "1") {
                HeaderBarRevDel = new OO.ui.MessageWidget({
                    type: 'warning',
                    label: new OO.ui.HtmlSnippet('This page has been deleted ' + revDelCount + ' times before! (<a href="/w/index.php?title=Special:Log&page=' + mwConfig.wgPageName + '&type=delete">Log</a>)')
                });
                this.panel1.$element.append(HeaderBar.$element, '<hr><br>', HeaderBarRevDel.$element, '<br>', stack.$element);
            } else {
                this.panel1.$element.append(HeaderBar.$element, '<hr><br>', stack.$element);
            }
            this.panel2 = new OO.ui.PanelLayout({
                padded: true,
                expanded: false
            });
            this.panel2.$element.append('<p><strong>Adiutor</strong>, It is a gadget developed to provide convenience to users in various operations. You can provide all your feedback, including bug reports and feature suggestions, on its talk page.</p><h2>Licensing and attribution</h2><p>Firstly published at,\ https://tr.wikipedia.org/wiki/MediaWiki:Gadget-Adiutor.js Licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License (CC BY-SA 3.0) https://creativecommons.org/licenses/by-sa/3.0/ and GNU Free Documentation License (GFDL) http://www.gnu.org/copyleft/fdl.html.</p>');
            this.stackLayout = new OO.ui.StackLayout({
                items: [this.panel1, this.panel2]
            });
            this.$body.append(this.stackLayout.$element);
        };
        // Set up the initial mode of the window ('edit', in this example.)  
        ProcessDialog.prototype.getSetupProcess = function(data) {
            return ProcessDialog.super.prototype.getSetupProcess.call(this, data).next(function() {
                this.actions.setMode('edit');
            }, this);
        };
        // Use the getActionProcess() method to set the modes and displayed item.
        ProcessDialog.prototype.getActionProcess = function(action) {
            if (action === 'help') {
                // Set the mode to help.
                this.actions.setMode('help');
                // Show the help panel.
                this.stackLayout.setItem(this.panel2);
            } else if (action === 'back') {
                // Set the mode to edit.
                this.actions.setMode('edit');
                // Show the edit panel.
                this.stackLayout.setItem(this.panel1);
            } else if (action === 'continue') {
                var dialog = this;
                return new OO.ui.Process(function() {
                    var CSDReason;
                    var CSDSummary;
                    var CSDReasons = [];
                    var CSDOptions = [];
                    NameSpaceDeletionReasons.items.forEach(function(Reason) {
                        if (Reason.fieldWidget.selected) {
                            CSDReasons.push({
                                value: Reason.fieldWidget.value,
                                data: Reason.fieldWidget.data,
                                selected: Reason.fieldWidget.selected
                            });
                        }
                    });
                    GeneralReasons.items.forEach(function(Reason) {
                        if (Reason.fieldWidget.selected) {
                            CSDReasons.push({
                                value: Reason.fieldWidget.value,
                                data: Reason.fieldWidget.data,
                                selected: Reason.fieldWidget.selected
                            });
                        }
                    });
                    var SaltCSDSummary = '';
                    if (copyVioInput.value != "") {
                        CopVioURL = '|url=' + copyVioInput.value;
                    } else {
                        CopVioURL = "";
                    }
                    if (CSDReasons.length > 1) {
                        var SaltCSDReason = '{{sil|';
                        var i = 0;
                        var keys = Object.keys(CSDReasons);
                        for (i = 0; i < keys.length; i++) {
                            if (i > 0) SaltCSDReason += (i < keys.length - 1) ? ', ' : ' ve ';
                            SaltCSDReason += '[[WP:CSD#' + CSDReasons[keys[i]].value + ']]';
                        }
                        for (i = 0; i < keys.length; i++) {
                            if (i > 0) SaltCSDSummary += (i < keys.length - 1) ? ', ' : ' ve ';
                            SaltCSDSummary += '[[WP:CSD#' + CSDReasons[keys[i]].value + ']]';
                        }
                        CSDReason = SaltCSDReason + CopVioURL + '}}';
                        CSDSummary = 'XXXX ' + SaltCSDSummary + ' YYYY Multiple.';
                    } else {
                        CSDReason = '{{Db-' + CSDReasons[0].value.toLowerCase() + '}}';
                        CSDSummary = 'Speedy deletion requested for page, the reason: ' + CSDReasons[0].data + '.';
                        SaltCSDSummary = CSDReasons[0].data;
                    }
                    //Invoke the adding template function
                    DeletionOptions.items.forEach(function(Option) {
                        if (Option.fieldWidget.selected) {
                            CSDOptions.push({
                                value: Option.fieldWidget.value,
                                selected: Option.fieldWidget.selected
                            });
                        }
                    });
                    CSDOptions.forEach(function(Option) {
                        if (Option.value === "recreationProrection") {
                            CSDReason = CSDReason + "\n" + '{{Salt}}';
                        }
                        if (Option.value === "informCreator") {
                            getCreator().then(function(data) {
                                var Author = data.query.pages[mw.config.get('wgArticleId')].revisions[0].user;
                                if (!mw.util.isIPAddress(Author)) {
                                    var message = '{{subst:db-reason-notice|' + mwConfig.wgPageName.replace(/_/g, " ") + '|' + SaltCSDSummary + '}}';
                                    sendMessageToAuthor(Author, message);
                                }
                            });
                        }
                    });
                    putCSDTemplate(CSDReason, CSDSummary);
                    showProgress();
                    dialog.close();
                });
            }
            return ProcessDialog.super.prototype.getActionProcess.call(this, action);
        };
        // Get dialog height.
        ProcessDialog.prototype.getBodyHeight = function() {
            return this.panel1.$element.outerHeight(true);
        };
        // Create and append the window manager.
        var windowManager = new OO.ui.WindowManager();
        $(document.body).append(windowManager.$element);
        // Create a new dialog window.
        var processDialog = new ProcessDialog({
            size: 'larger'
        });
        // Add windows to window manager using the addWindows() method.
        windowManager.addWindows([processDialog]);
        // Open the window.
        windowManager.openWindow(processDialog);

        function putCSDTemplate(CSDReason, CSDSummary) {
            api.postWithToken('csrf', {
                action: 'edit',
                title: mwConfig.wgPageName,
                prependtext: CSDReason + "\n",
                summary: CSDSummary,
                //tags: 'Adiutor',
                format: 'json'
            }).done(function() {
                location.reload();
            });
        }

        function getCreator() {
            return api.get({
                action: 'query',
                prop: 'revisions',
                rvlimit: 1,
                rvprop: ['user'],
                rvdir: 'newer',
                titles: mwConfig.wgPageName
            });
        }

        function sendMessageToAuthor(Author, message) {
            api.postWithToken('csrf', {
                action: 'edit',
                title: 'User_talk:' + Author,
                appendtext: '\n' + message,
                summary: 'Speedy deletion requested for page ' + '[[' + mwConfig.wgPageName.replace(/_/g, " ") + ']]',
                //tags: 'Adiutor',
                format: 'json'
            }).done(function() {});
        }

        function showProgress() {
            var processStartedDialog = new OO.ui.MessageDialog();
            var progressBar = new OO.ui.ProgressBarWidget();
            var windowManager = new OO.ui.WindowManager();
            $(document.body).append(windowManager.$element);
            windowManager.addWindows([processStartedDialog]);
            windowManager.openWindow(processStartedDialog, {
                title: 'The request is in progress',
                message: progressBar.$element
            });
        }
    });
});
/* </nowiki> */