diff --git a/docs/js/main.js b/docs/js/main.js
index b3f7d5d..5317680 100644
--- a/docs/js/main.js
+++ b/docs/js/main.js
@@ -62,7 +62,8 @@ socket.send(JSON.stringify( subscription ));
// Remove and complete icons in SVG format
var removeSVG = '';
-var completeSVG = '';
+var uncheckedSVG = '';
+var checkedSVG = '';
// User clicked on the add button
// If there is any text inside the item field, add that text to the todo list
@@ -166,7 +167,11 @@ function addItemToDOM(text, completed) {
var complete = document.createElement('button');
complete.classList.add('complete');
- complete.innerHTML = completeSVG;
+ if (completed) {
+ complete.innerHTML = checkedSVG;
+ } else {
+ complete.innerHTML = uncheckedSVG;
+ };
// Add click event for completing the item
complete.addEventListener('click', completeItem);
@@ -174,7 +179,6 @@ function addItemToDOM(text, completed) {
buttons.appendChild(remove);
buttons.appendChild(complete);
item.appendChild(buttons);
-
list.insertBefore(item, list.childNodes[0]);
};
diff --git a/public/js/main.js b/public/js/main.js
index b3f7d5d..5317680 100644
--- a/public/js/main.js
+++ b/public/js/main.js
@@ -62,7 +62,8 @@ socket.send(JSON.stringify( subscription ));
// Remove and complete icons in SVG format
var removeSVG = '';
-var completeSVG = '';
+var uncheckedSVG = '';
+var checkedSVG = '';
// User clicked on the add button
// If there is any text inside the item field, add that text to the todo list
@@ -166,7 +167,11 @@ function addItemToDOM(text, completed) {
var complete = document.createElement('button');
complete.classList.add('complete');
- complete.innerHTML = completeSVG;
+ if (completed) {
+ complete.innerHTML = checkedSVG;
+ } else {
+ complete.innerHTML = uncheckedSVG;
+ };
// Add click event for completing the item
complete.addEventListener('click', completeItem);
@@ -174,7 +179,6 @@ function addItemToDOM(text, completed) {
buttons.appendChild(remove);
buttons.appendChild(complete);
item.appendChild(buttons);
-
list.insertBefore(item, list.childNodes[0]);
};