From b603bd7e4cef828fe0d6db343ab6c1ac16f71f2f Mon Sep 17 00:00:00 2001 From: aqua <84078890+phthallo@users.noreply.github.com> Date: Mon, 12 May 2025 18:03:06 -0400 Subject: [PATCH] global audio toggle --- app/javascript/application.js | 3 ++- app/views/landing/index.html.erb | 21 --------------------- app/views/layouts/application.html.erb | 3 ++- app/views/layouts/overview.html.erb | 2 ++ app/views/shared/_audio.html.erb | 19 +++++++++++++++++++ 5 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 app/views/shared/_audio.html.erb diff --git a/app/javascript/application.js b/app/javascript/application.js index bd3ce1f..61309ba 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -9,8 +9,9 @@ import "@rails/actiontext" const audio = new Audio('https://hc-cdn.hel1.your-objectstorage.com/s/v3/98df9f1054b50821b1d2208a7d3386a2408134be_d3bd3f0972d62d58cdfce91bc042d32ee643aa94_ui_button_confirm_audio__mp3cut.net__audio.mp4'); audio.volume = 0.5 document.addEventListener('click', (event) => { + var myAudio = document.getElementById('background-audio'); let el = event.target.closest('a.btn'); - if (el) { + if (el && ((myAudio && !myAudio.muted))) { audio.play(); } }); \ No newline at end of file diff --git a/app/views/landing/index.html.erb b/app/views/landing/index.html.erb index a7981d1..b922681 100644 --- a/app/views/landing/index.html.erb +++ b/app/views/landing/index.html.erb @@ -1,24 +1,3 @@ - - - -
- - - -
- <%= image_tag "/bg3.png", class: "absolute w-full h-screen h-full object-cover z-[-1] fixed opacity-20" %> Hack Club diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 54000a5..3f141ae 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -24,7 +24,8 @@ -
+ <%= render partial: "shared/audio" %> +
<%= render "shared/topbar" %> <% if show_sidebar? %> <%# render "shared/sidebar" %> diff --git a/app/views/layouts/overview.html.erb b/app/views/layouts/overview.html.erb index 38049f7..85be231 100644 --- a/app/views/layouts/overview.html.erb +++ b/app/views/layouts/overview.html.erb @@ -23,6 +23,8 @@ + <%= render partial: "shared/audio" %> +
diff --git a/app/views/shared/_audio.html.erb b/app/views/shared/_audio.html.erb new file mode 100644 index 0000000..0e4f123 --- /dev/null +++ b/app/views/shared/_audio.html.erb @@ -0,0 +1,19 @@ + + +
+ + + +
\ No newline at end of file