1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-25 17:25:16 +03:00

Change lexical scope utils

This commit is contained in:
Mark Haslinghuis 2020-12-08 16:43:05 +01:00
parent 317f937fd5
commit 2607ab8a3c

View file

@ -5,7 +5,7 @@
One window could watch passed values from another window and react to them. One window could watch passed values from another window and react to them.
*/ */
var windowWatcherUtil = {}; const windowWatcherUtil = {};
windowWatcherUtil.invokeWatcher = function(bindingKey, bindingVal, watchersObject) { windowWatcherUtil.invokeWatcher = function(bindingKey, bindingVal, watchersObject) {
if (watchersObject[bindingKey]) { if (watchersObject[bindingKey]) {
@ -16,7 +16,7 @@ windowWatcherUtil.invokeWatcher = function(bindingKey, bindingVal, watchersObjec
windowWatcherUtil.iterateOverBindings = function(bindings, watchersObject) { windowWatcherUtil.iterateOverBindings = function(bindings, watchersObject) {
let entries = Object.entries(bindings); let entries = Object.entries(bindings);
for (const [key, val] of entries) { for (const [key, val] of entries) {
this.invokeWatcher(key, val, watchersObject) this.invokeWatcher(key, val, watchersObject);
} }
} }
@ -38,9 +38,9 @@ windowWatcherUtil.bindWatchers = function(windowObject, watchersObject) {
// 'Windows' here could be array or single window reference // 'Windows' here could be array or single window reference
windowWatcherUtil.passValue = function(windows, key, val) { windowWatcherUtil.passValue = function(windows, key, val) {
let applyBinding = function(win, key, val) { let applyBinding = function(win, key, val) {
if (!win) { if (!win) {
return; return;
} }
if (win.contentWindow.bindings) { if (win.contentWindow.bindings) {
win.contentWindow.bindings[key] = val; win.contentWindow.bindings[key] = val;
@ -49,7 +49,7 @@ windowWatcherUtil.passValue = function(windows, key, val) {
[key]: val [key]: val
}; };
} }
} };
if (Array.isArray(windows)) { if (Array.isArray(windows)) {
windows.forEach((el) => applyBinding(el, key, val)); windows.forEach((el) => applyBinding(el, key, val));