Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/about-window/about-window.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
at DeviantArt</a></b></label>

<app-icon-button iconPath="home.png" title="Return to home"
(onButtonClick)="this.returnHome()"></app-icon-button>
(onButtonClick)="this.router.navigateByUrl(PathsEnum.HOME)"></app-icon-button>
</div>
</div>
7 changes: 3 additions & 4 deletions src/app/about-window/about-window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import {PathsEnum} from "../../model/enums/PathsEnum";
})
export class AboutWindowComponent {

protected readonly PathsEnum = PathsEnum;

constructor(
private readonly router: Router
public readonly router: Router
) {
}

public async returnHome(): Promise<void> {
await this.router.navigateByUrl(PathsEnum.HOME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<app-icon-button iconPath="copy.png" title="Share result" [copy-clipboard]="this.clipboardText"
(onButtonClick)="this.showClipboardMessage()"></app-icon-button>
<app-icon-button iconPath="home.png" title="Return to home"
(onButtonClick)="this.returnHome()"></app-icon-button>
(onButtonClick)="this.router.navigateByUrl(PathsEnum.HOME);"></app-icon-button>
</div>
<div *ngIf="this.displayClipboardMessage">
<label class="window-body_clipboard-text">Question result copied to clipboard!</label>
Expand Down
10 changes: 4 additions & 6 deletions src/app/correct-answer-window/correct-answer-window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import {GameMode} from "../../model/enums/GameModesEnum";
})
export class CorrectAnswerWindowComponent implements OnInit {

protected readonly PathsEnum = PathsEnum;

public questionScore: number = 0;
public clipboardText: string = '';
public displayClipboardMessage: boolean = false;

private correctAnswerSound: HTMLAudioElement = new Audio('assets/sounds/tada.wav');

constructor(
private readonly router: Router,
protected readonly router: Router,
private readonly route: ActivatedRoute,
private readonly encryptionService: EncryptionService,
private readonly templateService: TemplateService,
Expand All @@ -33,18 +35,14 @@ export class CorrectAnswerWindowComponent implements OnInit {
await this.retrieveRouteParams();

if (!this.appStorageService.canQuizBeAnswered()) {
await this.returnHome();
await this.router.navigateByUrl(PathsEnum.HOME);
return;
}

await this.correctAnswerSound.play();
this.saveCurrentScore();
}

public async returnHome(): Promise<void> {
await this.router.navigateByUrl(PathsEnum.HOME);
}

public async showClipboardMessage(): Promise<void> {
this.displayClipboardMessage = true;

Expand Down
6 changes: 3 additions & 3 deletions src/app/main-window/main-window.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

<div class="window-body_buttons">
<app-icon-button iconPath="quiz.png" title="New quiz"
(onButtonClick)="this.redirectTo(PathsEnum.GAME_MODE)"
(onButtonClick)="this.router.navigateByUrl(PathsEnum.GAME_MODE)"
[disabled]="!this.quizCanBeAnswered"></app-icon-button>
<app-icon-button iconPath="score.png" title="My score"
(onButtonClick)="this.redirectTo(PathsEnum.SCORES)"></app-icon-button>
(onButtonClick)="this.router.navigateByUrl(PathsEnum.SCORES)"></app-icon-button>
<app-icon-button iconPath="about.png" title="About"
(onButtonClick)="this.redirectTo(PathsEnum.ABOUT)"></app-icon-button>
(onButtonClick)="this.router.navigateByUrl(PathsEnum.ABOUT)"></app-icon-button>
</div>
</div>
</div>
6 changes: 1 addition & 5 deletions src/app/main-window/main-window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class MainWindowComponent implements OnInit {
protected readonly PathsEnum = PathsEnum;

constructor(
private readonly router: Router,
protected readonly router: Router,
private readonly appStorageService: AppStorageService
) {
}
Expand All @@ -30,10 +30,6 @@ export class MainWindowComponent implements OnInit {
this.startCountdown();
}

public async redirectTo(route: PathsEnum): Promise<void> {
await this.router.navigateByUrl(route);
}

private async startCountdown(): Promise<void> {
const appStorage: AppStorage = this.appStorageService.retrieveAppStorage();

Expand Down
2 changes: 1 addition & 1 deletion src/app/score-window/score-window.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<app-icon-button iconPath="copy.png" title="Share score" [copy-clipboard]="this.clipboardText"
(click)="this.showClipboardMessage()"></app-icon-button>
<app-icon-button iconPath="home.png" title="Return to home"
(onButtonClick)="this.returnHome()"></app-icon-button>
(onButtonClick)="this.router.navigateByUrl(PathsEnum.HOME)"></app-icon-button>
</div>
<div *ngIf="this.displayClipboardMessage">
<label class="window-body_clipboard-text">Score copied to clipboard!</label>
Expand Down
8 changes: 3 additions & 5 deletions src/app/score-window/score-window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ScoreWindowComponent implements OnInit {
public displayClipboardMessage: boolean = false;

constructor(
private readonly router: Router,
protected readonly router: Router,
private readonly templateService: TemplateService,
private readonly appStorageService: AppStorageService
) {
Expand All @@ -33,10 +33,6 @@ export class ScoreWindowComponent implements OnInit {
await this.assembleClipboardText();
}

public async returnHome(): Promise<void> {
await this.router.navigateByUrl(PathsEnum.HOME);
}

public async showClipboardMessage(): Promise<void> {
this.displayClipboardMessage = true;

Expand Down Expand Up @@ -75,4 +71,6 @@ export class ScoreWindowComponent implements OnInit {
this.currentYear = currentYear;
this.currentWeek = currentWeek;
}

protected readonly PathsEnum = PathsEnum;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<app-icon-button iconPath="copy.png" title="Share result" [copy-clipboard]="this.clipboardText"
(onButtonClick)="this.showClipboardMessage()"></app-icon-button>
<app-icon-button iconPath="home.png" title="Return to home"
(onButtonClick)="this.returnHome()"></app-icon-button>
(onButtonClick)="this.router.navigateByUrl(PathsEnum.HOME)"></app-icon-button>
</div>
<div *ngIf="this.displayClipboardMessage">
<label class="window-body_clipboard-text">Question result copied to clipboard!</label>
Expand Down
10 changes: 4 additions & 6 deletions src/app/wrong-answer-window/wrong-answer-window.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class WrongAnswerWindowComponent implements OnInit {
private wrongAnswerSound: HTMLAudioElement = new Audio('assets/sounds/critical_stop.wav');

constructor(
private readonly router: Router,
protected readonly router: Router,
private readonly route: ActivatedRoute,
private readonly encryptionService: EncryptionService,
private readonly templateService: TemplateService,
Expand All @@ -34,18 +34,14 @@ export class WrongAnswerWindowComponent implements OnInit {
await this.retrieveRouteParams();

if (!this.appStorageService.canQuizBeAnswered()) {
await this.returnHome();
await this.router.navigateByUrl(PathsEnum.HOME);
return;
}

await this.wrongAnswerSound.play();
this.saveCurrentScore();
}

public async returnHome(): Promise<void> {
await this.router.navigateByUrl(PathsEnum.HOME);
}

public async showClipboardMessage(): Promise<void> {
this.displayClipboardMessage = true;

Expand All @@ -71,4 +67,6 @@ export class WrongAnswerWindowComponent implements OnInit {
this.correctAnswers = 'questions' in questionResult ? questionResult.correctAnswers : [questionResult.rightAnswer];
this.clipboardText = await this.templateService.render(gameMode.templateEnum, questionResult);
}

protected readonly PathsEnum = PathsEnum;
}