Skip to content

Commit

Permalink
Removed unnecessary comments and improved code quality to maintain co…
Browse files Browse the repository at this point in the history
…nsistency

Signed-off-by: Ravjot Singh <ravu2004@gmail.com>
  • Loading branch information
ravjot07 committed Nov 23, 2024
1 parent e2e098f commit f7ad58f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
17 changes: 3 additions & 14 deletions js/activity-works.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
define(function (require) {
var activity = require("sugar-web/activity/activity");
var icon = require("sugar-web/graphics/icon");
require("easel");
require("handlebars");
var shapes = require("activity/shapes");


// Manipulate the DOM only when it is ready.
require(['domReady!'], function (doc) {
Expand All @@ -16,25 +14,22 @@ define(function (require) {
icon.colorize(activityButton, colors);
});

// Handle New Button Click
var newButton = document.getElementById("new-button");
newButton.onclick = function () {
new_positions();
}

// Handle Stop Button Click
var stopButton = document.getElementById("stop-button");
stopButton.addEventListener('click', function (e) {
activity.close();
});

// Handle Clear Button Click
var clearButton = document.getElementById("clear-button"); // **New Line**
clearButton.addEventListener('click', clearCanvas); // **New Line**

// Then create a list of the label elements
var nlabels = [];
for (var i = 0; i < 21; i++) {
nlabels = [];
for (i = 0; i < 21; i++) {
nlabels[i] = document.getElementById("n" + i.toString());
}

Expand Down Expand Up @@ -64,7 +59,6 @@ define(function (require) {
var Pen = "images/pen.svg";
var shape = 0;

// Get things started
init();

function init() {
Expand Down Expand Up @@ -276,9 +270,6 @@ define(function (require) {
shape = shape + 1;
}

/**
* Clear the canvas and reset the activity state.
*/
/**
* Clear the canvas and reset the drawing lines.
* This function removes only the drawn lines without affecting the turtles' positions.
Expand All @@ -292,8 +283,6 @@ define(function (require) {
oldPt = new createjs.Point(400, 300);
midPt = oldPt;
oldMidPt = oldPt;

// Update the stage to reflect changes
update = true;
}
});
Expand Down
14 changes: 2 additions & 12 deletions js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,21 @@ define(function (require) {
icon.colorize(activityButton, colors);
});

// Handle New Button Click
var newButton = document.getElementById("new-button");
newButton.onclick = function () {
new_positions();
}

// Handle Stop Button Click
var stopButton = document.getElementById("stop-button");
stopButton.addEventListener('click', function (e) {
activity.close();
});

// Handle Clear Button Click
var clearButton = document.getElementById("clear-button"); // **New Line**
clearButton.addEventListener('click', clearCanvas); // **New Line**

// Then create a list of the label elements
var nlabels = [];
for (var i = 0; i < 21; i++) {
nlabels = [];
for (i = 0; i < 21; i++) {
nlabels[i] = document.getElementById("n" + i.toString());
}

Expand Down Expand Up @@ -64,7 +60,6 @@ define(function (require) {
var Pen = "images/pen.svg";
var shape = 0;

// Get things started
init();

function init() {
Expand Down Expand Up @@ -276,9 +271,6 @@ define(function (require) {
shape = shape + 1;
}

/**
* Clear the canvas and reset the activity state.
*/
/**
* Clear the canvas and reset the drawing lines.
* This function removes only the drawn lines without affecting the turtles' positions.
Expand All @@ -292,8 +284,6 @@ define(function (require) {
oldPt = new createjs.Point(400, 300);
midPt = oldPt;
oldMidPt = oldPt;

// Update the stage to reflect changes
update = true;
}
});
Expand Down

0 comments on commit f7ad58f

Please sign in to comment.