play the jumpscare audio with the img

master
Aevann 2024-10-28 23:07:08 +03:00
parent c6a7080776
commit e6ccb2ec2c
2 changed files with 4 additions and 4 deletions

View File

@ -1,11 +1,11 @@
// Jump scare function
function scare() {
const image = document.getElementById("jumpscare-img");
image.style.display = "block";
const jumpscare_audio = document.getElementById('jumpscare-audio')
jumpscare_audio.play();
const image = document.getElementById("jumpscare-img");
image.style.display = "block";
// Hide image and reset sound
setTimeout(function() {
image.style.display = "none";

View File

@ -39,7 +39,7 @@
{% set image_src = SITE_FULL_IMAGES ~ "/assets/events/homoween/images/jumpscares/" ~ listdir("files/assets/events/homoween/images/jumpscares")|random ~ "?x=45" %}
<img src="{{image_src}}" id="jumpscare-img" style="display: none">
{% set audio_src = "/assets/events/homoween/audio/jumpscares/" ~ listdir("files/assets/events/homoween/audio/jumpscares")|random ~ "?x=45" %}
<audio id="jumpscare-audio" src="{{audio_src}}"></audio>
<audio id="jumpscare-audio" preload="auto" src="{{audio_src}}"></audio>
<script defer src="{{'events/homoween/js/jumpscare.js' | asset}}"></script>
{% endif %}