Skip to content

Commit 406624a

Browse files
committed
chore: cleanup
1 parent 8b5d783 commit 406624a

File tree

3 files changed

+827
-1112
lines changed

3 files changed

+827
-1112
lines changed

hdw-a339x/src/base/headwindsim-aircraft-a330-900/html_ui/JS/A339X/A32NX_Util.js

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ A32NX_Util.createMachine = (machineDef) => {
4747
if (valid) {
4848
machine.value = newState;
4949
}
50-
},
50+
}
5151
};
5252
return machine;
5353
};
@@ -59,7 +59,7 @@ A32NX_Util.createMachine = (machineDef) => {
5959
* @returns magnetic heading
6060
*/
6161
A32NX_Util.trueToMagnetic = (heading, magVar) => {
62-
return (720 + heading - (magVar || SimVar.GetSimVarValue('MAGVAR', 'degree'))) % 360;
62+
return (720 + heading - (magVar || SimVar.GetSimVarValue("MAGVAR", "degree"))) % 360;
6363
};
6464

6565
/**
@@ -69,7 +69,7 @@ A32NX_Util.trueToMagnetic = (heading, magVar) => {
6969
* @returns true heading
7070
*/
7171
A32NX_Util.magneticToTrue = (heading, magVar) => {
72-
return (720 + heading + (magVar || SimVar.GetSimVarValue('MAGVAR', 'degree'))) % 360;
72+
return (720 + heading + (magVar || SimVar.GetSimVarValue("MAGVAR", "degree"))) % 360;
7373
};
7474

7575
/**
@@ -80,7 +80,7 @@ A32NX_Util.latLonToSpherical = (ll) => {
8080
return [
8181
Math.cos(ll.lat * Avionics.Utils.DEG2RAD) * Math.cos(ll.long * Avionics.Utils.DEG2RAD),
8282
Math.cos(ll.lat * Avionics.Utils.DEG2RAD) * Math.sin(ll.long * Avionics.Utils.DEG2RAD),
83-
Math.sin(ll.lat * Avionics.Utils.DEG2RAD),
83+
Math.sin(ll.lat * Avionics.Utils.DEG2RAD)
8484
];
8585
};
8686

@@ -174,9 +174,9 @@ A32NX_Util.getIsaTempDeviation = (alt = Simplane.getAltitude(), sat = Simplane.g
174174
};
175175

176176
/**
177-
* Get the magvar to use for radials from a wp.
177+
* Get the magvar to use for radials from a wp.
178178
* @param {VhfNavaid} facility The waypoint.
179-
*/
179+
*/
180180
A32NX_Util.getRadialMagVar = (facility) => {
181181
if (facility.subSectionCode === 0 /* VhfNavaid */) {
182182
if (facility.stationDeclination !== undefined) {
@@ -191,9 +191,10 @@ A32NX_Util.getRadialMagVar = (facility) => {
191191
* Utility class to throttle instrument updates
192192
*/
193193
class UpdateThrottler {
194+
194195
/**
195-
* @param {number} intervalMs Interval between updates, in milliseconds
196-
*/
196+
* @param {number} intervalMs Interval between updates, in milliseconds
197+
*/
197198
constructor(intervalMs) {
198199
this.intervalMs = intervalMs;
199200
this.currentTime = 0;
@@ -206,14 +207,14 @@ class UpdateThrottler {
206207
}
207208

208209
/**
209-
* Checks whether the instrument should be updated in the current frame according to the
210-
* configured update interval.
211-
*
212-
* @param {number} deltaTime
213-
* @param {boolean} [forceUpdate = false] - True if you want to force an update during this frame.
214-
* @returns -1 if the instrument should not update, or the time elapsed since the last
215-
* update in milliseconds
216-
*/
210+
* Checks whether the instrument should be updated in the current frame according to the
211+
* configured update interval.
212+
*
213+
* @param {number} deltaTime
214+
* @param {boolean} [forceUpdate = false] - True if you want to force an update during this frame.
215+
* @returns -1 if the instrument should not update, or the time elapsed since the last
216+
* update in milliseconds
217+
*/
217218
canUpdate(deltaTime, forceUpdate = false) {
218219
this.currentTime += deltaTime;
219220
const number = Math.floor((this.currentTime + this.refreshOffset) / this.intervalMs);
@@ -236,9 +237,9 @@ A32NX_Util.UpdateThrottler = UpdateThrottler;
236237
*/
237238
class NotificationParams {
238239
constructor() {
239-
this.__Type = 'SNotificationParams';
240+
this.__Type = "SNotificationParams";
240241
this.buttons = [];
241-
this.style = 'normal';
242+
this.style = "normal";
242243
this.displayGlobalPopup = true;
243244
}
244245
}
@@ -250,33 +251,33 @@ class NXPopUp {
250251
constructor() {
251252
this.params = new NotificationParams();
252253
this.popupListener;
253-
this.params.title = 'A339X POPUP';
254+
this.params.title = "HDW POPUP";
254255
this.params.time = new Date().getTime();
255-
this.params.id = this.params.title + '_' + this.params.time;
256-
this.params.contentData = 'Default Message';
257-
this.params.style = 'small';
258-
this.params.buttons.push(new NotificationButton('TT:MENU.YES', 'HDW_POP_' + this.params.id + '_YES'));
259-
this.params.buttons.push(new NotificationButton('TT:MENU.NO', 'HDW_POP_' + this.params.id + '_NO'));
256+
this.params.id = this.params.title + "_" + this.params.time;
257+
this.params.contentData = "Default Message";
258+
this.params.style = "small";
259+
this.params.buttons.push(new NotificationButton("TT:MENU.YES", "HDW_POP_" + this.params.id + "_YES"));
260+
this.params.buttons.push(new NotificationButton("TT:MENU.NO", "HDW_POP_" + this.params.id + "_NO"));
260261
}
261262

262263
_showPopUp(params) {
263264
try {
264265
Coherent.trigger('UNFOCUS_INPUT_FIELD'); // Needed to return focus back to camera if it has been taken elsewhere.
265266
SimVar.SetSimVarValue('A:COCKPIT CAMERA HEADLOOK', 'Enum', 2); // Toggles freelook off if it is on and forces on the mouse cursor
266-
Coherent.trigger('SHOW_POP_UP', params);
267+
Coherent.trigger("SHOW_POP_UP", params);
267268
} catch (e) {
268269
console.error(e);
269270
}
270271
}
271272

272273
/**
273-
* Show popup with given or already initiated parameters
274-
* @param {string} title Title for popup - will show in menu bar
275-
* @param {string} message Popup message
276-
* @param {string} style Style/Type of popup. Valid types are small|normal|big|big-help
277-
* @param {function} callbackYes Callback function -> YES button is clicked.
278-
* @param {function} callbackNo Callback function -> NO button is clicked.
279-
*/
274+
* Show popup with given or already initiated parameters
275+
* @param {string} title Title for popup - will show in menu bar
276+
* @param {string} message Popup message
277+
* @param {string} style Style/Type of popup. Valid types are small|normal|big|big-help
278+
* @param {function} callbackYes Callback function -> YES button is clicked.
279+
* @param {function} callbackNo Callback function -> NO button is clicked.
280+
*/
280281
showPopUp(title, message, style, callbackYes, callbackNo) {
281282
if (title) {
282283
this.params.title = title;
@@ -288,22 +289,22 @@ class NXPopUp {
288289
this.params.style = style;
289290
}
290291
if (callbackYes) {
291-
const yes = typeof callbackYes === 'function' ? callbackYes : () => callbackYes;
292+
const yes = (typeof callbackYes === "function") ? callbackYes : () => callbackYes;
292293
Coherent.on(`HDW_POP_${this.params.id}_YES`, () => {
293294
Coherent.off(`HDW_POP_${this.params.id}_YES`, null, null);
294295
yes();
295296
});
296297
}
297298
if (callbackNo) {
298-
const no = typeof callbackNo === 'function' ? callbackNo : () => callbackNo;
299+
const no = (typeof callbackNo === "function") ? callbackNo : () => callbackNo;
299300
Coherent.on(`HDW_POP_${this.params.id}_NO`, () => {
300301
Coherent.off(`HDW_POP_${this.params.id}_NO`, null, null);
301302
no();
302303
});
303304
}
304305

305306
if (!this.popupListener) {
306-
this.popupListener = RegisterViewListener('JS_LISTENER_POPUP', this._showPopUp.bind(null, this.params));
307+
this.popupListener = RegisterViewListener("JS_LISTENER_POPUP", this._showPopUp.bind(null, this.params));
307308
} else {
308309
this._showPopUp();
309310
}
@@ -315,21 +316,22 @@ class NXPopUp {
315316
*/
316317

317318
class NXNotifManager {
319+
318320
constructor() {
319-
Coherent.on('keyIntercepted', (key) => this.registerIntercepts(key));
320-
Coherent.call('INTERCEPT_KEY_EVENT', 'PAUSE_TOGGLE', 0);
321-
Coherent.call('INTERCEPT_KEY_EVENT', 'PAUSE_ON', 0);
322-
Coherent.call('INTERCEPT_KEY_EVENT', 'PAUSE_OFF', 0);
323-
Coherent.call('INTERCEPT_KEY_EVENT', 'PAUSE_SET', 0);
321+
Coherent.on("keyIntercepted", (key) => this.registerIntercepts(key));
322+
Coherent.call("INTERCEPT_KEY_EVENT", "PAUSE_TOGGLE", 0);
323+
Coherent.call("INTERCEPT_KEY_EVENT", "PAUSE_ON", 0);
324+
Coherent.call("INTERCEPT_KEY_EVENT", "PAUSE_OFF", 0);
325+
Coherent.call("INTERCEPT_KEY_EVENT", "PAUSE_SET", 0);
324326
this.notifications = [];
325327
}
326328

327329
registerIntercepts(key) {
328330
switch (key) {
329-
case 'PAUSE_TOGGLE':
330-
case 'PAUSE_ON':
331-
case 'PAUSE_OFF':
332-
case 'PAUSE_SET':
331+
case "PAUSE_TOGGLE":
332+
case "PAUSE_ON":
333+
case "PAUSE_OFF":
334+
case "PAUSE_SET":
333335
this.notifications.forEach((notif) => {
334336
notif.hideNotification();
335337
});
@@ -349,15 +351,15 @@ class NXNotifManager {
349351

350352
class NXNotif {
351353
constructor() {
352-
const title = 'A339X ALERT';
354+
const title = "HDW ALERT";
353355
this.time = new Date().getTime();
354356
this.params = {
355357
id: `${title}_${this.time}`,
356358
title,
357-
type: 'MESSAGE',
358-
theme: 'GAMEPLAY',
359-
image: 'IMAGE_NOTIFICATION',
360-
description: 'Default Message',
359+
type: "MESSAGE",
360+
theme: "GAMEPLAY",
361+
image: "IMAGE_NOTIFICATION",
362+
description: "Default Message",
361363
timeout: 10000,
362364
time: this.time,
363365
};
@@ -386,29 +388,29 @@ class NXNotif {
386388
}
387389

388390
/**
389-
* Show notification with given or already initiated parametrs.
390-
* @param {string} params.title Title for notification - will show as the message header
391-
* @param {string} params.type Type of Notification - Valid types are MESSAGE|SUBTITLES
392-
* @param {string} params.theme Theme of Notification. Valid types are TIPS|GAMEPLAY|SYSTEM
393-
* @param {string} params.image Notification image. Valid types are IMAGE_NOTIFICATION|IMAGE_SCORE
394-
* @param {string} params.message Notification message
395-
* @param {number} params.timeout Time in ms before notification message will disappear
396-
*/
391+
* Show notification with given or already initiated parametrs.
392+
* @param {string} params.title Title for notification - will show as the message header
393+
* @param {string} params.type Type of Notification - Valid types are MESSAGE|SUBTITLES
394+
* @param {string} params.theme Theme of Notification. Valid types are TIPS|GAMEPLAY|SYSTEM
395+
* @param {string} params.image Notification image. Valid types are IMAGE_NOTIFICATION|IMAGE_SCORE
396+
* @param {string} params.message Notification message
397+
* @param {number} params.timeout Time in ms before notification message will disappear
398+
*/
397399
showNotification(params = {}) {
398400
this.setData(params);
399401

400402
if (!nxNotificationsListener) {
401-
nxNotificationsListener = RegisterViewListener('JS_LISTENER_NOTIFICATIONS');
403+
nxNotificationsListener = RegisterViewListener("JS_LISTENER_NOTIFICATIONS");
402404
}
403-
nxNotificationsListener.triggerToAllSubscribers('SendNewNotification', this.params);
405+
nxNotificationsListener.triggerToAllSubscribers("SendNewNotification", this.params);
404406
setTimeout(() => {
405407
this.hideNotification();
406408
}, this.params.timeout);
407409
}
408410

409411
// TODO FIXME: May break in the future, check every update
410412
hideNotification() {
411-
nxNotificationsListener.triggerToAllSubscribers('HideNotification', this.params.type, null, this.params.id);
413+
nxNotificationsListener.triggerToAllSubscribers("HideNotification", this.params.type, null, this.params.id);
412414
}
413415
}
414416

0 commit comments

Comments
 (0)