Skip to content

Commit 6f84b5d

Browse files
committed
Apply eslint --fix and fix indentation
1 parent 4123c06 commit 6f84b5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3935
-3912
lines changed

.eslintrc.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"env": {
3-
"browser": true,
3+
"browser": false,
44
"commonjs": true,
55
"es6": true,
66
"node": true
@@ -31,4 +31,4 @@
3131
"always"
3232
]
3333
}
34-
}
34+
}

js/.eslintrc.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"globals": {
7+
"Atomics": "readonly",
8+
"SharedArrayBuffer": "readonly"
9+
},
10+
"parserOptions": {
11+
"ecmaVersion": 2018
12+
},
13+
"rules": {
14+
"indent": [
15+
"error",
16+
4,
17+
{
18+
"SwitchCase": 1
19+
}
20+
],
21+
"linebreak-style": [
22+
"error",
23+
"unix"
24+
],
25+
"quotes": [
26+
"error",
27+
"single"
28+
],
29+
"semi": [
30+
"error",
31+
"always"
32+
]
33+
}
34+
}

js/_addColor.js

+45-45
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@
22
//input hex color string
33
//returns list item element
44
function addColor (newColor) {
5-
6-
//add # at beginning if not present
7-
if (newColor.charAt(0) != '#')
8-
newColor = '#' + newColor;
9-
10-
//create list item
11-
var listItem = document.createElement("li");
12-
13-
//create button
14-
var button = document.createElement("button");
15-
button.classList.add("color-button");
16-
button.style.backgroundColor = newColor;
17-
button.addEventListener("mouseup", clickedColor);
18-
listItem.appendChild(button);
19-
20-
/*
21-
//create input to hold color value
22-
var colorValue = document.createElement("input");
23-
colorValue.classList.add("color-value");
24-
listItem.appendChild(colorValue);
25-
*/
26-
27-
//insert new listItem element at the end of the colors menu (right before add button)
28-
colorsMenu.insertBefore(listItem, colorsMenu.children[colorsMenu.children.length-1]);
29-
30-
//add jscolor functionality
31-
initColor(button);
32-
33-
//add edit button
34-
var editButtonTemplate = document.getElementsByClassName('color-edit-button')[0];
35-
newEditButton = editButtonTemplate.cloneNode(true);
36-
listItem.appendChild(newEditButton);
37-
38-
//when you click the edit button
39-
on('click', newEditButton, function (event, button) {
40-
41-
//hide edit button
42-
button.parentElement.lastChild.classList.add('hidden');
43-
44-
//show jscolor picker
45-
button.parentElement.firstChild.jscolor.show();
46-
});
47-
48-
return listItem;
49-
}
5+
6+
//add # at beginning if not present
7+
if (newColor.charAt(0) != '#')
8+
newColor = '#' + newColor;
9+
10+
//create list item
11+
var listItem = document.createElement('li');
12+
13+
//create button
14+
var button = document.createElement('button');
15+
button.classList.add('color-button');
16+
button.style.backgroundColor = newColor;
17+
button.addEventListener('mouseup', clickedColor);
18+
listItem.appendChild(button);
19+
20+
/*
21+
//create input to hold color value
22+
var colorValue = document.createElement("input");
23+
colorValue.classList.add("color-value");
24+
listItem.appendChild(colorValue);
25+
*/
26+
27+
//insert new listItem element at the end of the colors menu (right before add button)
28+
colorsMenu.insertBefore(listItem, colorsMenu.children[colorsMenu.children.length-1]);
29+
30+
//add jscolor functionality
31+
initColor(button);
32+
33+
//add edit button
34+
var editButtonTemplate = document.getElementsByClassName('color-edit-button')[0];
35+
newEditButton = editButtonTemplate.cloneNode(true);
36+
listItem.appendChild(newEditButton);
37+
38+
//when you click the edit button
39+
on('click', newEditButton, function (event, button) {
40+
41+
//hide edit button
42+
button.parentElement.lastChild.classList.add('hidden');
43+
44+
//show jscolor picker
45+
button.parentElement.firstChild.jscolor.show();
46+
});
47+
48+
return listItem;
49+
}

js/_addColorButton.js

+52-52
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11
//add color button
22
on('click', 'add-color-button', function(){
3-
if (!documentCreated) return;
3+
if (!documentCreated) return;
44

5-
var colorCheckingStyle = `
5+
var colorCheckingStyle = `
66
color: white;
77
background: #3c4cc2;
88
`;
9-
10-
var colorIsUnique = true
11-
do {
12-
//console.log('%cchecking for unique colors', colorCheckingStyle)
13-
//generate random color
14-
var hue = Math.floor(Math.random()*255);
15-
var sat = 130+Math.floor(Math.random()*100);
16-
var lit = 70+Math.floor(Math.random()*100);
17-
var newColorRgb = hslToRgb(hue,sat,lit)
18-
var newColor = rgbToHex(newColorRgb.r,newColorRgb.g,newColorRgb.b)
19-
20-
var newColorHex = newColor;
21-
22-
//check if color has been used before
23-
colors = document.getElementsByClassName('color-button');
24-
colorCheckingLoop: for (var i = 0; i < colors.length; i++) {
25-
//console.log('%c'+newColorHex +' '+ colors[i].jscolor.toString(), colorCheckingStyle)
26-
27-
//if generated color matches this color
28-
if (newColorHex == colors[i].jscolor.toString()) {
29-
//console.log('%ccolor already exists', colorCheckingStyle)
30-
31-
//start loop again
32-
colorIsUnique = false;
33-
34-
//exit
35-
break colorCheckingLoop;
36-
}
9+
10+
var colorIsUnique = true;
11+
do {
12+
//console.log('%cchecking for unique colors', colorCheckingStyle)
13+
//generate random color
14+
var hue = Math.floor(Math.random()*255);
15+
var sat = 130+Math.floor(Math.random()*100);
16+
var lit = 70+Math.floor(Math.random()*100);
17+
var newColorRgb = hslToRgb(hue,sat,lit);
18+
var newColor = rgbToHex(newColorRgb.r,newColorRgb.g,newColorRgb.b);
19+
20+
var newColorHex = newColor;
21+
22+
//check if color has been used before
23+
colors = document.getElementsByClassName('color-button');
24+
colorCheckingLoop: for (var i = 0; i < colors.length; i++) {
25+
//console.log('%c'+newColorHex +' '+ colors[i].jscolor.toString(), colorCheckingStyle)
26+
27+
//if generated color matches this color
28+
if (newColorHex == colors[i].jscolor.toString()) {
29+
//console.log('%ccolor already exists', colorCheckingStyle)
30+
31+
//start loop again
32+
colorIsUnique = false;
33+
34+
//exit
35+
break colorCheckingLoop;
36+
}
37+
}
3738
}
38-
}
39-
while (colorIsUnique == false);
40-
41-
//remove current color selection
42-
document.querySelector("#colors-menu li.selected").classList.remove("selected");
43-
44-
//add new color and make it selected
45-
var addedColor = addColor(newColor);
46-
addedColor.classList.add('selected');
47-
context.fillStyle = '#' + newColor;
48-
49-
//add history state
50-
//saveHistoryState({type: 'addcolor', colorValue: addedColor.firstElementChild.jscolor.toString()});
51-
new HistoryStateAddColor(addedColor.firstElementChild.jscolor.toString());
52-
53-
//show color picker
54-
addedColor.firstElementChild.jscolor.show();
55-
console.log("showing picker");
56-
57-
//hide edit button
58-
addedColor.lastChild.classList.add('hidden');
59-
}, false);
39+
while (colorIsUnique == false);
40+
41+
//remove current color selection
42+
document.querySelector('#colors-menu li.selected').classList.remove('selected');
43+
44+
//add new color and make it selected
45+
var addedColor = addColor(newColor);
46+
addedColor.classList.add('selected');
47+
context.fillStyle = '#' + newColor;
48+
49+
//add history state
50+
//saveHistoryState({type: 'addcolor', colorValue: addedColor.firstElementChild.jscolor.toString()});
51+
new HistoryStateAddColor(addedColor.firstElementChild.jscolor.toString());
52+
53+
//show color picker
54+
addedColor.firstElementChild.jscolor.show();
55+
console.log('showing picker');
56+
57+
//hide edit button
58+
addedColor.lastChild.classList.add('hidden');
59+
}, false);

js/_changeTool.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
function changeTool (selectedTool) {
2-
// Ending any selection in progress
3-
if (currentTool.includes("select") && !selectedTool.includes("select") && !selectionCanceled) {
4-
endSelection();
2+
// Ending any selection in progress
3+
if (currentTool.includes('select') && !selectedTool.includes('select') && !selectionCanceled) {
4+
endSelection();
55
}
66
//set tool and temp tje tje tpp;
77
currentTool = selectedTool;
8-
currentToolTemp = selectedTool;
9-
10-
var tools = document.getElementById("tools-menu").children;
11-
12-
for (var i = 0; i < tools.length; i++) {
13-
tools[i].classList.remove("selected");
14-
}
15-
8+
currentToolTemp = selectedTool;
9+
10+
var tools = document.getElementById('tools-menu').children;
11+
12+
for (var i = 0; i < tools.length; i++) {
13+
tools[i].classList.remove('selected');
14+
}
15+
1616
//give the button of the selected tool the .selected class
17-
document.getElementById(selectedTool+"-button").parentNode.classList.add("selected");
18-
19-
//change cursor
20-
updateCursor();
21-
}
17+
document.getElementById(selectedTool+'-button').parentNode.classList.add('selected');
18+
19+
//change cursor
20+
updateCursor();
21+
}

js/_changeZoom.js

+28-30
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
21
function changeZoom (layer, direction, cursorLocation) {
3-
var oldWidth = canvasSize[0] * zoom;
4-
var oldHeight = canvasSize[1] * zoom;
5-
var newWidth, newHeight;
6-
7-
//change zoom level
8-
//if you want to zoom out, and the zoom isnt already at the smallest level
9-
if (direction == 'out' && zoom > 1) {
10-
zoom -= Math.ceil(zoom / 10);
11-
newWidth = canvasSize[0] * zoom;
12-
newHeight = canvasSize[1] * zoom;
13-
14-
//adjust canvas position
15-
setCanvasOffset(layer.canvas, layer.canvas.offsetLeft + (oldWidth - newWidth) *cursorLocation[0]/oldWidth, layer.canvas.offsetTop + (oldHeight - newHeight) *cursorLocation[1]/oldWidth)
16-
}
17-
//if you want to zoom in
18-
else if (direction == 'in' && zoom + Math.ceil(zoom/10) < window.innerHeight/4){
19-
zoom += Math.ceil(zoom/10);
20-
newWidth = canvasSize[0] * zoom;
21-
newHeight = canvasSize[1] * zoom;
22-
23-
//adjust canvas position
24-
setCanvasOffset(layer.canvas, layer.canvas.offsetLeft - Math.round((newWidth - oldWidth)*cursorLocation[0]/oldWidth), layer.canvas.offsetTop - Math.round((newHeight - oldHeight)*cursorLocation[1]/oldHeight))
25-
}
26-
27-
//resize canvas
28-
layer.resize();
2+
var oldWidth = canvasSize[0] * zoom;
3+
var oldHeight = canvasSize[1] * zoom;
4+
var newWidth, newHeight;
5+
6+
//change zoom level
7+
//if you want to zoom out, and the zoom isnt already at the smallest level
8+
if (direction == 'out' && zoom > 1) {
9+
zoom -= Math.ceil(zoom / 10);
10+
newWidth = canvasSize[0] * zoom;
11+
newHeight = canvasSize[1] * zoom;
12+
13+
//adjust canvas position
14+
setCanvasOffset(layer.canvas, layer.canvas.offsetLeft + (oldWidth - newWidth) *cursorLocation[0]/oldWidth, layer.canvas.offsetTop + (oldHeight - newHeight) *cursorLocation[1]/oldWidth);
15+
} else if (direction == 'in' && zoom + Math.ceil(zoom/10) < window.innerHeight/4){
16+
//if you want to zoom in
17+
zoom += Math.ceil(zoom/10);
18+
newWidth = canvasSize[0] * zoom;
19+
newHeight = canvasSize[1] * zoom;
20+
21+
//adjust canvas position
22+
setCanvasOffset(layer.canvas, layer.canvas.offsetLeft - Math.round((newWidth - oldWidth)*cursorLocation[0]/oldWidth), layer.canvas.offsetTop - Math.round((newHeight - oldHeight)*cursorLocation[1]/oldHeight));
23+
}
24+
25+
//resize canvas
26+
layer.resize();
2927

30-
// adjust brush size
31-
updateCursor();
32-
}
28+
// adjust brush size
29+
updateCursor();
30+
}

js/_checkCompatibility.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
21
/////=include libraries/bowser.js
32

43
function closeCompatibilityWarning () {
5-
document.getElementById('compatibility-warning').style.visibility = 'hidden';
4+
document.getElementById('compatibility-warning').style.visibility = 'hidden';
65
}
76

8-
console.log('checking compatibility')
7+
console.log('checking compatibility');
98

109
//check browser/version
11-
if ( (bowser.msie && bowser.version < 11) ||
12-
(bowser.firefox && bowser.version < 28) ||
13-
(bowser.chrome && bowser.version < 29) ||
14-
(bowser.msedge && bowser.version < 12) ||
15-
(bowser.safari && bowser.version < 9) ||
16-
(bowser.opera && bowser.version < 17) )
17-
//show warning
18-
document.getElementById('compatibility-warning').style.visibility = 'visible';
10+
if ((bowser.msie && bowser.version < 11) ||
11+
(bowser.firefox && bowser.version < 28) ||
12+
(bowser.chrome && bowser.version < 29) ||
13+
(bowser.msedge && bowser.version < 12) ||
14+
(bowser.safari && bowser.version < 9) ||
15+
(bowser.opera && bowser.version < 17) )
16+
//show warning
17+
document.getElementById('compatibility-warning').style.visibility = 'visible';
1918

20-
else alert(bowser.name+' '+bowser.version+' is fine!')
19+
else alert(bowser.name+' '+bowser.version+' is fine!');

0 commit comments

Comments
 (0)