11<?php
22
3+ use Psr \Http \Message \ServerRequestInterface ;
34use Yiisoft \ErrorHandler \CompositeException ;
45use Yiisoft \ErrorHandler \Exception \ErrorException ;
6+ use Yiisoft \ErrorHandler \Renderer \HtmlRenderer ;
57use Yiisoft \FriendlyException \FriendlyExceptionInterface ;
68
79/**
8- * @var $this \Yiisoft\ErrorHandler\Renderer\ HtmlRenderer
9- * @var $request \Psr\Http\Message\ ServerRequestInterface|null
10- * @var $throwable \ Throwable
10+ * @var $this HtmlRenderer
11+ * @var $request ServerRequestInterface|null
12+ * @var $throwable Throwable
1113 */
1214
1315$ theme = $ _COOKIE ['yii-exception-theme ' ] ?? '' ;
3537 <?= file_get_contents (__DIR__ . '/development.css ' ) ?>
3638 </style>
3739 <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700">
40+ <noscript>
41+ <style>
42+ .call-stack-vendor-items, .functionArguments {
43+ display: block !important;
44+ }
45+ .call-stack-vendor-collapse .flex-1 {
46+ display: none;
47+ }
48+ </style>
49+ </noscript>
3850</head>
3951<body<?= !empty ($ theme ) ? " class= \"{$ this ->htmlEncode ($ theme )}\"" : '' ?> >
4052<header>
@@ -189,6 +201,9 @@ class="copy-clipboard"
189201 <?= file_get_contents (__DIR__ . '/highlight.min.js ' ) ?>
190202</script>
191203<script>
204+ const LIGHT_THEME = 'light-theme';
205+ const DARK_THEME = 'dark-theme';
206+
192207 window.onload = function() {
193208 const codeBlocks = document.querySelectorAll('.solution pre code,.codeBlock');
194209 const callStackItems = document.getElementsByClassName('call-stack-item');
@@ -346,15 +361,13 @@ class="copy-clipboard"
346361 }
347362
348363 function enableDarkTheme() {
349- document.body.classList.remove('light-theme');
350- document.body.classList.add('dark-theme');
351- setCookie('yii-exception-theme', 'dark-theme');
364+ applyTheme(DARK_THEME);
365+ setCookie('yii-exception-theme', DARK_THEME);
352366 }
353367
354368 function enableLightTheme() {
355- document.body.classList.remove('dark-theme');
356- document.body.classList.add('light-theme');
357- setCookie('yii-exception-theme', 'light-theme');
369+ applyTheme(LIGHT_THEME);
370+ setCookie('yii-exception-theme', LIGHT_THEME);
358371 }
359372 };
360373
@@ -363,28 +376,32 @@ function enableLightTheme() {
363376 document.onmouseup = function() { document.getElementsByTagName('body')[0].classList.remove('mousedown'); }
364377
365378 <?php if (empty ($ theme )): ?>
366- var theme = getCookie('yii-exception-theme');
367-
379+ const theme = getCookie('yii-exception-theme');
368380 if (theme) {
369- document.body.classList.add (theme);
381+ applyTheme (theme);
370382 }
371383 <?php endif ; ?>
372384
385+ function applyTheme(theme){
386+ document.body.classList.remove(DARK_THEME, LIGHT_THEME);
387+ document.body.classList.add(theme);
388+ }
389+
373390 function setCookie(name, value) {
374- var date = new Date(2100, 0, 1);
375- var expires = "; expires=" + date.toUTCString();
391+ const date = new Date(2100, 0, 1);
392+ const expires = "; expires=" + date.toUTCString();
376393
377394 document.cookie = name + "=" + (value || "") + expires + "; path=/";
378395 }
379396
380397 function getCookie(name) {
381- var nameEQ = name + "=";
382- var ca = document.cookie.split(';');
398+ const nameEQ = name + "=";
399+ const ca = document.cookie.split(';');
383400
384- for (var i=0; i < ca.length; i++) {
385- var c = ca[i];
386- while (c.charAt(0)== ' ') c = c.substring(1,c.length);
387- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
401+ for (let i=0; i < ca.length; i++) {
402+ let c = ca[i];
403+ while (c.charAt(0) === ' ') c = c.substring(1,c.length);
404+ if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length,c.length);
388405 }
389406
390407 return null;
0 commit comments