Skip to content

Commit

Permalink
change let and const back to var
Browse files Browse the repository at this point in the history
  • Loading branch information
finnboeger committed Apr 28, 2020
1 parent d2242bc commit 84b2c83
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
32 changes: 16 additions & 16 deletions client-data/tools/eraser/eraser.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@

(function eraser() { //Code isolation

let erasing = false;
var erasing = false;

const currShape = null;
let curTool = "click";
const icons = ["tools/eraser/icon-red.svg", "tools/eraser/icon.svg",];
const toolNames = ["Remove single shape", "Remove all contacted shapes"];
var currShape = null;
var curTool = "click";
var icons = ["tools/eraser/icon-red.svg", "tools/eraser/icon.svg",];
var toolNames = ["Remove single shape", "Remove all contacted shapes"];

const msg = {
var msg = {
"type": "delete",
"id": null,
"x": 0,
Expand All @@ -54,21 +54,21 @@

function erase(x, y, evt) {
// evt.target should be the element over which the mouse is...
let target = evt.target;
var target = evt.target;
if (evt.type === "touchmove") {
// ... the target of touchmove events is the element that was initially touched,
// not the one **currently** being touched
const touch = evt.touches[0];
var touch = evt.touches[0];
target = document.elementFromPoint(touch.clientX, touch.clientY);
}
if (erasing) {
// get points all within a circle of a given radius
// https://stackoverflow.com/a/26802146
let radius = Tools.getSize(),
var radius = Tools.getSize(),
r2 = radius*radius;
for (let dx = -radius; dx <= radius; dx++) {
let h = Math.sqrt(r2 - dx * dx) | 0;
for (let dy = -h; dy <= h; dy++) {
for (var dx = -radius; dx <= radius; dx++) {
var h = Math.sqrt(r2 - dx * dx) | 0;
for (var dy = -h; dy <= h; dy++) {
scanForObject(x, y, target, dx, dy);
}
}
Expand All @@ -79,12 +79,12 @@
}

function draw(data) {
let elem;
var elem;
switch (data.type) {
//TODO: add the ability to erase only some points in a line
case "delete":
if (Array.isArray(data.id)) {
for(let i = 0; i<data.id.length; i++){
for(var i = 0; i<data.id.length; i++){
elem = svg.getElementById(data.id[i]);
if (elem !== null){ //console.error("Eraser: Tried to delete an element that does not exist.");
elem.remove();
Expand All @@ -111,7 +111,7 @@
msg.y = y+j;
msg.target = target;
if(!msg.id.startsWith("layer")&&msg.id!=="defs"&&msg.id!=="rect_1"&&msg.id!=="cursors"){
const elem = svg.getElementById(msg.id);
var elem = svg.getElementById(msg.id);
if (elem !== null) Tools.drawAndSend(msg);
}
}
Expand All @@ -120,7 +120,7 @@
var svg = Tools.svg;

function toggle(elem){
let index = 0;
var index = 0;
if (curTool === "click") {
curTool = "drag";
index = 1;
Expand Down
32 changes: 16 additions & 16 deletions client-data/tools/multi-eraser/multi-eraser.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@

(function multi_eraser() { //Code isolation

let erasing = false;
var erasing = false;

let curTool = "single";
let end = false;
let lastTime = performance.now(); //The time at which the last point was drawn
let makeRect = false;
let textElem;
var curTool = "single";
var end = false;
var lastTime = performance.now(); //The time at which the last point was drawn
var makeRect = false;
var textElem;
var oldScale = Tools.getScale();

const msg = {
var msg = {
"type": "delete",
"id": null,
"x": 0,
"y": 0
};

const rect = {
var rect = {
x: 0,
y: 0,
x2: 0,
Expand All @@ -53,7 +53,7 @@

//Prevent the press from being interpreted by the browser
evt.preventDefault();
const shape = Tools.createSVGElement("rect");
var shape = Tools.createSVGElement("rect");

shape.id = "erase-rect";

Expand Down Expand Up @@ -85,18 +85,18 @@
end = true;
erase(x, y);
end = false;
const shape = svg.getElementById("erase-rect");
var shape = svg.getElementById("erase-rect");
erase_rect = shape.getBoundingClientRect();
shape.remove();
textElem.setAttribute("x", -1000);
textElem.setAttribute("y", 100);
textElem.style.visibility = "hidden";
makeRect = false;
const targets = [];
var targets = [];
//document.querySelectorAll("#layer-" + Tools.layer + " *").forEach(
document.querySelectorAll("#canvas path, #canvas text, #canvas line, #canvas rect").forEach(
function (el, i) {
let r = el.getBoundingClientRect();
var r = el.getBoundingClientRect();
if (r.left >= erase_rect.left && r.right <= erase_rect.right
&& r.top >= erase_rect.top && r.bottom <= erase_rect.bottom) {
targets.push(el);
Expand All @@ -105,7 +105,7 @@
);
if (targets.length > 0) {
msg.id = [];
for (let i = 0; i < targets.length; i++) {
for (var i = 0; i < targets.length; i++) {
msg.id.push(targets[i].id);
}
Tools.drawAndSend(msg);
Expand All @@ -118,7 +118,7 @@
rect['x2'] = x;
rect['y2'] = y;
if (performance.now() - lastTime > 20 || end) {
const shape = svg.getElementById("erase-rect");
var shape = svg.getElementById("erase-rect");
shape.x.baseVal.value = Math.min(rect['x2'], rect['x']);
shape.y.baseVal.value = Math.min(rect['y2'], rect['y']);
shape.width.baseVal.value = Math.abs(rect['x2'] - rect['x']);
Expand Down Expand Up @@ -146,12 +146,12 @@
}

function draw (data) {
let elem;
var elem;
switch (data.type) {
//TODO: add the ability to erase only some points in a line
case "delete":
if(Array.isArray(data.id)){
for(let i = 0; i<data.id.length; i++){
for(var i = 0; i<data.id.length; i++){
elem = svg.getElementById(data.id[i]);
if (elem !== null){ //console.error("Eraser: Tried to delete an element that does not exist.");
elem.remove();
Expand Down

0 comments on commit 84b2c83

Please sign in to comment.