Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
Solves #10 in linted file
  • Loading branch information
VBproDev authored Sep 30, 2024
1 parent 4a42bc7 commit 0f7753a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ let y;
let num = -1;
let canvasArray = [];
let warnedUser = false;
let newDesign;

function previewLine(event) {
const atX = event.offsetX;
Expand All @@ -49,14 +50,14 @@ function int(n) {
function copyText() {
design.select();
design.setSelectionRange(0, 99999999);
navigator.clipboard.writeText(`${design.value}`);
navigator.clipboard.writeText(JSON.stringify(canvasArray));
}

function setArray() {
if (canvasArray.length === 0) {
design.value = '[ ]'
} else {
design.value = `[${canvasArray}]`;
design.value = JSON.stringify(canvasArray);
};
}

Expand Down Expand Up @@ -89,8 +90,8 @@ function drawLines() {
if (!(int(CA1) || int(CA2))) {
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = CA1 || "#000";
ctx.lineWidth = CA2;
ctx.strokeStyle = CA1;
ctx.lineWidth = CA1 || "#000";
i += 2;
} else {
if (Math.sign(CA1)) {
Expand Down Expand Up @@ -203,7 +204,7 @@ window.addEventListener('resize', (e) => {
window.addEventListener('beforeunload', (e) => {
if (localStorage.getItem('canvasArray') !== JSON.stringify(canvasArray) && !warnedUser) {
e.preventDefault();
warnedUser = true;
warnedUser = true;
}
});

Expand Down Expand Up @@ -313,4 +314,4 @@ userDesign.addEventListener('click', () => {

save.addEventListener('click', () => {
localStorage.setItem('canvasArray', JSON.stringify(canvasArray));
});
});

0 comments on commit 0f7753a

Please sign in to comment.