Skip to content

Commit

Permalink
feat: show livereload count in log and on config page
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Nov 10, 2023
1 parent 27f9a04 commit ad7748a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2366,6 +2366,9 @@ private function configLivereload(InputfieldWrapper $inputfields)
} else $value = 'LiveReload is disabled. To enable it set this in your config.php:
<pre class="uk-margin-small-top uk-margin-remove-bottom">$config->livereload = 1;</pre>';
$f->value = $value;
$f->notes = "LiveReload saved you from hitting refresh <span id=live-cnt></span> times on this device :)";
$f->entityEncodeText = false;
$f->appendMarkup = "<script>document.getElementById('live-cnt').innerText = localStorage.getItem('livereload-count') || 0;</script>";
$fs->add($f);

// early exit if live reload is disabled
Expand Down
4 changes: 3 additions & 1 deletion livereload.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ setTimeout(() => {
}

// all fine, reload page
console.log("detected change - reloading");
let cnt = localStorage.getItem("livereload-count") || 0;
localStorage.setItem("livereload-count", ++cnt);
console.log("detected change - reloading " + cnt);
reloading = true;
setTimeout(() => {
document.location.reload(true);
Expand Down
2 changes: 1 addition & 1 deletion livereload.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ad7748a

Please sign in to comment.