diff --git a/_data/i18n.js b/_data/i18n.js index ab17402..6189f42 100644 --- a/_data/i18n.js +++ b/_data/i18n.js @@ -69,6 +69,7 @@ module.exports = { by: "by", back: "back", hideBackground: "Hide background", + disableSoundEffects: "Disable sound effects", options: "Options", alsoAvailableAsVideo: "Also available as video", websiteDescription: "Personal website/blog of Adrian Victor.", @@ -124,6 +125,7 @@ module.exports = { by: "por", back: "voltar", hideBackground: "Esconder imagem de fundo", + disableSoundEffects: "Desabilitar efeitos sonoros", options: "Opções", alsoAvailableAsVideo: "Também disponível em vídeo", websiteDescription: "Website/blog pessoal de Adrian Victor.", diff --git a/_includes/base.njk b/_includes/base.njk index 28fb5d7..b25667b 100644 --- a/_includes/base.njk +++ b/_includes/base.njk @@ -20,6 +20,7 @@ + diff --git a/_includes/header.njk b/_includes/header.njk index 29d6f22..704f163 100644 --- a/_includes/header.njk +++ b/_includes/header.njk @@ -12,6 +12,7 @@ permissionIssue: "{{ i18n[langKey].permissionIssue | safe }}", permissionIssueNotificationContent: "{{ i18n[langKey].permissionIssueNotificationContent | safe }}", notificationDefaultHint: "{{ i18n[langKey].notificationDefaultHint | safe }}", + disableSoundEffects: "{{ i18n[langKey].disableSoundEffects | safe }}" } diff --git a/static/audio/click.ogg b/static/audio/click.ogg new file mode 100644 index 0000000..c0c8461 Binary files /dev/null and b/static/audio/click.ogg differ diff --git a/static/audio/hover.ogg b/static/audio/hover.ogg new file mode 100644 index 0000000..45a0cc1 Binary files /dev/null and b/static/audio/hover.ogg differ diff --git a/static/main.css b/static/main.css index 5db40e4..faf6687 100644 --- a/static/main.css +++ b/static/main.css @@ -256,9 +256,9 @@ li.inlineList { #defaultSquare { transition: 0.4s; border: medium solid white; - height: 7vh; + height: 3vw; overflow: hidden; - width: 10vh; + width: 6vw; opacity: 0.4; padding: 0.4em; cursor: pointer; @@ -279,7 +279,7 @@ li.inlineList { .headerSquare.selected, #defaultSquare.selected { opacity: 1; - height: 10vh; + height: 6vw; box-shadow: 2px 7px 5px rgba(0, 0, 0, 0.4), 0px -4px 10px rgba(0, 0, 0, 0.4); background-color: rgba(0, 0, 0, 0.3); } diff --git a/static/scripts/click.js b/static/scripts/click.js new file mode 100644 index 0000000..2fc6cc1 --- /dev/null +++ b/static/scripts/click.js @@ -0,0 +1,26 @@ +/* +This script plays a sound when user clicks on the page. +*/ + +const click = new Audio(`${rootPrefix}static/audio/click.ogg`); +const hover = new Audio(`${rootPrefix}static/audio/hover.ogg`); +click.preload = "auto"; +hover.preload = "auto"; +click.volume = 0.5; +hover.volume = 0.5; + + +document.body.addEventListener("click", () => { + if (localStorage.getItem("disablesfx") == 'true') return; + + click.currentTime = 0; + click.play().catch(() => {}); +}); + +document.querySelectorAll('a').forEach(link => { + link.addEventListener("mouseenter", () => { + if (localStorage.getItem("disablesfx") == 'true') return; + hover.currentTime = 0; + hover.play().catch(() => {}); + }) +}) diff --git a/static/scripts/music.js b/static/scripts/music.js index da8e108..c8d0f6e 100644 --- a/static/scripts/music.js +++ b/static/scripts/music.js @@ -49,6 +49,10 @@ optionsAside.classList.add("metromenu");

${headeri18n.hideBackground}

+
+

${headeri18n.disableSoundEffects}

+ +
` optionsAside.appendChild(content); @@ -76,6 +80,12 @@ function toggleBG() { localStorage.setItem("bgHidden", bg.classList.contains("invisible")) } +const disableSFX = document.querySelector("input#soundEffects"); +if (localStorage.getItem("disablesfx") === "true") disableSFX.checked = true; +disableSFX.addEventListener("click", () => { + localStorage.setItem("disablesfx", disableSFX.checked) +}) + const songsDrawer = document.querySelector("#songDrawer"); const drawerSongs = []; const playlist = document.querySelector("#playlist");