Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$ut.on('pointerenter', function() {
if (!map.drawing || currentUtility === $ut) return;
map.addPoint(p);
map.stop();
map.p = null;
$ut.effect('pulse-down');
if (startUtility.data.type === dataType) {
last(map.paths).css('stroke','#C00');
errors.push(last(map.paths));
if (dataType === 'house') {
$section.addHint('housesToEachOther');
} else {
$section.addHint('factoriesToEachOther');
}
} else {
let sector = (startUtility.data.type === 'house') ?
$('.' + $ut.data.utility, currentUtility) : $('.' + currentUtility.data.utility, $ut);
sector.css('opacity', 1);
sectors.set(last(map.paths), sector);
}
// TODO Error on connect twice
});
});
map.p = undefined;
$ut.effect('pulse-down');
if (startUtility.data.type === dataType) {
last(map.paths).css('stroke', '#C00');
errors.push(last(map.paths));
if (dataType === 'house') {
$section.addHint('housesToEachOther');
} else {
$section.addHint('factoriesToEachOther');
}
} else {
let sector = (startUtility.data.type === 'house') ?
$('.' + $ut.data.utility, currentUtility)! :
$('.' + currentUtility.data.utility, $ut)!;
sector.css('opacity', 1);
sectors.set(last(map.paths), sector);
}
// TODO Error on connect twice
});
}
$ut.on('pointerenter', function() {
if (!map.drawing || currentUtility === $ut) return;
map.addPoint(p);
map.stop();
map.p = null;
$ut.effect('pulse-down');
if (startUtility.data.type === dataType) {
last(map.paths).css('stroke','#C00');
errors.push(last(map.paths));
if (dataType === 'house') {
$section.addHint('housesToEachOther');
} else {
$section.addHint('factoriesToEachOther');
}
} else {
let sector = (startUtility.data.type === 'house') ?
$('.' + $ut.data.utility, currentUtility) : $('.' + currentUtility.data.utility, $ut);
sector.css('opacity', 1);
sectors.set(last(map.paths), sector);
}
// TODO Error on connect twice
});
});
$ut.on('pointerenter', () => {
if (!map.drawing || currentUtility === $ut) return;
map.addPoint(p);
map.stop();
map.p = undefined;
$ut.effect('pulse-down');
if (startUtility.data.type === dataType) {
last(map.paths).css('stroke', '#C00');
errors.push(last(map.paths));
if (dataType === 'house') {
$section.addHint('housesToEachOther');
} else {
$section.addHint('factoriesToEachOther');
}
} else {
let sector = (startUtility.data.type === 'house') ?
$('.' + $ut.data.utility, currentUtility)! :
$('.' + currentUtility.data.utility, $ut)!;
sector.css('opacity', 1);
sectors.set(last(map.paths), sector);
}
// TODO Error on connect twice
});
}
explode() {
return last(this.cells).explode(true);
}
}
function generatePossibilities(len) {
if (len <= 1) return [['R', 'B']];
let prev = generatePossibilities(len - 1);
prev.push(last(prev).map(x => x + 'R').concat(last(prev).map(x => x + 'B')));
return prev;
}
while (n0 > 0) {
let r1 = x - triangleNumber(n0);
if (!r1) return [n0, 0, 0];
let n1 = Math.min(n0, Math.floor((Math.sqrt(8 * r1 + 1) - 1) / 2));
while (n1 > 0) {
let r2 = r1 - triangleNumber(n1);
if (!r2) results.push([n0, n1, 0]);
let n2 = Math.min(n1, Math.floor((Math.sqrt(8 * r2 + 1) - 1) / 2));
if (r2 === triangleNumber(n2)) results.push([n0, n1, n2]);
n1 -= 1;
}
n0 -= 1;
}
sortBy(results, r => total(r.map(x => x * x)));
return last(results);
});
checkForIntersects() {
if (!this.options.intersect || this.paths.length <= 1) return;
let path1 = last(this.paths);
let points1 = path1.points as Point[];
let line1 = new Segment(points1[points1.length - 2],
points1[points1.length - 1]);
for (let i = 0; i < this.paths.length - 1; ++i) {
let path2 = this.paths[i];
let points2 = path2.points as Point[];
for (let j = 1; j < points2.length - 2; ++j) {
let line2 = new Segment(points2[j], points2[j + 1]);
let t = Segment.intersect(line1, line2);
if (t) {
this.trigger('intersect', {point: t, paths: [path1, path2]});
return;
}
}
}
checkForIntersects() {
if (!this.options.intersect || this.paths.length <= 1) return;
let path1 = last(this.paths);
let points1 = path1.points;
let line1 = new Line(points1[points1.length-2], points1[points1.length-1]);
for (let i = 0; i < this.paths.length - 1; ++i) {
let path2 = this.paths[i];
let points2 = path2.points;
for (let j = 1; j < points2.length - 2; ++j) {
let line2 = new Line(points2[j], points2[j + 1]);
let t = Line.intersect(line1, line2);
if (t) {
this.trigger('intersect', { point: t, paths: [path1, path2] });
return;
}
}
}
}