web-console 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of web-console might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.markdown +132 -85
- data/lib/web_console.rb +14 -13
- data/lib/web_console/errors.rb +7 -0
- data/lib/web_console/{repl.rb → evaluator.rb} +7 -10
- data/lib/web_console/helper.rb +22 -0
- data/lib/web_console/integration.rb +8 -0
- data/lib/web_console/{core_ext/exception → integration}/cruby.rb +0 -0
- data/lib/web_console/integration/jruby.rb +111 -0
- data/lib/web_console/integration/rubinius.rb +66 -0
- data/lib/web_console/middleware.rb +117 -0
- data/lib/web_console/railtie.rb +61 -0
- data/lib/web_console/request.rb +30 -0
- data/lib/web_console/session.rb +65 -0
- data/lib/web_console/template.rb +49 -0
- data/lib/web_console/templates/_inner_console_markup.html +3 -0
- data/lib/web_console/templates/_markup.html +4 -0
- data/lib/web_console/templates/_prompt_box_markup.html +2 -0
- data/lib/web_console/templates/console.js +373 -0
- data/lib/web_console/templates/error_page.js +83 -0
- data/lib/web_console/templates/index.html +8 -0
- data/lib/web_console/templates/layouts/inlined_string.erb +1 -0
- data/lib/web_console/templates/layouts/javascript.erb +5 -0
- data/lib/web_console/templates/main.js +24 -0
- data/lib/web_console/templates/style.css +9 -0
- data/lib/web_console/version.rb +1 -1
- data/lib/web_console/whiny_request.rb +38 -0
- data/lib/web_console/whitelist.rb +42 -0
- data/test/dummy/config/environments/test.rb +0 -4
- data/test/dummy/log/development.log +7075 -0
- data/test/dummy/log/test.log +66006 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/support/scenarios/bad_custom_error_scenario.rb +17 -0
- data/test/support/scenarios/basic_nested_scenario.rb +15 -0
- data/test/support/scenarios/custom_error_scenario.rb +11 -0
- data/test/support/scenarios/eval_nested_scenario.rb +15 -0
- data/test/support/scenarios/flat_scenario.rb +9 -0
- data/test/support/scenarios/reraised_scenario.rb +21 -0
- data/test/test_helper.rb +50 -3
- data/test/web_console/evaluator_test.rb +73 -0
- data/test/web_console/helper_test.rb +76 -0
- data/test/web_console/integration_test.rb +47 -0
- data/test/web_console/middleware_test.rb +116 -0
- data/test/web_console/railtie_test.rb +99 -0
- data/test/web_console/request_test.rb +52 -0
- data/test/web_console/session_test.rb +59 -0
- data/test/web_console/whiny_request_test.rb +33 -0
- data/test/web_console/whitelist_test.rb +43 -0
- metadata +66 -56
- data/lib/action_dispatch/debug_exceptions.rb +0 -105
- data/lib/action_dispatch/exception_wrapper.rb +0 -38
- data/lib/action_dispatch/templates/rescues/_request_and_response.html.erb +0 -34
- data/lib/action_dispatch/templates/rescues/_request_and_response.text.erb +0 -23
- data/lib/action_dispatch/templates/rescues/_source.erb +0 -29
- data/lib/action_dispatch/templates/rescues/_trace.html.erb +0 -72
- data/lib/action_dispatch/templates/rescues/_trace.text.erb +0 -9
- data/lib/action_dispatch/templates/rescues/_web_console.html.erb +0 -420
- data/lib/action_dispatch/templates/rescues/diagnostics.html.erb +0 -18
- data/lib/action_dispatch/templates/rescues/diagnostics.text.erb +0 -9
- data/lib/action_dispatch/templates/rescues/layout.erb +0 -160
- data/lib/action_dispatch/templates/rescues/missing_template.html.erb +0 -13
- data/lib/action_dispatch/templates/rescues/missing_template.text.erb +0 -3
- data/lib/action_dispatch/templates/rescues/routing_error.html.erb +0 -34
- data/lib/action_dispatch/templates/rescues/routing_error.text.erb +0 -11
- data/lib/action_dispatch/templates/rescues/template_error.html.erb +0 -22
- data/lib/action_dispatch/templates/rescues/template_error.text.erb +0 -7
- data/lib/action_dispatch/templates/rescues/unknown_action.html.erb +0 -6
- data/lib/action_dispatch/templates/rescues/unknown_action.text.erb +0 -3
- data/lib/action_dispatch/templates/routes/_route.html.erb +0 -16
- data/lib/action_dispatch/templates/routes/_table.html.erb +0 -200
- data/lib/assets/javascripts/web-console.js +0 -1
- data/lib/assets/javascripts/web_console.js +0 -41
- data/lib/web_console/controller_helpers.rb +0 -46
- data/lib/web_console/core_ext/exception.rb +0 -7
- data/lib/web_console/core_ext/exception/jruby.rb +0 -25
- data/lib/web_console/core_ext/exception/rubinius.rb +0 -32
- data/lib/web_console/engine.rb +0 -47
- data/lib/web_console/repl_session.rb +0 -89
- data/lib/web_console/unsupported_platforms.rb +0 -28
- data/lib/web_console/view_helpers.rb +0 -16
- data/test/action_pack/exception_wrapper_test.rb +0 -26
- data/test/controllers/tests_controller_test.rb +0 -41
- data/test/web_console/core_ext/exception_test.rb +0 -46
- data/test/web_console/engine_test.rb +0 -108
- data/test/web_console/repl_session_test.rb +0 -32
- data/test/web_console/repl_test.rb +0 -75
@@ -1,18 +0,0 @@
|
|
1
|
-
<header>
|
2
|
-
<h1>
|
3
|
-
<%= @exception.class.to_s %>
|
4
|
-
<% if @request.parameters['controller'] %>
|
5
|
-
in <%= @request.parameters['controller'].camelize %>Controller<% if @request.parameters['action'] %>#<%= @request.parameters['action'] %><% end %>
|
6
|
-
<% end %>
|
7
|
-
</h1>
|
8
|
-
</header>
|
9
|
-
|
10
|
-
<div id="container">
|
11
|
-
<h2><%= h @exception.message %></h2>
|
12
|
-
|
13
|
-
<%= render template: "rescues/_source" %>
|
14
|
-
<%= render template: "rescues/_trace" %>
|
15
|
-
<%= render template: "rescues/_request_and_response" %>
|
16
|
-
</div>
|
17
|
-
|
18
|
-
<%= render template: "rescues/_web_console" %>
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<%= @exception.class.to_s %><%
|
2
|
-
if @request.parameters['controller']
|
3
|
-
%> in <%= @request.parameters['controller'].camelize %>Controller<% if @request.parameters['action'] %>#<%= @request.parameters['action'] %><% end %>
|
4
|
-
<% end %>
|
5
|
-
|
6
|
-
<%= @exception.message %>
|
7
|
-
<%= render template: "rescues/_source" %>
|
8
|
-
<%= render template: "rescues/_trace" %>
|
9
|
-
<%= render template: "rescues/_request_and_response" %>
|
@@ -1,160 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<title>Action Controller: Exception caught</title>
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #FAFAFA;
|
9
|
-
color: #333;
|
10
|
-
margin: 0px;
|
11
|
-
}
|
12
|
-
|
13
|
-
body, p, ol, ul, td {
|
14
|
-
font-family: helvetica, verdana, arial, sans-serif;
|
15
|
-
font-size: 13px;
|
16
|
-
line-height: 18px;
|
17
|
-
}
|
18
|
-
|
19
|
-
pre {
|
20
|
-
font-size: 11px;
|
21
|
-
white-space: pre-wrap;
|
22
|
-
}
|
23
|
-
|
24
|
-
pre.box {
|
25
|
-
border: 1px solid #EEE;
|
26
|
-
padding: 10px;
|
27
|
-
margin: 0px;
|
28
|
-
width: 958px;
|
29
|
-
}
|
30
|
-
|
31
|
-
header {
|
32
|
-
color: #F0F0F0;
|
33
|
-
background: #C52F24;
|
34
|
-
padding: 0.5em 1.5em;
|
35
|
-
}
|
36
|
-
|
37
|
-
h1 {
|
38
|
-
margin: 0.2em 0;
|
39
|
-
line-height: 1.1em;
|
40
|
-
font-size: 2em;
|
41
|
-
}
|
42
|
-
|
43
|
-
h2 {
|
44
|
-
color: #C52F24;
|
45
|
-
line-height: 25px;
|
46
|
-
}
|
47
|
-
|
48
|
-
.details {
|
49
|
-
border: 1px solid #D0D0D0;
|
50
|
-
border-radius: 4px;
|
51
|
-
margin: 1em 0px;
|
52
|
-
display: block;
|
53
|
-
width: 978px;
|
54
|
-
}
|
55
|
-
|
56
|
-
.summary {
|
57
|
-
padding: 8px 15px;
|
58
|
-
border-bottom: 1px solid #D0D0D0;
|
59
|
-
display: block;
|
60
|
-
}
|
61
|
-
|
62
|
-
.details pre {
|
63
|
-
margin: 5px;
|
64
|
-
border: none;
|
65
|
-
}
|
66
|
-
|
67
|
-
#container {
|
68
|
-
box-sizing: border-box;
|
69
|
-
width: 100%;
|
70
|
-
padding: 0 1.5em;
|
71
|
-
}
|
72
|
-
|
73
|
-
.source * {
|
74
|
-
margin: 0px;
|
75
|
-
padding: 0px;
|
76
|
-
}
|
77
|
-
|
78
|
-
.source {
|
79
|
-
border: 1px solid #D9D9D9;
|
80
|
-
background: #ECECEC;
|
81
|
-
width: 978px;
|
82
|
-
}
|
83
|
-
|
84
|
-
.source pre {
|
85
|
-
padding: 10px 0px;
|
86
|
-
border: none;
|
87
|
-
}
|
88
|
-
|
89
|
-
.source .data {
|
90
|
-
font-size: 80%;
|
91
|
-
overflow: auto;
|
92
|
-
background-color: #FFF;
|
93
|
-
}
|
94
|
-
|
95
|
-
.info {
|
96
|
-
padding: 0.5em;
|
97
|
-
}
|
98
|
-
|
99
|
-
.source .data .line_numbers {
|
100
|
-
background-color: #ECECEC;
|
101
|
-
color: #AAA;
|
102
|
-
padding: 1em .5em;
|
103
|
-
border-right: 1px solid #DDD;
|
104
|
-
text-align: right;
|
105
|
-
}
|
106
|
-
|
107
|
-
.line {
|
108
|
-
padding-left: 10px;
|
109
|
-
}
|
110
|
-
|
111
|
-
.line:hover {
|
112
|
-
background-color: #F6F6F6;
|
113
|
-
}
|
114
|
-
|
115
|
-
.line.active {
|
116
|
-
background-color: #FFCCCC;
|
117
|
-
}
|
118
|
-
|
119
|
-
.hidden {
|
120
|
-
display: none;
|
121
|
-
}
|
122
|
-
|
123
|
-
a { color: #980905; }
|
124
|
-
a:visited { color: #666; }
|
125
|
-
a.trace-frames { color: #666; }
|
126
|
-
a:hover { color: #C52F24; }
|
127
|
-
a.trace-frames.selected { color: #C52F24 }
|
128
|
-
|
129
|
-
<%= yield :style %>
|
130
|
-
</style>
|
131
|
-
|
132
|
-
<script>
|
133
|
-
var toggle = function(id) {
|
134
|
-
var s = document.getElementById(id).style;
|
135
|
-
s.display = s.display == 'none' ? 'block' : 'none';
|
136
|
-
return false;
|
137
|
-
}
|
138
|
-
var show = function(id) {
|
139
|
-
document.getElementById(id).style.display = 'block';
|
140
|
-
}
|
141
|
-
var hide = function(id) {
|
142
|
-
document.getElementById(id).style.display = 'none';
|
143
|
-
}
|
144
|
-
var toggleTrace = function() {
|
145
|
-
return toggle('blame_trace');
|
146
|
-
}
|
147
|
-
var toggleSessionDump = function() {
|
148
|
-
return toggle('session_dump');
|
149
|
-
}
|
150
|
-
var toggleEnvDump = function() {
|
151
|
-
return toggle('env_dump');
|
152
|
-
}
|
153
|
-
</script>
|
154
|
-
</head>
|
155
|
-
<body>
|
156
|
-
|
157
|
-
<%= yield %>
|
158
|
-
|
159
|
-
</body>
|
160
|
-
</html>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<header>
|
2
|
-
<h1>Template is missing</h1>
|
3
|
-
</header>
|
4
|
-
|
5
|
-
<div id="container">
|
6
|
-
<h2><%= h @exception.message %></h2>
|
7
|
-
|
8
|
-
<%= render template: "rescues/_source" %>
|
9
|
-
<%= render template: "rescues/_trace" %>
|
10
|
-
<%= render template: "rescues/_request_and_response" %>
|
11
|
-
</div>
|
12
|
-
|
13
|
-
<%= render template: "rescues/_web_console" %>
|
@@ -1,34 +0,0 @@
|
|
1
|
-
<header>
|
2
|
-
<h1>Routing Error</h1>
|
3
|
-
</header>
|
4
|
-
<div id="container">
|
5
|
-
<h2><%= h @exception.message %></h2>
|
6
|
-
<% unless @exception.failures.empty? %>
|
7
|
-
<p>
|
8
|
-
<h2>Failure reasons:</h2>
|
9
|
-
<ol>
|
10
|
-
<% @exception.failures.each do |route, reason| %>
|
11
|
-
<li><code><%= route.inspect.delete('\\') %></code> failed because <%= reason.downcase %></li>
|
12
|
-
<% end %>
|
13
|
-
</ol>
|
14
|
-
</p>
|
15
|
-
<% end %>
|
16
|
-
|
17
|
-
<%= render template: "rescues/_trace" %>
|
18
|
-
|
19
|
-
<% if @routes_inspector %>
|
20
|
-
<h2>
|
21
|
-
Routes
|
22
|
-
</h2>
|
23
|
-
|
24
|
-
<p>
|
25
|
-
Routes match in priority from top to bottom
|
26
|
-
</p>
|
27
|
-
|
28
|
-
<%= @routes_inspector.format(ActionDispatch::Routing::HtmlTableFormatter.new(self)) %>
|
29
|
-
<% end %>
|
30
|
-
|
31
|
-
<%= render template: "rescues/_request_and_response" %>
|
32
|
-
</div>
|
33
|
-
|
34
|
-
<%= render template: "rescues/_web_console" %>
|
@@ -1,11 +0,0 @@
|
|
1
|
-
Routing Error
|
2
|
-
|
3
|
-
<%= @exception.message %>
|
4
|
-
<% unless @exception.failures.empty? %>
|
5
|
-
Failure reasons:
|
6
|
-
<% @exception.failures.each do |route, reason| %>
|
7
|
-
- <%= route.inspect.delete('\\') %></code> failed because <%= reason.downcase %>
|
8
|
-
<% end %>
|
9
|
-
<% end %>
|
10
|
-
|
11
|
-
<%= render template: "rescues/_trace", format: :text %>
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<header>
|
2
|
-
<h1>
|
3
|
-
<%= @exception.original_exception.class.to_s %> in
|
4
|
-
<%= @request.parameters["controller"].camelize if @request.parameters["controller"] %>#<%= @request.parameters["action"] %>
|
5
|
-
</h1>
|
6
|
-
</header>
|
7
|
-
|
8
|
-
<div id="container">
|
9
|
-
<p>
|
10
|
-
Showing <i><%= @exception.file_name %></i> where line <b>#<%= @exception.line_number %></b> raised:
|
11
|
-
</p>
|
12
|
-
<pre><code><%= h @exception.message %></code></pre>
|
13
|
-
|
14
|
-
<%= render template: "rescues/_source" %>
|
15
|
-
|
16
|
-
<p><%= @exception.sub_template_message %></p>
|
17
|
-
|
18
|
-
<%= render template: "rescues/_trace" %>
|
19
|
-
<%= render template: "rescues/_request_and_response" %>
|
20
|
-
</div>
|
21
|
-
|
22
|
-
<%= render template: "rescues/_web_console" %>
|
@@ -1,7 +0,0 @@
|
|
1
|
-
<%= @exception.original_exception.class.to_s %> in <%= @request.parameters["controller"].camelize if @request.parameters["controller"] %>#<%= @request.parameters["action"] %>
|
2
|
-
|
3
|
-
Showing <%= @exception.file_name %> where line #<%= @exception.line_number %> raised:
|
4
|
-
<%= @exception.message %>
|
5
|
-
<%= @exception.sub_template_message %>
|
6
|
-
<%= render template: "rescues/_trace", format: :text %>
|
7
|
-
<%= render template: "rescues/_request_and_response", format: :text %>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<tr class='route_row' data-helper='path'>
|
2
|
-
<td data-route-name='<%= route[:name] %>'>
|
3
|
-
<% if route[:name].present? %>
|
4
|
-
<%= route[:name] %><span class='helper'>_path</span>
|
5
|
-
<% end %>
|
6
|
-
</td>
|
7
|
-
<td data-route-verb='<%= route[:verb] %>'>
|
8
|
-
<%= route[:verb] %>
|
9
|
-
</td>
|
10
|
-
<td data-route-path='<%= route[:path] %>' data-regexp='<%= route[:regexp] %>'>
|
11
|
-
<%= route[:path] %>
|
12
|
-
</td>
|
13
|
-
<td data-route-reqs='<%= route[:reqs] %>'>
|
14
|
-
<%= route[:reqs] %>
|
15
|
-
</td>
|
16
|
-
</tr>
|
@@ -1,200 +0,0 @@
|
|
1
|
-
<% content_for :style do %>
|
2
|
-
#route_table {
|
3
|
-
margin: 0;
|
4
|
-
border-collapse: collapse;
|
5
|
-
}
|
6
|
-
|
7
|
-
#route_table thead tr {
|
8
|
-
border-bottom: 2px solid #ddd;
|
9
|
-
}
|
10
|
-
|
11
|
-
#route_table thead tr.bottom {
|
12
|
-
border-bottom: none;
|
13
|
-
}
|
14
|
-
|
15
|
-
#route_table thead tr.bottom th {
|
16
|
-
padding: 10px 0;
|
17
|
-
line-height: 15px;
|
18
|
-
}
|
19
|
-
|
20
|
-
#route_table tbody tr {
|
21
|
-
border-bottom: 1px solid #ddd;
|
22
|
-
}
|
23
|
-
|
24
|
-
#route_table tbody tr:nth-child(odd) {
|
25
|
-
background: #f2f2f2;
|
26
|
-
}
|
27
|
-
|
28
|
-
#route_table tbody.exact_matches,
|
29
|
-
#route_table tbody.fuzzy_matches {
|
30
|
-
background-color: LightGoldenRodYellow;
|
31
|
-
border-bottom: solid 2px SlateGrey;
|
32
|
-
}
|
33
|
-
|
34
|
-
#route_table tbody.exact_matches tr,
|
35
|
-
#route_table tbody.fuzzy_matches tr {
|
36
|
-
background: none;
|
37
|
-
border-bottom: none;
|
38
|
-
}
|
39
|
-
|
40
|
-
#route_table td {
|
41
|
-
padding: 4px 30px;
|
42
|
-
}
|
43
|
-
|
44
|
-
#path_search {
|
45
|
-
width: 80%;
|
46
|
-
font-size: inherit;
|
47
|
-
}
|
48
|
-
<% end %>
|
49
|
-
|
50
|
-
<table id='route_table' class='route_table'>
|
51
|
-
<thead>
|
52
|
-
<tr>
|
53
|
-
<th>Helper</th>
|
54
|
-
<th>HTTP Verb</th>
|
55
|
-
<th>Path</th>
|
56
|
-
<th>Controller#Action</th>
|
57
|
-
</tr>
|
58
|
-
<tr class='bottom'>
|
59
|
-
<th><%# Helper %>
|
60
|
-
<%= link_to "Path", "#", 'data-route-helper' => '_path',
|
61
|
-
title: "Returns a relative path (without the http or domain)" %> /
|
62
|
-
<%= link_to "Url", "#", 'data-route-helper' => '_url',
|
63
|
-
title: "Returns an absolute url (with the http and domain)" %>
|
64
|
-
</th>
|
65
|
-
<th><%# HTTP Verb %>
|
66
|
-
</th>
|
67
|
-
<th><%# Path %>
|
68
|
-
<%= search_field(:path, nil, id: 'search', placeholder: "Path Match") %>
|
69
|
-
</th>
|
70
|
-
<th><%# Controller#action %>
|
71
|
-
</th>
|
72
|
-
</tr>
|
73
|
-
</thead>
|
74
|
-
<tbody class='exact_matches' id='exact_matches'>
|
75
|
-
</tbody>
|
76
|
-
<tbody class='fuzzy_matches' id='fuzzy_matches'>
|
77
|
-
</tbody>
|
78
|
-
<tbody>
|
79
|
-
<%= yield %>
|
80
|
-
</tbody>
|
81
|
-
</table>
|
82
|
-
|
83
|
-
<script type='text/javascript'>
|
84
|
-
// Iterates each element through a function
|
85
|
-
function each(elems, func) {
|
86
|
-
if (!elems instanceof Array) { elems = [elems]; }
|
87
|
-
for (var i = 0, len = elems.length; i < len; i++) {
|
88
|
-
func(elems[i]);
|
89
|
-
}
|
90
|
-
}
|
91
|
-
|
92
|
-
// Sets innerHTML for an element
|
93
|
-
function setContent(elem, text) {
|
94
|
-
elem.innerHTML = text;
|
95
|
-
}
|
96
|
-
|
97
|
-
// Enables path search functionality
|
98
|
-
function setupMatchPaths() {
|
99
|
-
// Check if the user input (sanitized as a path) matches the regexp data attribute
|
100
|
-
function checkExactMatch(section, elem, value) {
|
101
|
-
var string = sanitizePath(value),
|
102
|
-
regexp = elem.getAttribute("data-regexp");
|
103
|
-
|
104
|
-
showMatch(string, regexp, section, elem);
|
105
|
-
}
|
106
|
-
|
107
|
-
// Check if the route path data attribute contains the user input
|
108
|
-
function checkFuzzyMatch(section, elem, value) {
|
109
|
-
var string = elem.getAttribute("data-route-path"),
|
110
|
-
regexp = value;
|
111
|
-
|
112
|
-
showMatch(string, regexp, section, elem);
|
113
|
-
}
|
114
|
-
|
115
|
-
// Display the parent <tr> element in the appropriate section when there's a match
|
116
|
-
function showMatch(string, regexp, section, elem) {
|
117
|
-
if(string.match(RegExp(regexp))) {
|
118
|
-
section.appendChild(elem.parentNode.cloneNode(true));
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
// Check if there are any matched results in a section
|
123
|
-
function checkNoMatch(section, defaultText, noMatchText) {
|
124
|
-
if (section.innerHTML === defaultText) {
|
125
|
-
setContent(section, defaultText + noMatchText);
|
126
|
-
}
|
127
|
-
}
|
128
|
-
|
129
|
-
// Ensure path always starts with a slash "/" and remove params or fragments
|
130
|
-
function sanitizePath(path) {
|
131
|
-
var path = path.charAt(0) == '/' ? path : "/" + path;
|
132
|
-
return path.replace(/\#.*|\?.*/, '');
|
133
|
-
}
|
134
|
-
|
135
|
-
var regexpElems = document.querySelectorAll('#route_table [data-regexp]'),
|
136
|
-
searchElem = document.querySelector('#search'),
|
137
|
-
exactMatches = document.querySelector('#exact_matches'),
|
138
|
-
fuzzyMatches = document.querySelector('#fuzzy_matches');
|
139
|
-
|
140
|
-
// Remove matches when no search value is present
|
141
|
-
searchElem.onblur = function(e) {
|
142
|
-
if (searchElem.value === "") {
|
143
|
-
setContent(exactMatches, "");
|
144
|
-
setContent(fuzzyMatches, "");
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
|
-
// On key press perform a search for matching paths
|
149
|
-
searchElem.onkeyup = function(e){
|
150
|
-
var userInput = searchElem.value,
|
151
|
-
defaultExactMatch = '<tr><th colspan="4">Paths Matching (' + escape(sanitizePath(userInput)) +'):</th></tr>',
|
152
|
-
defaultFuzzyMatch = '<tr><th colspan="4">Paths Containing (' + escape(userInput) +'):</th></tr>',
|
153
|
-
noExactMatch = '<tr><th colspan="4">No Exact Matches Found</th></tr>',
|
154
|
-
noFuzzyMatch = '<tr><th colspan="4">No Fuzzy Matches Found</th></tr>';
|
155
|
-
|
156
|
-
// Clear out results section
|
157
|
-
setContent(exactMatches, defaultExactMatch);
|
158
|
-
setContent(fuzzyMatches, defaultFuzzyMatch);
|
159
|
-
|
160
|
-
// Display exact matches and fuzzy matches
|
161
|
-
each(regexpElems, function(elem) {
|
162
|
-
checkExactMatch(exactMatches, elem, userInput);
|
163
|
-
checkFuzzyMatch(fuzzyMatches, elem, userInput);
|
164
|
-
})
|
165
|
-
|
166
|
-
// Display 'No Matches' message when no matches are found
|
167
|
-
checkNoMatch(exactMatches, defaultExactMatch, noExactMatch);
|
168
|
-
checkNoMatch(fuzzyMatches, defaultFuzzyMatch, noFuzzyMatch);
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
|
-
// Enables functionality to toggle between `_path` and `_url` helper suffixes
|
173
|
-
function setupRouteToggleHelperLinks() {
|
174
|
-
|
175
|
-
// Sets content for each element
|
176
|
-
function setValOn(elems, val) {
|
177
|
-
each(elems, function(elem) {
|
178
|
-
setContent(elem, val);
|
179
|
-
});
|
180
|
-
}
|
181
|
-
|
182
|
-
// Sets onClick event for each element
|
183
|
-
function onClick(elems, func) {
|
184
|
-
each(elems, function(elem) {
|
185
|
-
elem.onclick = func;
|
186
|
-
});
|
187
|
-
}
|
188
|
-
|
189
|
-
var toggleLinks = document.querySelectorAll('#route_table [data-route-helper]');
|
190
|
-
onClick(toggleLinks, function(){
|
191
|
-
var helperTxt = this.getAttribute("data-route-helper"),
|
192
|
-
helperElems = document.querySelectorAll('[data-route-name] span.helper');
|
193
|
-
|
194
|
-
setValOn(helperElems, helperTxt);
|
195
|
-
});
|
196
|
-
}
|
197
|
-
|
198
|
-
setupMatchPaths();
|
199
|
-
setupRouteToggleHelperLinks();
|
200
|
-
</script>
|