finish the (pretty dirty tbh, clean later) nonjs dropdowns

This commit is contained in:
Ruben 2024-10-01 12:11:47 -05:00
commit 9b66f37bd8
No known key found for this signature in database
4 changed files with 96 additions and 114 deletions

View file

@ -1,44 +1,3 @@
// dropdown menu for mobile users, used https://www.w3schools.com/howto/howto_js_dropdown.asp
// When the user clicks on the button,
// toggle between hiding and showing the dropdown content
function mobileDropdown() {
document.getElementById("dropdown-box").classList.toggle("show-dropdown");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.nav-baselink-mobile')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show-dropdown')) {
openDropdown.classList.remove('show-dropdown');
}
}
}
}
// Same snippet as above, but for the Table of Contents of button.
function tocDropdown() {
document.getElementById("toc-dropdown").classList.toggle("show-dropdown");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.toc-button')) {
var dropdowns = document.getElementsByClassName("toc-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show-dropdown')) {
openDropdown.classList.remove('show-dropdown');
}
}
}
}
// TODO: Replace the above(s) with CSS?
// snippet that copies the html for my button(s)
function copyButtonRegular() {
navigator.clipboard.writeText ('<a href="https://sneexy.pages.gay"><img src="https://sneexy.pages.gay/assets/buttons/sneexy.png" alt="Sneexy" title="Sneexy"></a>');