line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This file is generated by author/assets.pl. Do not edit manually. |
2
|
|
|
|
|
|
|
package Amon2::Setup::Asset::MicroDispatcherJS; |
3
|
1
|
|
|
1
|
|
366
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
112
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub tags { |
7
|
1
|
|
|
1
|
0
|
5
|
<<',,,'; |
8
|
|
|
|
|
|
|
<script src="<: uri_for('/static/js/micro_dispatcher.js') :>"></script> |
9
|
|
|
|
|
|
|
,,, |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub files { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
0
|
|
'js/micro_dispatcher.js' => '// micro_dispatcher.js - (C) tokuhirom, MIT License. |
15
|
|
|
|
|
|
|
(function() { |
16
|
|
|
|
|
|
|
var namedParam = /:([\\w\\d]+)/g; |
17
|
|
|
|
|
|
|
var splatParam = /\\*([\\w\\d]+)/g; |
18
|
|
|
|
|
|
|
var escapeRegExp = /[\\-\\[\\]{}()+?.,\\\\\\^$|#\\s]/g; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
// http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/ |
21
|
|
|
|
|
|
|
var toString = Object.prototype.toString; |
22
|
|
|
|
|
|
|
function isRegExp(obj) { |
23
|
|
|
|
|
|
|
return toString.call(obj)==\'[object RegExp]\'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
function Dispatcher() { |
27
|
|
|
|
|
|
|
this.routes = []; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
Dispatcher.prototype = { |
30
|
|
|
|
|
|
|
register: function(route, callback) { |
31
|
|
|
|
|
|
|
if (!isRegExp(route)) { |
32
|
|
|
|
|
|
|
route = this._compileRoute(route); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
this.routes.push([route, callback]); |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
dispatch: function (path) { |
37
|
|
|
|
|
|
|
var routes = this.routes; |
38
|
|
|
|
|
|
|
for (var i=0, l=routes.length; i<l; i++) { |
39
|
|
|
|
|
|
|
var route = this.routes[i][0]; |
40
|
|
|
|
|
|
|
var callback = this.routes[i][1]; |
41
|
|
|
|
|
|
|
var matched = route.exec(path); |
42
|
|
|
|
|
|
|
if (matched) { |
43
|
|
|
|
|
|
|
var args = matched.slice(1); |
44
|
|
|
|
|
|
|
callback.apply(this, args); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
_compileRoute : function(route) { |
49
|
|
|
|
|
|
|
route = route.replace(escapeRegExp, "\\\\$&").replace(namedParam, "([^\\/]+)").replace(splatParam, "(.*?)"); |
50
|
|
|
|
|
|
|
return new RegExp(\'^\' + route + \'$\'); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
this.MicroDispatcher = Dispatcher; |
54
|
|
|
|
|
|
|
})(); |
55
|
|
|
|
|
|
|
' |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |