Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroKaa committed Jun 15, 2021
1 parent eb63dae commit db6ab62
Show file tree
Hide file tree
Showing 29 changed files with 970,304 additions and 1 deletion.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
'use strict';

/* global BaseInstrument */
/* global registerInstrument */

// eslint-disable-next-line camelcase
class A32NX_ATC_Logic extends BaseInstrument {
constructor() {
super();
// eslint-disable-next-line no-underscore-dangle
let lastTime = this._lastTime;
this.getDeltaTime = () => {
const nowTime = Date.now();
const deltaTime = nowTime - lastTime;
lastTime = nowTime;

return deltaTime;
};
}

get templateID() {
return 'A32NX_ATC_TEMPLATE';
}

get isInteractive() {
// eslint-disable-next-line
return false;
}

get IsGlassCockpit() {
return true;
}

connectedCallback() {
super.connectedCallback();

// This is big hack, see `template.html`.
{
const code = document.getElementById('A32NX_BUNDLED_STYLE').innerHTML;
const style = document.createElement('style');
style.innerHTML = code;
document.head.appendChild(style);
}
{
const code = document.getElementById('A32NX_BUNDLED_LOGIC').innerHTML;
const script = document.createElement('script');
script.innerHTML = code;
document.body.appendChild(script);
}
}

Update() {
super.Update();
this.dispatchEvent(new CustomEvent('update', { detail: this.getDeltaTime() }));
}

onInteractionEvent(event) {
const eventName = String(event);
this.dispatchEvent(new CustomEvent(eventName));
this.dispatchEvent(new CustomEvent('*', { detail: eventName }));
}
}

registerInstrument('a32nx-atc-element', A32NX_ATC_Logic);
Loading

0 comments on commit db6ab62

Please sign in to comment.