Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setInterModelListeners() {
const spaceRefs = this._parent.getSpace(this);
//check what we want to hook this model to
utils.forEach(spaceRefs, reference => {
//hook with the closest prefix to this model
this._space[reference] = this.getClosestModel(reference);
//if hooks change, this should load again
this._space[reference].on("dataConnectedChange", this.handleDataConnectedChange.bind(this));
// tell the connected model to set a link with me
this._space[reference].setLinkWith(this);
});
this.getClosestModel("locale").on("dataConnectedChange", this.handleDataConnectedChange.bind(this));
},
translateStrings() {
const t = this.getTranslationFunction();
const strings = this.placeholder.querySelectorAll("[data-vzb-translate]");
if (strings.length === 0) {
return;
}
utils.forEach(strings, str => {
if (!str || !str.getAttribute) {
return;
}
str.innerHTML = t(str.getAttribute("data-vzb-translate"));
});
},
applyShowChanges() {
this.model.state.marker.clearSelected();
const setObj = {};
utils.forEach(this.previewShow, (showObj, entities) => {
const $and = [];
const $andKeys = [];
utils.forEach(showObj, (entitiesArray, category) => {
$andKeys.push(category);
if (entitiesArray.length) {
$and.push({ [category]: { $in: entitiesArray.slice(0) } });
}
});
utils.forEach(this.model.state[entities].show.$and || [this.model.state[entities].show], show$and => {
utils.forEach(show$and, (filter, key) => {
if (!$andKeys.includes(key)) {
$and.push(utils.deepClone(filter));
}
});
});
_getFirstDimension(opts) {
const models = [];
const _this = this;
utils.forEach(this.space, name => {
models.push(_this.getClosestModel(name));
});
opts = opts || {};
let dim = false;
utils.forEach(models, m => {
if (opts.exceptType && m.getType() !== opts.exceptType) {
dim = m.getDimension();
return false;
} else if (opts.type && m.getType() === opts.type) {
dim = m.getDimension();
return false;
} else if (!opts.exceptType && !opts.type) {
dim = m.getDimension();
return false;
}
});
return dim;
},
afterPreload() {
const submodels = this.getSubmodels();
utils.forEach(submodels, s => {
s.afterPreload();
});
},
Promise.all(proms).then(limits => {
if (_setSelectedLimitsId != _this._setSelectedLimitsId) return;
const first = limits.shift();
let min = first.min;
let max = first.max;
utils.forEach(limits, limit => {
if (min - limit.min > 0) min = limit.min;
if (max - limit.max < 0) max = limit.max;
});
_this.model.time
.set({
startSelected: d3.max([min, new Date(_this.model.time.start)]),
endSelected: d3.min([max, new Date(_this.model.time.end)])
}, force, false /*make change non-persistent for URL and history*/);
});
},
_muteAllQueues(except) {
utils.forEach(this._collectionPromises, (queries, dataId) => {
utils.forEach(queries, (promise, whatId) => {
if (promise.queue.isActive == true && promise.queue.whatId != except) {
promise.queue.mute();
}
});
});
}
hook.getFrames(steps, selected).then(response => {
utils.forEach(response, (frame, t) => {
_this.partialResult[cachePath][t][currentHookState.name] = frame[currentHookState.which];
});
res();
});
}));
_this.getFrame(nextFrameTime, nValues => {
const fraction = (time - prevFrameTime) / (nextFrameTime - prevFrameTime);
const dataBetweenFrames = {};
//loop across the hooks
utils.forEach(pValues, (values, hook) => {
dataBetweenFrames[hook] = {};
//loop across the entities
utils.forEach(values, (val1, key) => {
const val2 = nValues[hook][key];
if (utils.isDate(val1)) {
dataBetweenFrames[hook][key] = time;
} else if (!utils.isNumber(val1)) {
//we can be interpolating string values
dataBetweenFrames[hook][key] = val1;
} else {
//interpolation between number and null should rerurn null, not a value in between (#1350)
dataBetweenFrames[hook][key] = (val1 == null || val2 == null) ? null : val1 + ((val2 - val1) * fraction);
}
});
});
utils.forEach(timeKeys, time => {
totals[time] = {};
utils.forEach(sideKeysNF, side => {
let ageSum = 0;
const sideMaxLimits = [];
utils.forEach(_this.ageKeys, age => {
let stackSum = 0;
utils.forEach(_this.stackKeys, stack => {
if (limits[stack][side] && limits[stack][side][age] && limits[stack][side][age][time]) {
stackSum += limits[stack][side][age][time].max;
ageSum += stackSum;
}
});
sideMaxLimits.push(stackSum);
});
totals[time][side] = ageSum;
const maxSideLimit = Math.max(...sideMaxLimits);
inpercentMaxLimits[side].push(maxSideLimit / ageSum);
maxLimits[side].push(maxSideLimit);