-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da1f493
commit 5354827
Showing
5 changed files
with
74 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// @ts-check | ||
|
||
import { showDebugTab } from "./utils/debug.js"; | ||
|
||
// Show the debug tab if the debug mode is enabled. | ||
showDebugTab(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// @ts-check | ||
|
||
/** | ||
* @description | ||
* Check if the debug mode is enabled. | ||
* To enable the debug mode, add the query parameter "p=debug" to the URL. | ||
* Example: http://localhost:8000/?p=debug | ||
* @returns {boolean} | ||
*/ | ||
function isDebugModeEnabled() { | ||
return "debug" === new URL(window.location.href).searchParams.get("p"); | ||
} | ||
|
||
/** | ||
* @description | ||
* Reset the local storage (fortknightHS). | ||
*/ | ||
function resetLocalStorage() { | ||
localStorage.removeItem("fortknightHS"); | ||
location.reload(); | ||
} | ||
|
||
/** | ||
* @description | ||
* Show the debug info in the debug tab. | ||
*/ | ||
function showDebugInfo() { | ||
const debugTab = document.querySelector(".debug"); | ||
if (debugTab) { | ||
debugTab.textContent = JSON.stringify( | ||
JSON.parse(localStorage.getItem("fortknightHS") ?? "{}"), | ||
undefined, | ||
2 | ||
); | ||
} else { | ||
console.error("Debug tab not found."); | ||
} | ||
} | ||
|
||
/** | ||
* @description | ||
* Show the debug tab, if the debug mode is enabled. | ||
*/ | ||
function showDebugTab() { | ||
if (isDebugModeEnabled()) { | ||
const debugTab = document.querySelector(".debugTab"); | ||
if (debugTab) { | ||
debugTab.classList.remove("hidden"); | ||
} else { | ||
console.error("Debug tab not found."); | ||
} | ||
} | ||
} | ||
|
||
/** event listeners */ | ||
document.querySelector("#show-debug")?.addEventListener("click", showDebugInfo); | ||
document.querySelector("#reset-button")?.addEventListener("click", resetLocalStorage); | ||
|
||
export { showDebugTab }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,3 +345,7 @@ input:checked[type="checkbox"]::before{ | |
width: auto; | ||
} | ||
} | ||
|
||
.hidden { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters