summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/lib/Router.js
blob: d06c07a33459412222f5e921ca18c62cda8fb9c4 (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
var Router = View.extend({

	route: function(){

		this.originalPath = window.location.pathname
		
		var path = window.location.pathname.split("/")
		// console.log(path)
		for (var route in this.routes) {
			var routePath = route.split("/")
			if (routePath[1] == path[1]) {
				if (routePath[2] && routePath[2].indexOf(":") !== -1 && path[2] && (path[3] === routePath[3]) ) {
					this[this.routes[route]](null, path[2])
					break;
				}
				else if (routePath[2] == path[2]) {
					this[this.routes[route]](null)
					break;
				}
				else if (! routePath[2] && (! path[2].length || ! path[2])) {
					this[this.routes[route]](null)
					break;
				}
			}
		}
	}

})