ui.js
/**
     * Reconstruct the UI based on the current section (stored in the URL).
    */
Reconstruct the UI based on the current section (stored in the URL).
Reconstruct the UI based on the current section ( stored in the URL ) .
reconstruct() {
        this.listPage = 1;
        this.listOrder = "id";
        this.listDesc = true;
        var section = this.section();
        if (!this.order) { 
            if (!section.length) section = this.defaultPath;
            var modules = Object.keys(ui.modules);
            if (!modules.includes(section[0])) {
                section = this.defaultPath;
                this.onInvalidURL();
            } else {
                for (var i = 2; i < section.length; i = i + 2) {
                    if (!modules.includes(section[i])) {
                        section = this.defaultPath;
                        this.onInvalidURL();
                        break;
                    }
                }
            }
            this.replaceSection([section[0]]);
            if (section.length > 1) {
                this.pushSection([section[1]]);
                for (var i = 2; i < section.length; i = i + 2) {
                    this.pushSection([section[i], section[i + 1]]);
                }
            }
            if (this.activeClass) {
                document.getElementById(this.defaultPath[0]).classList.remove(this.activeClass);
                document.getElementById(section[0]).classList.add(this.activeClass);
            }
            this.onSection();
        }
        this.main = this.modules[section[0]];
        this.main.submodules = [];
        this.loadSubmodules(section[0]);
        if (this.searchInput) document.getElementById("searchInput").value = null;
        document.getElementById("grid").innerHTML = "";
        this.main.submodules.forEach((n) => { 
            let element = document.createElement("div");
            element.id = this.modules[n].grid;
            document.getElementById("grid").appendChild(element);
        });
        if (section.length > 1) {
            for (var i = 0; i < section.length; i = i + 2) {
                if (this.isSee(section[i + 1])) {
                    this.modules[section[i]].class().see(section[i + 1]);
                } else {
                    this.modules[section[i]].class().add();
                }
            }
            this.show(section[section.length - 2]);
            if (this.isSee(section[section.length - 1])) {
                this.modules[section[i - 2]].onSee();
            } else {
                this.modules[section[i - 2]].onAdd();
            }
        } else {
            this.main.class().list(this.listPage, this.listOrder, this.listDesc);
            this.show(section[0]);
            this.modules[section[0]].onList();
        }
    }
reconstruct ( ) { this . listPage = 1 ; this . listOrder = "id" ; this . listDesc = true ; var section = this . section ( ) ; if ( ! this . order ) { if ( ! section . length ) section = this . defaultPath ; var modules = Object . keys ( ui . modules ) ; if ( ! modules . includes ( section [ 0 ] ) ) { section = this . defaultPath ; this . onInvalidURL ( ) ; } else { for ( var i = 2 ; i < section . length ; i = i + 2 ) { if ( ! modules . includes ( section [ i ] ) ) { section = this . defaultPath ; this . onInvalidURL ( ) ; break ; } } } this . replaceSection ( [ section [ 0 ] ] ) ; if ( section . length > 1 ) { this . pushSection ( [ section [ 1 ] ] ) ; for ( var i = 2 ; i < section . length ; i = i + 2 ) { this . pushSection ( [ section [ i ] , section [ i + 1 ] ] ) ; } } if ( this . activeClass ) { document . getElementById ( this . defaultPath [ 0 ] ) . classList . remove ( this . activeClass ) ; document . getElementById ( section [ 0 ] ) . classList . add ( this . activeClass ) ; } this . onSection ( ) ; } this . main = this . modules [ section [ 0 ] ] ; this . main . submodules = [ ] ; this . loadSubmodules ( section [ 0 ] ) ; if ( this . searchInput ) document . getElementById ( "searchInput" ) . value = null ; document . getElementById ( "grid" ) . innerHTML = "" ; this . main . submodules . forEach ( ( n ) => { let element = document . createElement ( "div" ) ; element . id = this . modules [ n ] . grid ; document . getElementById ( "grid" ) . appendChild ( element ) ; } ) ; if ( section . length > 1 ) { for ( var i = 0 ; i < section . length ; i = i + 2 ) { if ( this . isSee ( section [ i + 1 ] ) ) { this . modules [ section [ i ] ] . class ( ) . see ( section [ i + 1 ] ) ; } else { this . modules [ section [ i ] ] . class ( ) . add ( ) ; } } this . show ( section [ section . length - 2 ] ) ; if ( this . isSee ( section [ section . length - 1 ] ) ) { this . modules [ section [ i - 2 ] ] . onSee ( ) ; } else { this . modules [ section [ i - 2 ] ] . onAdd ( ) ; } } else { this . main . class ( ) . list ( this . listPage , this . listOrder , this . listDesc ) ; this . show ( section [ 0 ] ) ; this . modules [ section [ 0 ] ] . onList ( ) ; } }
Reconstruct the UI based on the current section (stored in the URL).
Reconstruct the UI based on the current section ( stored in the URL ) .
// Application is loading for the first time // Verify that the url is correct, if not replace with default one and call onInvalidURL // Load all the submodules (nested dependencies) to have a simple list // Clean stuff and create each module's viewport //create viewport (div) for each submodule // Call each module to display stuff 