_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:Jeeputer/specialRandomPage.js

In today's world, User:Jeeputer/specialRandomPage.js has become a topic of great relevance and debate. With the advancement of technology and globalization, User:Jeeputer/specialRandomPage.js has taken an unexpected role, generating conflicting opinions and diverse positions. There is no doubt that User:Jeeputer/specialRandomPage.js has impacted different aspects of society, from politics to the economy, including culture and daily life. In this article, we will explore the various facets of User:Jeeputer/specialRandomPage.js and discuss its influence today, as well as its possible implications in the future. Through an interdisciplinary approach, we will approach User:Jeeputer/specialRandomPage.js from multiple perspectives with the goal of better understanding its scope and meaning in contemporary society.
/**
 * Finds a random page in a selected namespace with preferred options
**/
mw.loader.using(, function() {
    var namespaces = [{
        name: 'All',
        ns: '0|6|10|14|118|828'
    }, {
        name: '(Article)',
        ns: 0
    }, {
        name: 'File',
        ns: 6
    }, {
        name: 'Template',
        ns: 10
    }, {
        name: 'Category',
        ns: 14
    }, {
        name: 'Draft',
        ns: 118
    }, {
        name: 'Module',
        ns: 828
    }];

    var SPRPFieldSet = new OO.ui.FieldsetLayout({
        align: 'inline'
    });

    var dropDown = new OO.ui.DropdownWidget({
        menu: {
            items: namespaces.map(function(item) {
                return new OO.ui.MenuOptionWidget({
                    data: item.ns,
                    label: item.name
                });
            })
        }
    });
    dropDown.getMenu().selectItemByLabel(window.SPRPpreferredNamespace || 'All');

    var redirect = new OO.ui.ToggleButtonWidget({
        icon: 'articleRedirect',
        title: 'Random redirect',
        value: window.SPRPActivateRedirect || false
    }),
        edit = new OO.ui.ToggleButtonWidget({
            icon: 'edit',
            title: 'Open the edit form',
            value: window.SPRPAlwaysEdit || false
        }),
        links = new OO.ui.ToggleButtonWidget({
            icon: 'link',
            title: 'See what links to the page',
            value: window.SPRPActivateWLH || false
        });
    options = new OO.ui.ButtonGroupWidget({
        items: 
    });

    SPRPFieldSet.addItems([
        new OO.ui.FieldLayout(dropDown, {
            align: 'top'
        }),
        new OO.ui.FieldLayout(options, {
            align: 'top'
        })
    ]);

    function SPRPProcessDialog(config) {
        SPRPProcessDialog.super.call(this, config);
    }
    OO.inheritClass(SPRPProcessDialog, OO.ui.ProcessDialog);

    SPRPProcessDialog.static.name = 'SPRPDialog';
    SPRPProcessDialog.static.title = 'Random page';
    SPRPProcessDialog.static.actions = [{
        action: 'save',
        label: 'Go',
        flags: 'primary'
    }, {
        label: 'Cancel',
        flags: 'safe'
    }];

    SPRPProcessDialog.prototype.initialize = function() {
        SPRPProcessDialog.super.prototype.initialize.apply(this, arguments);
        this.content = new OO.ui.PanelLayout({
            padded: true,
            expanded: false
        });
        this.content.$element.append(SPRPFieldSet.$element);
        this.$body.append(this.content.$element);
    };
    SPRPProcessDialog.prototype.getActionProcess = function(action) {
        var dialog = this;
        if (action) {
            mw.notify('Finding a random page...');
            var actionParam, WLH = false,
                redir = false;
            if (redirect.getValue()) {
                redir = true;
            }
            if (links.getValue()) {
                WLH = true;
                actionParam = 'view';
            } else {
                actionParam = edit.getValue() ? 'edit' : 'view';
            }
            return new OO.ui.Process(function() {
                var ns = dropDown.getMenu().findSelectedItem();
                var r = redir ? 'redirects' : 'nonredirects';
                new mw.Api().get({
                    action: 'query',
                    format: 'json',
                    list: 'random',
                    rnlimit: '1',
                    rnnamespace: ns.data,
                    rnfilterredir: r
                }).done(function(data) {
                    var title = data.query.random.title;
                    var url = mw.config.get('wgServer');
                    if (WLH) {
                        url += mw.util.getUrl('Special:WhatLinksHere/' + title);
                    } else {
                        url += mw.util.getUrl(title, {
                            redirect: redir ? 'no' : 'yes',
                            action: actionParam
                        })
                        if (actionParam == 'edit') {
                            url += '#editform'
                        }
                    }
                    window.location.href = url;
                });
                dialog.close({
                    action: action
                });
            });
        }
        return SPRPProcessDialog.super.prototype.getActionProcess.call(this, action);
    };

    var windowManager = new OO.ui.WindowManager();
    $(mw.util.addPortletLink('p-cactions', '#', 'Random Page', 'ca-sprp', 'Go to a random page in a selected namespace', window.SPRPAccesskey || 'z')).on('click', function(e) {
        e.preventDefault();
        $(document.body).append(windowManager.$element);
        var dialog = new SPRPProcessDialog();
        windowManager.addWindows();
        windowManager.openWindow(dialog);
    });
});