Skip to content

Commit

Permalink
Persist stack trace toggle in localStorage (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
osbre committed Jun 4, 2024
1 parent 82eb220 commit 9871e86
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/plug/templates/debugger.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,8 @@
on($toggle, 'click', toggleOnclick)
on($copyBtn, 'click', copyToClipboard)
restoreToggle()
function copyToClipboard () {
if(navigator.clipboard) {
// For those working on localhost or HTTPS
Expand All @@ -863,6 +865,8 @@
}
function toggleOnclick () {
localStorage.setItem('plugStackTrace', this.checked ? 'checked' : '');
if (this.checked) {
var $first = document.querySelector('[role~="stack-trace-item"].-app:first-of-type')
if ($first) itemOnclick.call($first)
Expand All @@ -872,6 +876,11 @@
}
}
function restoreToggle () {
$toggle.checked = localStorage.getItem('plugStackTrace') === 'checked'
toggleOnclick.call($toggle)
}
function itemOnclick () {
var idx = this.getAttribute('data-index')
Expand Down

0 comments on commit 9871e86

Please sign in to comment.