js/replayviewer.js
/**
         * Creates a new ReplayViewer inside the given `container` element.
         * @param container Element that should contain the viewer.
         */
Creates a new ReplayViewer inside the given `container` element.
@param container Element that should contain the viewer.
Creates a new ReplayViewer inside the given ` container ` element . @param container Element that should contain the viewer .
function ReplayViewer(container) {
            var _this = _super.call(this, container) || this;
            _this.saveTickInHash = true;
            _this.tick = -1;
            _this.playbackRate = 1.0;
            _this.autoRepeat = true;
            _this.isScrubbing = false;
            _this.isPlaying = false;
            _this.showCrosshair = true;
            _this.showKeyDisplay = true;
            _this.showOptions = false;
            _this.replayLoaded = new Gokz.Event(_this);
            _this.updated = new Gokz.Event(_this);
            _this.tickChanged = new Gokz.ChangedEvent(_this);
            _this.playbackSkipped = new Gokz.Event(_this);
            _this.playbackRateChanged = new Gokz.ChangedEvent(_this);
            _this.isPlayingChanged = new Gokz.ChangedEvent(_this);
            _this.showCrosshairChanged = new Gokz.ChangedEvent(_this);
            _this.showKeyDisplayChanged = new Gokz.ChangedEvent(_this);
            _this.showOptionsChanged = new Gokz.ChangedEvent(_this);
            _this.cameraModeChanged = new Gokz.ChangedEvent(_this);
            _this.pauseTime = 1.0;
            _this.spareTime = 0;
            _this.prevTick = undefined;
            _this.ignoreMouseUp = true;
            _this.saveCameraPosInHash = false;
            _this.controls = new Gokz.ReplayControls(_this);
            _this.keyDisplay = new Gokz.KeyDisplay(_this, _this.controls.playbackBarElem);
            _this.options = new Gokz.OptionsMenu(_this, _this.controls.playbackBarElem);
            var crosshair = document.createElement("div");
            crosshair.classList.add("crosshair");
            container.appendChild(crosshair);
            _this.showCrosshairChanged.addListener(function (showCrosshair) {
                crosshair.hidden = !showCrosshair;
            });
            _this.isPlayingChanged.addListener(function (isPlaying) {
                if (!isPlaying && _this.saveTickInHash)
                    _this.updateTickHash();
                if (isPlaying) {
                    _this.wakeLock = navigator.wakeLock;
                    if (_this.wakeLock != null) {
                        _this.wakeLock.request("display");
                    }
                    _this.cameraMode = SourceUtils.CameraMode.Fixed;
                }
                else if (_this.wakeLock != null) {
                    _this.wakeLock.release("display");
                    _this.wakeLock = null;
                }
            });
            _this.cameraModeChanged.addListener(function (mode) {
                if (mode === SourceUtils.CameraMode.FreeCam) {
                    _this.isPlaying = false;
                }
                if (_this.routeLine != null) {
                    _this.routeLine.visible = mode === SourceUtils.CameraMode.FreeCam;
                }
                _this.canLockPointer = mode === SourceUtils.CameraMode.FreeCam;
                if (!_this.canLockPointer && _this.isPointerLocked()) {
                    document.exitPointerLock();
                }
            });
            return _this;
        }
function ReplayViewer ( container ) { var _this = _super . call ( this , container ) || this ; _this . saveTickInHash = true ; _this . tick = - 1 ; _this . playbackRate = 1.0 ; _this . autoRepeat = true ; _this . isScrubbing = false ; _this . isPlaying = false ; _this . showCrosshair = true ; _this . showKeyDisplay = true ; _this . showOptions = false ; _this . replayLoaded = new Gokz . Event ( _this ) ; _this . updated = new Gokz . Event ( _this ) ; _this . tickChanged = new Gokz . ChangedEvent ( _this ) ; _this . playbackSkipped = new Gokz . Event ( _this ) ; _this . playbackRateChanged = new Gokz . ChangedEvent ( _this ) ; _this . isPlayingChanged = new Gokz . ChangedEvent ( _this ) ; _this . showCrosshairChanged = new Gokz . ChangedEvent ( _this ) ; _this . showKeyDisplayChanged = new Gokz . ChangedEvent ( _this ) ; _this . showOptionsChanged = new Gokz . ChangedEvent ( _this ) ; _this . cameraModeChanged = new Gokz . ChangedEvent ( _this ) ; _this . pauseTime = 1.0 ; _this . spareTime = 0 ; _this . prevTick = undefined ; _this . ignoreMouseUp = true ; _this . saveCameraPosInHash = false ; _this . controls = new Gokz . ReplayControls ( _this ) ; _this . keyDisplay = new Gokz . KeyDisplay ( _this , _this . controls . playbackBarElem ) ; _this . options = new Gokz . OptionsMenu ( _this , _this . controls . playbackBarElem ) ; var crosshair = document . createElement ( "div" ) ; crosshair . classList . add ( "crosshair" ) ; container . appendChild ( crosshair ) ; _this . showCrosshairChanged . addListener ( function ( showCrosshair ) { crosshair . hidden = ! showCrosshair ; } ) ; _this . isPlayingChanged . addListener ( function ( isPlaying ) { if ( ! isPlaying && _this . saveTickInHash ) _this . updateTickHash ( ) ; if ( isPlaying ) { _this . wakeLock = navigator . wakeLock ; if ( _this . wakeLock != null ) { _this . wakeLock . request ( "display" ) ; } _this . cameraMode = SourceUtils . CameraMode . Fixed ; } else if ( _this . wakeLock != null ) { _this . wakeLock . release ( "display" ) ; _this . wakeLock = null ; } } ) ; _this . cameraModeChanged . addListener ( function ( mode ) { if ( mode === SourceUtils . CameraMode . FreeCam ) { _this . isPlaying = false ; } if ( _this . routeLine != null ) { _this . routeLine . visible = mode === SourceUtils . CameraMode . FreeCam ; } _this . canLockPointer = mode === SourceUtils . CameraMode . FreeCam ; if ( ! _this . canLockPointer && _this . isPointerLocked ( ) ) { document . exitPointerLock ( ) ; } } ) ; return _this ; }
Creates a new ReplayViewer inside the given `container` element.
Creates a new ReplayViewer inside the given ` container ` element .
/**
             * If true, the current tick will be stored in the address hash when
             * playback is paused or the viewer uses the playback bar to skip
             * around.
             * @default `true`
             */ /**
             * The current tick being shown during playback, starting with 0 for
             * the first tick. Will automatically be increased while playing,
             * although some ticks might be skipped depending on playback speed and
             * frame rate. Can be set to skip to a particular tick.
             */ /**
             * Current playback rate, measured in seconds per second. Can support
             * negative values for rewinding.
             * @default `1.0`
             */ /**
             * If true, the replay will automatically loop back to the first tick
             * when it reaches the end.
             * @default `true`
             */ /**
             * Used internally to temporarily pause playback while the user is
             * dragging the scrubber in the playback bar.
             */ /**
             * If true, the currently displayed tick will advance based on the
             * value of `playbackRate`.
             * @default `false`
             */ /**
             * If true, a crosshair graphic will be displayed in the middle of the
             * viewer.
             * @default `true`
             */ /**
             * If true, makes the key press display visible.
             * @default `true`
             */ /**
             * If true, makes the options menu visible.
             * @default `false`
             */ /**
             * Event invoked when a new replay is loaded. Will be invoked before
             * the map for the replay is loaded (if required).
             *
             * **Available event arguments**:
             * * `replay: Gokz.ReplayFile` - The newly loaded ReplayFile
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */ /**
             * Event invoked after each update.
             *
             * **Available event arguments**:
             * * `dt: number` - Time since the last update
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */ /**
             * Event invoked when the current tick has changed.
             *
             * **Available event arguments**:
             * * `tickData: Gokz.TickData` - Recorded data for the current tick
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */ /**
             * Event invoked when playback has skipped to a different tick, for
             * example when the user uses the scrubber.
             *
             * **Available event arguments**:
             * * `oldTick: number` - The previous value of `tick` before skipping
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */ /**
             * Event invoked when `playbackRate` changes.
             *
             * **Available event arguments**:
             * * `playbackRate: number` - The new playback rate
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */ /**
             * Event invoked when `isPlaying` changes, for example when the user
             * pauses or resumes playback.
             *
             * **Available event arguments**:
             * * `isPlaying: boolean` - True if currently playing
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */ /**
             * Event invoked when `showCrosshair` changes.
             *
             * **Available event arguments**:
             * * `showCrosshair: boolean` - True if crosshair is now visible
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */ /**
             * Event invoked when `showKeyDisplay` changes.
             *
             * **Available event arguments**:
             * * `showKeyDisplay: boolean` - True if keyDisplay is now visible
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */ /**
             * Event invoked when `showOptions` changes.
             *
             * **Available event arguments**:
             * * `showOptions: boolean` - True if options menu is now visible
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */ /**
             * Event invoked when `cameraMode` changes.
             *
             * **Available event arguments**:
             * * `cameraMode: SourceUtils.CameraMode` - Camera mode value
             * * `sender: Gokz.ReplayViewer` - This ReplayViewer
             */