Last active
November 29, 2022 07:20
-
-
Save danielkwok21/c6544e52b8933f1cc870bdc3e3c5979e to your computer and use it in GitHub Desktop.
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
<script> | |
const params = new URLSearchParams(window.location.search) | |
const halalButtonEl = document.getElementById("halalButton") | |
let isFilterHalal = false | |
if (isFilterHalal) { | |
toggleHalalButton(false) | |
} else { | |
toggleHalalButton(true) | |
} | |
halalButtonEl.onclick = () => { | |
const posts = document.getElementsByClassName("ue_post_blocks_box") | |
if (isFilterHalal) { | |
toggleHalalButton(true) | |
for (let i = 0; i < posts.length; i++) { | |
const post = posts[i] | |
post.style.display = 'block' | |
} | |
} else { | |
toggleHalalButton(false) | |
for (let i = 0; i < posts.length; i++) { | |
const post = posts[i] | |
const toHide = !post.innerHTML.includes("Halal") | |
if (toHide) { | |
post.style.display = 'none' | |
} else { | |
post.style.display = 'visible' | |
} | |
} | |
} | |
isFilterHalal = !isFilterHalal | |
} | |
function toggleHalalButton(isToggled) { | |
if (isToggled) { | |
halalButtonEl.style.backgroundColor = 'white' | |
halalButtonEl.style.color = '#81b759' | |
} else { | |
halalButtonEl.style.backgroundColor = '#81b759' | |
halalButtonEl.style.color = 'white' | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment