|
3 | 3 | <head> |
4 | 4 | <title><%= exception_type %> at <%= request_path %></title> |
5 | 5 | </head> |
6 | | -<body> |
| 6 | +<body class="better-errors-javascript-not-loaded"> |
7 | 7 | <%# Stylesheets are placed in the <body> for Turbolinks compatibility. %> |
8 | 8 | <style> |
9 | 9 | /* Basic reset */ |
|
232 | 232 | * Navigation |
233 | 233 | * --------------------------------------------------------------------- */ |
234 | 234 |
|
| 235 | + .better-errors-javascript-not-loaded .backtrace .tabs { |
| 236 | + display: none; |
| 237 | + } |
| 238 | + |
235 | 239 | nav.tabs { |
236 | 240 | border-bottom: solid 1px #ddd; |
237 | 241 |
|
|
416 | 420 | * Display area |
417 | 421 | * --------------------------------------------------------------------- */ |
418 | 422 |
|
| 423 | + .no-javascript-notice { |
| 424 | + margin-bottom: 1em; |
| 425 | + padding: 1em; |
| 426 | + border: 2px solid #e00; |
| 427 | + } |
| 428 | + .better-errors-javascript-loaded .no-javascript-notice { |
| 429 | + display: none; |
| 430 | + } |
| 431 | + .no-inline-style-notice { |
| 432 | + display: none; |
| 433 | + } |
| 434 | + |
419 | 435 | .trace_info { |
420 | 436 | background: #fff; |
421 | 437 | padding: 6px; |
|
473 | 489 | font-weight: 200; |
474 | 490 | } |
475 | 491 |
|
| 492 | + .better-errors-javascript-not-loaded .be-repl { |
| 493 | + display: none; |
| 494 | + } |
| 495 | + |
476 | 496 | .code, .be-console, .unavailable { |
477 | 497 | background: #fff; |
478 | 498 | padding: 5px; |
|
603 | 623 | .console-has-been-used .live-console-hint { |
604 | 624 | display: none; |
605 | 625 | } |
| 626 | + .better-errors-javascript-not-loaded .live-console-hint { |
| 627 | + display: none; |
| 628 | + } |
606 | 629 |
|
607 | 630 | .hint:before { |
608 | 631 | content: '\25b2'; |
|
745 | 768 | } |
746 | 769 | </script> |
747 | 770 |
|
| 771 | + <p class='no-inline-style-notice'> |
| 772 | + <strong> |
| 773 | + Better Errors can't apply inline style, |
| 774 | + possibly because you have a Content Security Policy along with Turbolinks. |
| 775 | + But you can |
| 776 | + <a href='/__better_errors' target="_blank">open the interactive console in a new tab/window</a>. |
| 777 | + </strong> |
| 778 | + </p> |
| 779 | + |
748 | 780 | <div class='top'> |
749 | 781 | <header class="exception"> |
750 | 782 | <h2><strong><%= exception_type %></strong> <span>at <%= request_path %></span></h2> |
|
791 | 823 | </ul> |
792 | 824 | </nav> |
793 | 825 |
|
794 | | - <% backtrace_frames.each_with_index do |frame, index| %> |
795 | | - <div class="frame_info" id="frame_info_<%= index %>"></div> |
796 | | - <% end %> |
| 826 | + <div class="frameInfos"> |
| 827 | + <div class="frame_info current" data-frame-idx="0"> |
| 828 | + <p class='no-javascript-notice'> |
| 829 | + Better Errors can't run Javascript here<span class='no-inline-style-notice'> (or apply inline style)</span>, |
| 830 | + possibly because you have a Content Security Policy along with Turbolinks. |
| 831 | + But you can |
| 832 | + <a href='/__better_errors' target="_blank">open the interactive console in a new tab/window</a>. |
| 833 | + </p> |
| 834 | + <!-- this is enough information to show something in case JS doesn't get to load --> |
| 835 | + <%== ErrorPage.render_template('variable_info', first_frame_variable_info) %> |
| 836 | + </div> |
| 837 | + </div> |
797 | 838 | </section> |
798 | 839 | </body> |
799 | 840 | <script nonce="<%= csp_nonce %>"> |
|
803 | 844 | var csrfToken = "<%= csrf_token %>"; |
804 | 845 |
|
805 | 846 | var previousFrame = null; |
806 | | - var previousFrameInfo = null; |
807 | 847 | var allFrames = document.querySelectorAll("ul.frames li"); |
808 | | - var allFrameInfos = document.querySelectorAll(".frame_info"); |
| 848 | + var frameInfos = document.querySelector(".frameInfos"); |
| 849 | + |
| 850 | + document.querySelector('body').classList.remove("better-errors-javascript-not-loaded"); |
| 851 | + document.querySelector('body').classList.add("better-errors-javascript-loaded"); |
809 | 852 |
|
810 | 853 | function apiCall(method, opts, cb) { |
811 | 854 | var req = new XMLHttpRequest(); |
|
979 | 1022 | }; |
980 | 1023 |
|
981 | 1024 | function switchTo(el) { |
982 | | - if(previousFrameInfo) { |
983 | | - previousFrameInfo.className = "frame_info"; |
| 1025 | + var currentFrameInfo = document.querySelectorAll('.frame_info.current'); |
| 1026 | + for(var i = 0; i < currentFrameInfo.length; i++) { |
| 1027 | + currentFrameInfo[i].className = "frame_info"; |
984 | 1028 | } |
985 | | - previousFrameInfo = el; |
986 | 1029 |
|
987 | 1030 | el.className = "frame_info current"; |
988 | 1031 |
|
|
991 | 1034 | } |
992 | 1035 |
|
993 | 1036 | function selectFrameInfo(index) { |
994 | | - var el = allFrameInfos[index]; |
| 1037 | + var el = document.querySelector(".frame_info[data-frame-idx='" + index + "']") |
| 1038 | + if (!el) { |
| 1039 | + el = document.createElement("div"); |
| 1040 | + el.className = "frame_info"; |
| 1041 | + el.setAttribute('data-frame-idx', index); |
| 1042 | + frameInfos.appendChild(el); |
| 1043 | + } |
995 | 1044 | if(el) { |
996 | 1045 | if (el.loaded) { |
997 | 1046 | return switchTo(el); |
|
0 commit comments