style: fix formatting and add missing commas in code
All checks were successful
CI / Get Changed Files (pull_request) Successful in 10s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 26s
CI / eslint (pull_request) Successful in 39s
CI / prettier (pull_request) Successful in 30s
CI / Docker frontend validation (pull_request) Successful in 57s
CI / test-build (pull_request) Successful in 42s
All checks were successful
CI / Get Changed Files (pull_request) Successful in 10s
CI / Checkstyle Main (pull_request) Has been skipped
CI / Docker backend validation (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 26s
CI / eslint (pull_request) Successful in 39s
CI / prettier (pull_request) Successful in 30s
CI / Docker frontend validation (pull_request) Successful in 57s
CI / test-build (pull_request) Successful in 42s
This commit is contained in:
parent
5809757bc9
commit
6d353cc202
5 changed files with 24 additions and 18 deletions
|
@ -21,11 +21,11 @@ import { SoundInitializerService } from './shared/services/sound-initializer.ser
|
||||||
PlaySoundDirective,
|
PlaySoundDirective,
|
||||||
],
|
],
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
hostDirectives: [PlaySoundDirective]
|
hostDirectives: [PlaySoundDirective],
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
private soundInitializer = inject(SoundInitializerService);
|
private soundInitializer = inject(SoundInitializerService);
|
||||||
|
|
||||||
showLogin = signal(false);
|
showLogin = signal(false);
|
||||||
showRegister = signal(false);
|
showRegister = signal(false);
|
||||||
showRecoverPassword = signal(false);
|
showRecoverPassword = signal(false);
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { AudioService } from '../services/audio.service';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[appPlaySound]',
|
selector: '[appPlaySound]',
|
||||||
standalone: true
|
standalone: true,
|
||||||
})
|
})
|
||||||
export class PlaySoundDirective {
|
export class PlaySoundDirective {
|
||||||
private audioService = inject(AudioService);
|
private audioService = inject(AudioService);
|
||||||
|
@ -12,4 +12,4 @@ export class PlaySoundDirective {
|
||||||
onClick() {
|
onClick() {
|
||||||
this.audioService.playBetSound();
|
this.audioService.playBetSound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class AudioService {
|
export class AudioService {
|
||||||
private audioCache = new Map<string, HTMLAudioElement>();
|
private audioCache = new Map<string, HTMLAudioElement>();
|
||||||
|
@ -18,12 +18,12 @@ export class AudioService {
|
||||||
playBetSound(): void {
|
playBetSound(): void {
|
||||||
const audio = this.getAudio('bet.mp3');
|
const audio = this.getAudio('bet.mp3');
|
||||||
audio.currentTime = 0;
|
audio.currentTime = 0;
|
||||||
audio.play().catch(error => console.error('Error playing bet sound:', error));
|
audio.play().catch((error) => console.error('Error playing bet sound:', error));
|
||||||
}
|
}
|
||||||
|
|
||||||
playWinSound(): void {
|
playWinSound(): void {
|
||||||
const audio = this.getAudio('win.mp3');
|
const audio = this.getAudio('win.mp3');
|
||||||
audio.currentTime = 0;
|
audio.currentTime = 0;
|
||||||
audio.play().catch(error => console.error('Error playing win sound:', error));
|
audio.play().catch((error) => console.error('Error playing win sound:', error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Injectable, Renderer2, RendererFactory2 } from '@angular/core';
|
import { Injectable, Renderer2, RendererFactory2 } from '@angular/core';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class SoundInitializerService {
|
export class SoundInitializerService {
|
||||||
private renderer: Renderer2;
|
private renderer: Renderer2;
|
||||||
|
@ -9,7 +9,7 @@ export class SoundInitializerService {
|
||||||
|
|
||||||
constructor(rendererFactory: RendererFactory2) {
|
constructor(rendererFactory: RendererFactory2) {
|
||||||
this.renderer = rendererFactory.createRenderer(null, null);
|
this.renderer = rendererFactory.createRenderer(null, null);
|
||||||
|
|
||||||
this.observer = new MutationObserver((mutations) => {
|
this.observer = new MutationObserver((mutations) => {
|
||||||
mutations.forEach((mutation) => {
|
mutations.forEach((mutation) => {
|
||||||
mutation.addedNodes.forEach((node) => {
|
mutation.addedNodes.forEach((node) => {
|
||||||
|
@ -22,7 +22,7 @@ export class SoundInitializerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
document.querySelectorAll('button, a').forEach(element => {
|
document.querySelectorAll('button, a').forEach((element) => {
|
||||||
if (!element.hasAttribute('appPlaySound')) {
|
if (!element.hasAttribute('appPlaySound')) {
|
||||||
this.renderer.setAttribute(element, 'appPlaySound', '');
|
this.renderer.setAttribute(element, 'appPlaySound', '');
|
||||||
}
|
}
|
||||||
|
@ -30,19 +30,22 @@ export class SoundInitializerService {
|
||||||
|
|
||||||
this.observer.observe(document.body, {
|
this.observer.observe(document.body, {
|
||||||
childList: true,
|
childList: true,
|
||||||
subtree: true
|
subtree: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private processElement(element: HTMLElement) {
|
private processElement(element: HTMLElement) {
|
||||||
if ((element.tagName === 'BUTTON' || element.tagName === 'A') && !element.hasAttribute('appPlaySound')) {
|
if (
|
||||||
|
(element.tagName === 'BUTTON' || element.tagName === 'A') &&
|
||||||
|
!element.hasAttribute('appPlaySound')
|
||||||
|
) {
|
||||||
this.renderer.setAttribute(element, 'appPlaySound', '');
|
this.renderer.setAttribute(element, 'appPlaySound', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
element.querySelectorAll('button, a').forEach(child => {
|
element.querySelectorAll('button, a').forEach((child) => {
|
||||||
if (!child.hasAttribute('appPlaySound')) {
|
if (!child.hasAttribute('appPlaySound')) {
|
||||||
this.renderer.setAttribute(child, 'appPlaySound', '');
|
this.renderer.setAttribute(child, 'appPlaySound', '');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,14 +175,17 @@ a {
|
||||||
@apply bg-deep-blue-light/50 hover:bg-deep-blue-light w-full py-2.5 my-2 border border-deep-blue-light/30 hover:border-deep-blue-light/50;
|
@apply bg-deep-blue-light/50 hover:bg-deep-blue-light w-full py-2.5 my-2 border border-deep-blue-light/30 hover:border-deep-blue-light/50;
|
||||||
}
|
}
|
||||||
|
|
||||||
button, a {
|
button,
|
||||||
|
a {
|
||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
button[appPlaySound], a[appPlaySound] {
|
button[appPlaySound],
|
||||||
|
a[appPlaySound] {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:not([appPlaySound]), a:not([appPlaySound]) {
|
button:not([appPlaySound]),
|
||||||
|
a:not([appPlaySound]) {
|
||||||
--add-sound-directive: true;
|
--add-sound-directive: true;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue