diff --git a/src/main.js b/src/main.js index 12d7604..137ff32 100644 --- a/src/main.js +++ b/src/main.js @@ -54,8 +54,8 @@ function onClickPaint(shapeId, color){ renderShapes(); } -function onClickTrash(circleId){ - const index = getShapeIndexById(circleId); +function onClickTrash(shapeId){ + const index = getShapeIndexById(shapeId); shapes.splice(index, 1) renderShapes(); } @@ -98,7 +98,7 @@ function drawNewText() { -function clearCircles(){ +function clearShapes(){ shapes.length = 0; renderShapes(); } @@ -122,6 +122,6 @@ document.getElementById("draw-circle").addEventListener("click", drawNewCircle); document.getElementById("draw-rectangle").addEventListener("click", drawNewRectangle); document.getElementById("draw-text").addEventListener("click", drawNewText); -document.getElementById("clear-drawing").addEventListener("click", clearCircles); +document.getElementById("clear-drawing").addEventListener("click", clearShapes); diff --git a/src/tp1.js b/src/tp1.js index 89320cb..82b93f8 100644 --- a/src/tp1.js +++ b/src/tp1.js @@ -246,7 +246,7 @@ function drawIcons(shape, /** * @param node {HTMLElement} un element tbody - * @param circles {Circle[]} Les cercles + * @param shapes {Circle[]} Les cercles * @param pointToString Argument optionnel qui doit être une fonction * qui prend en paramêtre un Point et retourne un String qui * représente le point. @@ -276,7 +276,7 @@ function drawIcons(shape, * la fonction. */ export function populateTable(node, - circles, + shapes, onClickUp=undefined, onClickDown=undefined, onClickLeft=undefined, @@ -284,10 +284,10 @@ export function populateTable(node, onClickPaint=undefined, onClickDelete = undefined){ const rows = []; - for(const circle of circles){ - const row =[m("td", circle.getId()), - m("td", circle.toString()), - m("td", drawIcons(circle, + for(const shape of shapes){ + const row =[m("td", shape.getId()), + m("td", shape.toString()), + m("td", drawIcons(shape, functionOrDefault(onClickUp), functionOrDefault(onClickDown), functionOrDefault(onClickLeft),