Skip to content

Commit 9871e86

Browse files
authored
Persist stack trace toggle in localStorage (#1224)
1 parent 82eb220 commit 9871e86

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/plug/templates/debugger.html.eex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,8 @@
844844
on($toggle, 'click', toggleOnclick)
845845
on($copyBtn, 'click', copyToClipboard)
846846

847+
restoreToggle()
848+
847849
function copyToClipboard () {
848850
if(navigator.clipboard) {
849851
// For those working on localhost or HTTPS
@@ -863,6 +865,8 @@
863865
}
864866

865867
function toggleOnclick () {
868+
localStorage.setItem('plugStackTrace', this.checked ? 'checked' : '');
869+
866870
if (this.checked) {
867871
var $first = document.querySelector('[role~="stack-trace-item"].-app:first-of-type')
868872
if ($first) itemOnclick.call($first)
@@ -872,6 +876,11 @@
872876
}
873877
}
874878
879+
function restoreToggle () {
880+
$toggle.checked = localStorage.getItem('plugStackTrace') === 'checked'
881+
toggleOnclick.call($toggle)
882+
}
883+
875884
function itemOnclick () {
876885
var idx = this.getAttribute('data-index')
877886

0 commit comments

Comments
 (0)