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: Adiutor options
 */
/* <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 api = new mw.Api();
    var prdSendMessageToCreator = localStorage.getItem("prdSendMessageToCreator") == "true";

    function AdiutorOptionsDialog(config) {
        AdiutorOptionsDialog.super.call(this, config);
    }
    OO.inheritClass(AdiutorOptionsDialog, OO.ui.ProcessDialog);
    AdiutorOptionsDialog.static.name = 'AdiutorOptionsDialog';
    AdiutorOptionsDialog.static.title = 'Adiutor - Options';
    AdiutorOptionsDialog.static.actions = [{
        action: 'save',
        label: 'Update',
        flags: ['primary', 'progressive']
    }, {
        label: 'Cancel',
        flags: 'safe'
    }];
    AdiutorOptionsDialog.prototype.initialize = function() {
        AdiutorOptionsDialog.super.prototype.initialize.apply(this, arguments);
        this.content = new OO.ui.PanelLayout({
            padded: true,
            expanded: false
        });
        AdiutorSettings = new OO.ui.FieldsetLayout({
            label: 'Settings',
        });
        AdiutorSettings.addItems([
            csdSendMessageToCreator = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                selected: localStorage.getItem("csdSendMessageToCreator") == "true"
            }), {
                align: 'inline',
                label: 'Notify the creator of the page which nominated for speedy deletion.',
                help: 'Explanation'
            }),
            /*afdSendMessageToCreator = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                selected: localStorage.getItem("afdSendMessageToCreator") == "true"
            }), {
                align: 'inline',
                label: 'Notify the creator of the page which nominated for deletion.',
                help: 'Explanation'
            }),*/
            prdSendMessageToCreator = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                selected: localStorage.getItem("prdSendMessageToCreator") == "true"
            }), {
                align: 'inline',
                label: 'Notify the user who created the page which proposed for deletion.',
                help: 'Explanation'
            }),
            csdLogNominatedPages = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                selected: localStorage.getItem("csdLogNominatedPages") == "true"
            }), {
                align: 'inline',
                label: 'Log speedy deletion requests',
                help: 'Explanation'
            }),
            csdLogPageName = new OO.ui.FieldLayout(new OO.ui.TextInputWidget({
                value: localStorage.getItem("csdLogPageName"),
            }), {
                label: 'Name of CSD Logs',
                help: 'Explanation'
            }),
            /*afdLogNominatedPages = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                selected: localStorage.getItem("afdLogNominatedPages") == "true"
            }), {
                align: 'inline',
                label: 'Keep a log of pages which I have nominated for deletion',
                help: 'Explanation'
            }),
            afdLogPageName = new OO.ui.FieldLayout(new OO.ui.TextInputWidget({
                value: localStorage.getItem("afdLogPageName")
            }), {
                label: 'Name of AFD Logs',
                help: 'Explanation'
            }),*/
            prdLogNominatedPages = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                selected: localStorage.getItem("prdLogNominatedPages") == "true"
            }), {
                align: 'inline',
                label: 'Keep a log of pages that I proposed for deletion.',
                help: 'Explanation'
            }),
            prdLogPageName = new OO.ui.FieldLayout(new OO.ui.TextInputWidget({
                value: localStorage.getItem("prdLogPageName"),
            }), {
                label: 'Name of PROD Logs',
                help: 'Explanation'
            }),
            /*
            afdNominateOpinionsLog = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                selected: localStorage.getItem("afdNominateOpinionsLog") == "true"
            }), {
                align: 'inline',
                label: 'Log my AFD comments',
                help: 'Explanation'
            }),
            afdOpinionLogPageName = new OO.ui.FieldLayout(new OO.ui.TextInputWidget({
                value: localStorage.getItem("afdOpinionLogPageName"),
            }), {
                label: 'Name of AFD comments log',
                help: 'Explanation'
            }),*/
            showMyStatus = new OO.ui.FieldLayout(new OO.ui.CheckboxInputWidget({
                selected: localStorage.getItem("showMyStatus") == "true"
            }), {
                align: 'inline',
                label: 'Show users activity status',
                help: 'When this option is activated, you can see the activity status on the user pages.'
            }),
        ]);
        this.content.$element.append(AdiutorSettings.$element);
        this.$body.append(this.content.$element);
    };
    AdiutorOptionsDialog.prototype.getActionProcess = function(action) {
        var dialog = this;
        if (action) {
            return new OO.ui.Process(function() {
                UpdatedOptions = JSON.stringify([{
                    "name": "csdSendMessageToCreator",
                    "value": csdSendMessageToCreator.fieldWidget.selected
                }, {
                    "name": "csdLogNominatedPages",
                    "value": csdLogNominatedPages.fieldWidget.selected
                }, {
                    "name": "csdLogPageName",
                    "value": csdLogPageName.fieldWidget.value
                }, {
                    "name": "afdSendMessageToCreator",
                    "value": afdSendMessageToCreator.fieldWidget.selected
                }, {
                    "name": "afdLogNominatedPages",
                    "value": afdLogNominatedPages.fieldWidget.selected
                }, {
                    "name": "afdLogPageName",
                    "value": afdLogPageName.fieldWidget.value
                }, {
                    "name": "prdSendMessageToCreator",
                    "value": prdSendMessageToCreator.fieldWidget.selected
                }, {
                    "name": "prdLogNominatedPages",
                    "value": prdLogNominatedPages.fieldWidget.selected
                }, {
                    "name": "prdLogPageName",
                    "value": prdLogPageName.fieldWidget.value
                }, {
                    "name": "afdNominateOpinionsLog",
                    "value": afdNominateOpinionsLog.fieldWidget.selected
                }, {
                    "name": "afdOpinionLogPageName",
                    "value": afdOpinionLogPageName.fieldWidget.value
                }, {
                    "name": "showMyStatus",
                    "value": showMyStatus.fieldWidget.selected
                }, {
                    "name": "MyStatus",
                    "value": "active"
                }]);
                updateOptions(UpdatedOptions);
                dialog.close({
                    action: action
                });
            });
        }
        return AdiutorOptionsDialog.super.prototype.getActionProcess.call(this, action);
    };
    var windowManager = new OO.ui.WindowManager();
    $(document.body).append(windowManager.$element);
    var dialog = new AdiutorOptionsDialog();
    windowManager.addWindows([dialog]);
    windowManager.openWindow(dialog);

    function updateOptions(UpdatedOptions) {
        api.postWithToken('csrf', {
            action: 'edit',
            title: 'User:' + mwConfig.wgUserName + '/Adiutor-options.js',
            text: UpdatedOptions,
            //tags: 'Adiutor',
            summary: '[[WP:Adiutor|Adiutor]] user settings has been updated',
            format: 'json'
        }).done(function() {
            var Notification = new OO.ui.MessageWidget({
                type: 'success',
                label: 'Your Adiutor setting has been updated successfully.',
                classes: ['afd-helper-notification'],
                showClose: true
            });
            $('.mw-page-container-inner').append(Notification.$element);
            setTimeout(function() {
                $(".afd-helper-notification").hide('blind', {}, 500);
            }, 5000);
        });
    }
});
/* </nowiki> */