Skip to content

Commit

Permalink
Fixed: AudioRecorder did not request confirmation on page leave if re…
Browse files Browse the repository at this point in the history
…corder is not ready to leave.
  • Loading branch information
klausj committed Apr 21, 2022
1 parent 8524f08 commit bd68cc1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This project was generated with [Angular CLI](https://github.com/angular/angular

### Install NPM package
Speechrecorder module is available as NPM package.
Add `"speechrecorderng": "2.23.7"` to the `dependencies` array property in the `package.json` file of your application. Run `npm install` to install the package.
Add `"speechrecorderng": "2.23.9"` to the `dependencies` array property in the `package.json` file of your application. Run `npm install` to install the package.
### Module integration
Add SpeechRecorderNg module to imports property of your `AppModule` annotation. The module main component `SpeechRecorder` should be activated by an Angular route.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-speech-recorder-ng",
"version": "2.23.8",
"version": "2.23.9",
"author": {
"name": "Klaus Jänsch",
"email": "klausj@phonetik.uni-muenchen.de"
Expand Down
2 changes: 1 addition & 1 deletion projects/speechrecorderng/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "speechrecorderng",
"version": "2.23.8",
"version": "2.23.9",
"peerDependencies": {
"@angular/animations": "~13.3.2",
"@angular/cdk": "~13.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,33 @@ export class AudioRecorderComponent extends RecorderComponent implements OnInit
this.controlAudioPlayer = new AudioPlayer(audioContext,this.ar);
}
this.ar.controlAudioPlayer=this.controlAudioPlayer;

//TODO Duplicate code in SpeechRecorderComponent
window.addEventListener('beforeunload', (e) => {
console.debug("Before page unload event");

if (this.ready()) {
return;
} else {
// all this attempts to customize the message do not work anymore (for security reasons)!!
var message = "Please do not leave the page, until all recordings are uploaded!";
alert(message);
e = e || window.event;

if (e) {
e.returnValue = message;
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
if (e.preventDefault) {
e.preventDefault();
}
}

return message;
}
});
}

ngAfterViewInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export class SpeechrecorderngComponent extends RecorderComponent implements OnIn
this.uploader.listener = (ue) => {
this.uploadUpdate(ue);
}

//TODO Duplicate code in AudioRecorderComponent
window.addEventListener('beforeunload', (e) => {
console.debug("Before page unload event");

Expand Down
2 changes: 1 addition & 1 deletion projects/speechrecorderng/src/lib/spr.module.version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION='2.23.8'
export const VERSION='2.23.9'

0 comments on commit bd68cc1

Please sign in to comment.