Use CustomEvent for playback events
Stop abusing Event as that doesn't work everwhere.
This commit is contained in:
parent
568f6567e1
commit
e35570227c
|
@ -141,16 +141,18 @@ class IterationPlayer {
|
||||||
const endTime = (new Date()).getTime();
|
const endTime = (new Date()).getTime();
|
||||||
const totalDuration = endTime - this._start_time;
|
const totalDuration = endTime - this._start_time;
|
||||||
|
|
||||||
const evt = new Event('finish');
|
const evt = new CustomEvent('finish',
|
||||||
evt.duration = totalDuration;
|
{ detail:
|
||||||
evt.iterations = this._iterations;
|
{ duration: totalDuration,
|
||||||
|
iterations: this._iterations } } );
|
||||||
this.onfinish(evt);
|
this.onfinish(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
_iterationFinish(duration) {
|
_iterationFinish(duration) {
|
||||||
const evt = new Event('iterationfinish');
|
const evt = new CustomEvent('iterationfinish',
|
||||||
evt.duration = duration;
|
{ detail:
|
||||||
evt.number = this._iteration;
|
{ duration: duration,
|
||||||
|
number: this._iteration } } );
|
||||||
this.oniterationfinish(evt);
|
this.oniterationfinish(evt);
|
||||||
|
|
||||||
this._nextIteration();
|
this._nextIteration();
|
||||||
|
@ -161,11 +163,11 @@ class IterationPlayer {
|
||||||
this._state = 'failed';
|
this._state = 'failed';
|
||||||
}
|
}
|
||||||
|
|
||||||
const evt = new Event('rfbdisconnected');
|
const evt = new CustomEvent('rfbdisconnected',
|
||||||
evt.clean = clean;
|
{ detail:
|
||||||
evt.frame = frame;
|
{ clean: clean,
|
||||||
evt.iteration = this._iteration;
|
frame: frame,
|
||||||
|
iteration: this._iteration } } );
|
||||||
this.onrfbdisconnected(evt);
|
this.onrfbdisconnected(evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,16 +190,16 @@ function start() {
|
||||||
|
|
||||||
const player = new IterationPlayer(iterations, frames);
|
const player = new IterationPlayer(iterations, frames);
|
||||||
player.oniterationfinish = (evt) => {
|
player.oniterationfinish = (evt) => {
|
||||||
message(`Iteration ${evt.number} took ${evt.duration}ms`);
|
message(`Iteration ${evt.detail.number} took ${evt.detail.duration}ms`);
|
||||||
};
|
};
|
||||||
player.onrfbdisconnected = (evt) => {
|
player.onrfbdisconnected = (evt) => {
|
||||||
if (!evt.clean) {
|
if (!evt.detail.clean) {
|
||||||
message(`noVNC sent disconnected during iteration ${evt.iteration} frame ${evt.frame}`);
|
message(`noVNC sent disconnected during iteration ${evt.detail.iteration} frame ${evt.detail.frame}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
player.onfinish = (evt) => {
|
player.onfinish = (evt) => {
|
||||||
const iterTime = parseInt(evt.duration / evt.iterations, 10);
|
const iterTime = parseInt(evt.detail.duration / evt.detail.iterations, 10);
|
||||||
message(`${evt.iterations} iterations took ${evt.duration}ms (average ${iterTime}ms / iteration)`);
|
message(`${evt.detail.iterations} iterations took ${evt.detail.duration}ms (average ${iterTime}ms / iteration)`);
|
||||||
|
|
||||||
document.getElementById('startButton').disabled = false;
|
document.getElementById('startButton').disabled = false;
|
||||||
document.getElementById('startButton').value = "Start";
|
document.getElementById('startButton').value = "Start";
|
||||||
|
|
Loading…
Reference in New Issue