Reformat sfx.core.js with tabs instead of spaces

This commit is contained in:
SrGooglo 2025-04-24 10:17:43 +00:00
parent 8e466fedf4
commit 681de1d5e7
2 changed files with 94 additions and 77 deletions

@ -1 +1 @@
Subproject commit ff38d45b9686ccbd2e902477bde4cd7eb7d251e8
Subproject commit 57d8b4bed14b0b35d1d9753847ac39710e0d9be5

View File

@ -21,7 +21,7 @@ export default class SFXCore extends Core {
this.play("test", {
volume: volume / 100,
})
}
},
}
async loadSoundpack(soundpack) {
@ -34,7 +34,7 @@ export default class SFXCore extends Core {
}
// check if is valid url with regex
const urlRegex = /^(http|https):\/\/[^ "]+$/;
const urlRegex = /^(http|https):\/\/[^ "]+$/
if (urlRegex.test(soundpack)) {
const { data } = await axios.get(soundpack)
@ -43,11 +43,15 @@ export default class SFXCore extends Core {
}
if (typeof soundpack.sounds !== "object") {
this.console.error(`Soundpack [${soundpack.id}] is not a valid soundpack.`)
this.console.error(
`Soundpack [${soundpack.id}] is not a valid soundpack.`,
)
return false
}
this.console.log(`Loading soundpack [${soundpack.id} | ${soundpack.name}] by ${soundpack.author} (${soundpack.version})`)
this.console.log(
`Loading soundpack [${soundpack.id} | ${soundpack.name}] by ${soundpack.author} (${soundpack.version})`,
)
for (const [name, path] of Object.entries(soundpack.sounds)) {
this.soundsPool[name] = new Howl({
@ -71,7 +75,9 @@ export default class SFXCore extends Core {
if (typeof options.volume !== "undefined") {
audioInstance.volume(options.volume)
} else {
audioInstance.volume((window.app.cores.settings.get("ui.general_volume") ?? 0) / 100)
audioInstance.volume(
(window.app.cores.settings.get("ui.general_volume") ?? 0) / 100,
)
}
audioInstance.play()
@ -79,7 +85,8 @@ export default class SFXCore extends Core {
async handleClick(event) {
// search for closest button
const button = event.target.closest("button") || event.target.closest(".ant-btn")
const button =
event.target.closest("button") || event.target.closest(".ant-btn")
// search for a slider
const slider = event.target.closest("input[type=range]")
@ -87,7 +94,11 @@ export default class SFXCore extends Core {
// if button exist and has aria-checked attribute then play switch_on or switch_off
if (button) {
if (button.hasAttribute("aria-checked")) {
return this.play(button.getAttribute("aria-checked") === "true" ? "component.switch_off" : "component.switch_on")
return this.play(
button.getAttribute("aria-checked") === "true"
? "component.switch_off"
: "component.switch_on",
)
}
return this.play("generic_click")
@ -102,6 +113,12 @@ export default class SFXCore extends Core {
async onInitialize() {
await this.loadSoundpack()
document.addEventListener("click", (...args) => { this.handleClick(...args) }, true)
document.addEventListener(
"click",
(...args) => {
this.handleClick(...args)
},
true,
)
}
}