<commit_before>function PicoAdmin(authToken, baseUrl)
{
    this.authToken = <PASSWORD>Token;
    this.baseUrl = baseUrl;

    this.modules = {};

    this.activeModule = 'landing';
    this.activePath = null;

    this.currentState = null;
    this.latestState = null;

    this.notifications = [];
    this.askFileNameModal = null;
}

utils.createClass(PicoAdmin, function () {
    this.prototype.init = function ()
    {
        this.initNotification();
        this.initLoading();
        this.initHistory();
    };

    this.prototype.registerModule = function (moduleName, instance)
    {
        this.modules[moduleName] = instance;
    };

    this.prototype.selectModule = function (activeModule, activePath, intermediateCallback)
    {
        var landingPage = document.getElementById('landing'),
            oldModule = this.activeModule ? this.modules[this.activeModule] : null,
            oldModulePage = oldModule ? document.getElementById('module-' + oldModule.moduleName) : landingPage,
            newModule = activeModule ? this.modules[activeModule] : null,
            newModulePage = newModule ? document.getElementById('module-' + newModule.moduleName) : landingPage;

        // disable old module
        if (oldModule && (!newModule || (oldModule.moduleName !== newModule.moduleName))) {
            oldModule.disable();
        }

        // call intermediate callback
        if (intermediateCallback) {
            intermediateCallback(oldModule, newModule);
        }

        // cross-fade old and new module page
        if (oldModulePage && newModulePage && !utils.isElementVisible(newModulePage)) {
            try {
                utils.crossFade(oldModulePage, newModulePage);
            } catch (e) {}
        }

        // enable new module
        if (newModule) {
            if (!oldModule || (oldModule.moduleName !== newModule.moduleName)) {
                newModule.enable();
            }

            // actually select module and path
            this.activeModule = newModule.moduleName;
            this.selectPath(activePath);
        } else {
            this.activeModule = null;
            this.activePath = null;
        }
    };

    this.prototype.selectPath = function (path)
    {
        this.activePath = path || null;

        var module = this.modules[this.activeModule];
        if (module) {
            module.selectPath(path);
        }
    };

    this.prototype.initHistory = function ()
    {
        var self = this;

        // restore old page states when navigating back/forward
        // without the need of reloading the page
        window.addEventListener('popstate', function (event) {
            if (self.currentState === self.latestState) {
                // navigating away from latest page; update history object
                // TODO: open question: is this (explicitly added) limitation really favored?
                self.updateHistory({ url: self.getHistoryObject(self.currentState).url });
            }

            if (event.state && event.state.PicoAdmin) {
                self.restoreHistory(event.state.PicoAdmin);<commit_msg>JavaScript: Give the modules some time to construct/destruct before fading their contents<commit_after>function PicoAdmin(authToken, baseUrl)
{
    this.authToken = <PASSWORD>Token;
    this.baseUrl = baseUrl;

    this.modules = {};

    this.activeModule = 'landing';
    this.activePath = null;

    this.currentState = null;
    this.latestState = null;

    this.notifications = [];
    this.askFileNameModal = null;
}

utils.createClass(PicoAdmin, function () {
    this.prototype.init = function ()
    {
        this.initNotification();
        this.initLoading();
        this.initHistory();
    };

    this.prototype.registerModule = function (moduleName, instance)
    {
        this.modules[moduleName] = instance;
    };

    this.prototype.selectModule = function (activeModule, activePath, intermediateCallback)
    {
        var landingPage = document.getElementById('landing'),
            oldModule = this.activeModule ? this.modules[this.activeModule] : null,
            oldModulePage = oldModule ? document.getElementById('module-' + oldModule.moduleName) : landingPage,
            newModule = activeModule ? this.modules[activeModule] : null,
            newModulePage = newModule ? document.getElementById('module-' + newModule.moduleName) : landingPage;

        // disable old module
        if (oldModule && (!newModule || (oldModule.moduleName !== newModule.moduleName))) {
            oldModule.disable();
        }

        // call intermediate callback
        if (intermediateCallback) {
            intermediateCallback(oldModule, newModule);
        }

        // enable new module
        if (newModule) {
            if (!oldModule || (oldModule.moduleName !== newModule.moduleName)) {
                newModule.enable();
            }

            // actually select module and path
            this.activeModule = newModule.moduleName;
            this.selectPath(activePath);
        } else {
            this.activeModule = null;
            this.activePath = null;
        }

        // cross-fade old and new module page
        if (oldModulePage && newModulePage) {
            window.requestAnimationFrame(function () {
                try {
                    utils.crossFade(oldModulePage, newModulePage);
                } catch (e) {}
            });
        }
    };

    this.prototype.selectPath = function (path)
    {
        this.activePath = path || null;

        var module = this.modules[this.activeModule];
        if (module) {
            module.selectPath(path);
        }
    };

    this.prototype.initHistory = function ()
    {
        var self = this;

        // restore old page states when navigating back/forward
        // without the need of reloading the page
        window.addEventListener('popstate', function (event) {
            if (self.currentState === self.latestState) {
                // navigating away from latest page; update history object
                // TODO: open question: is this (explicitly added) limitation really favored?
                self.updateHistory({ url: self.getHistoryObject(self.currentState).url });
            }

            if (event.state && event.state.PicoAdmin) {
                self.restoreHistory(event.state.PicoAdmin);
{'fraction_non_alphanumeric': 0.10569233181746902, 'fraction_numerical': 0.0, 'mean_word_length': 2.1310751104565537, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1331537', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1595, 'n_words': 358}