Skip to content
This repository
Browse code

move error page js into script tag

  • Loading branch information...
commit 1a5b5e19fc38955d5e755574276fc39fdee438fa 1 parent f8633f9
Gosha Arinich goshakkk authored
6 actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
... ... @@ -1,6 +1,6 @@
1 1 <% unless @exception.blamed_files.blank? %>
2 2 <% if (hide = @exception.blamed_files.length > 8) %>
3   - <a href="#" onclick="s = document.getElementById('blame_trace').style; s.display = s.display == 'none' ? 'block' : 'none'; return false;">Toggle blamed files</a>
  3 + <a href="#" onclick="toggleTrace()">Toggle blamed files</a>
4 4 <% end %>
5 5 <pre id="blame_trace" <%='style="display:none"' if hide %>><code><%=h @exception.describe_blame %></code></pre>
6 6 <% end %>
@@ -21,12 +21,12 @@
21 21 <p><b>Parameters</b>:</p> <pre><%=h request_dump %></pre>
22 22
23 23 <div class="details">
24   - <div class="summary"><a href="#" onclick="s = document.getElementById('session_dump').style; s.display = s.display == 'none' ? 'block' : 'none'; return false;">Toggle session dump</a></div>
  24 + <div class="summary"><a href="#" onclick="toggleSessionDump()">Toggle session dump</a></div>
25 25 <div id="session_dump" style="display:none"><pre><%= debug_hash @request.session %></pre></div>
26 26 </div>
27 27
28 28 <div class="details">
29   - <div class="summary"><a href="#" onclick="s = document.getElementById('env_dump').style; s.display = s.display == 'none' ? 'block' : 'none'; return false;">Toggle env dump</a></div>
  29 + <div class="summary"><a href="#" onclick="toggleEnvDump()">Toggle env dump</a></div>
30 30 <div id="env_dump" style="display:none"><pre><%= debug_hash @request.env.slice(*@request.class::ENV_METHODS) %></pre></div>
31 31 </div>
32 32
4 actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb
@@ -12,8 +12,8 @@
12 12 <div id="traces">
13 13 <% names.each do |name| %>
14 14 <%
15   - show = "document.getElementById('#{name.gsub(/\s/, '-')}').style.display='block';"
16   - hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub(/\s/, '-')}').style.display='none';"}
  15 + show = "show('#{name.gsub(/\s/, '-')}');"
  16 + hide = (names - [name]).collect {|hide_name| "hide('#{hide_name.gsub(/\s/, '-')}');"}
17 17 %>
18 18 <a href="#" onclick="<%= hide.join %><%= show %>; return false;"><%= name %></a> <%= '|' unless names.last == name %>
19 19 <% end %>
22 actionpack/lib/action_dispatch/middleware/templates/rescues/layout.erb
@@ -114,6 +114,28 @@
114 114 a:visited { color: #666; }
115 115 a:hover { color: #C52F24; }
116 116 </style>
  117 +
  118 + <script>
  119 + var toggle = function(id) {
  120 + var s = document.getElementById(id).style;
  121 + s.display = s.display == 'none' ? 'block' : 'none';
  122 + }
  123 + var show = function(id) {
  124 + document.getElementById(id).style.display = 'block';
  125 + }
  126 + var hide = function(id) {
  127 + document.getElementById(id).style.display = 'none';
  128 + }
  129 + var toggleTrace = function() {
  130 + toggle('blame_trace');
  131 + }
  132 + var toggleSessionDump = function() {
  133 + toggle('session_dump');
  134 + }
  135 + var toggleEnvDump = function() {
  136 + toggle('env_dump');
  137 + }
  138 + </script>
117 139 </head>
118 140 <body>
119 141

0 comments on commit 1a5b5e1

Please sign in to comment.
Something went wrong with that request. Please try again.