client/js/router.js
author rougeronj
Tue, 15 Sep 2015 12:24:58 +0200
changeset 521 0d9b3f1b97e7
parent 510 a8f02d66bf02
permissions -rw-r--r--
Create new view id the current one isn't in the project or if it's the first one (so we let the first one always unchanged) Otherwise modify the current one
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
471
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     1
(function(root) {
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     2
    "use strict";
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     3
    
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     4
    var Backbone = root.Backbone;
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     5
    
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     6
    var Router = root.Rkns.Router = Backbone.Router.extend({
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     7
        routes: {
473
6649d2d75a87 update router
rougeronj
parents: 471
diff changeset
     8
            '': 'index'
471
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     9
        },
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    10
        
473
6649d2d75a87 update router
rougeronj
parents: 471
diff changeset
    11
        index: function (parameters) {
471
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    12
            
473
6649d2d75a87 update router
rougeronj
parents: 471
diff changeset
    13
            var result = {};
510
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    14
            if (parameters !== null){
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    15
                parameters.split("&").forEach(function(part) {
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    16
                    var item = part.split("=");
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    17
                    result[item[0]] = decodeURIComponent(item[1]);
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    18
                });
473
6649d2d75a87 update router
rougeronj
parents: 471
diff changeset
    19
            }
510
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    20
            this.trigger('router', result);        
471
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    21
        }  
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    22
    });
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    23
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    24
})(window);