-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: add selfhosting view toggle
Preliminary commit to cater some feedback about its design and underlying JS code; will implement actual content modification later. Signed-off-by: Luca Zeuch <[email protected]>
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 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 |
---|---|---|
@@ -1 +1,29 @@ | ||
// Put your custom JS code here | ||
|
||
// self-hosting view. | ||
|
||
const storedSelfhost = localStorage.getItem('selfhost'); | ||
|
||
const getSelfhost = () => { | ||
if (storedSelfhost) { | ||
return storedSelfhost; | ||
} | ||
|
||
return 'no'; | ||
}; | ||
|
||
const setSelfhost = function (selfhost) { | ||
document.documentElement.setAttribute('data-bs-selfhost', selfhost); | ||
}; | ||
|
||
setSelfhost(getSelfhost()); | ||
|
||
window.addEventListener('DOMContentLoaded', () => { | ||
document.querySelectorAll('[data-bs-selfhost-value]').forEach((element) => { | ||
element.addEventListener('click', (event) => { | ||
const selfhost = element.getAttribute('data-bs-selfhost-value'); | ||
localStorage.setItem('selfhost', selfhost); | ||
setSelfhost(selfhost); | ||
}); | ||
} | ||
)}); |
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
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