summaryrefslogtreecommitdiff
path: root/assets/js/src/Router.js
blob: 0c96262cbcb907eca588a4fdc92f666c49ef63d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function Router() {
    this.routes = {};
}

Router.prototype.addRoute = function(id, controller) {
    this.routes[id] = controller;
};

Router.prototype.dispatch = function(app) {
    for (var id in this.routes) {
        if (document.getElementById(id)) {
            var controller = Object.create(this.routes[id].prototype);
            this.routes[id].apply(controller, [app]);
            controller.execute();
            break;
        }
    }
};

jQuery(document).ready(function() {
    var app = new App();
    var router = new Router();
    router.addRoute('board', Board);
    router.addRoute('calendar', Calendar);
    router.addRoute('screenshot-zone', Screenshot);
    router.addRoute('analytic-task-repartition', TaskRepartitionChart);
    router.addRoute('analytic-user-repartition', UserRepartitionChart);
    router.addRoute('analytic-cfd', CumulativeFlowDiagram);
    router.addRoute('analytic-burndown', BurndownChart);
    router.addRoute('analytic-avg-time-column', AvgTimeColumnChart);
    router.addRoute('analytic-task-time-column', TaskTimeColumnChart);
    router.addRoute('analytic-lead-cycle-time', LeadCycleTimeChart);
    router.addRoute('gantt-chart', Gantt);
    router.dispatch(app);
    app.listen();
});