<commit_before>window.onload = function(){
	console.log("javascript file loaded");
};



var btnNew = document.getElementById("subBtn");//button





//making our todoList object
//an empty array to push the todos into
var todoList = {
		todos:[], 
		todoComment: [],
		// displayToDos: function() {
		// 	if(this.todos.length === 0){
		// 		console.log("Your Todo List is Empty");
		// 	} else {
		// 		console.log("My todos:");
		// 		for (var i = 0; i < this.todos.length; i++) {
		// 			if (this.todos[i].completed === true) {
		// 			console.log('(completed)', this.todos[i].todoText); 
		// 			} else {
		// 			console.log('(not completed)', this.todos[i].todoText);
		// 	  }
		// 	}
		//   }
		// },	


		addToDo: function(todoText) {
			this.todos.push ({
				todoText: todoText,
				completed: false
			});
			
		},

		addComment: function(todoComment) {
			this.todoComment.push ({
				todoComment: todoComment
			});
			console.log(this.todoComment);
		},


		changeToDo: function(position, todoText) {
			this.todos[position].todoText = todoText;
			
		},
		deleteToDo: function(position) {
			this.todos.splice(position, 1);
			
		},
		toggleCompleted: function(position) {
			var todo = this.todos[position];
			todo.completed = !todo.completed;
			
		},
		toggleAll: function() {
			var totalTodos = this.todos.length;
			var completedTodos = 0;

			for (var i = 0; i < totalTodos; i++) {
				if (this.todos[i].completed === true){
					 completedTodos++;
				}
			}
			if (completedTodos === totalTodos) {
			for (var i = 0; i < totalTodos; i++) {
				this.todos[i].completed = false;
			}
		} 	else {
			for (var i = 0; i < totalTodos; i++) {
				this.todos[i].completed = true;
			}
		}
		
  	}
  };		


var buttonHandlers = {


	addToDo: function() {
		var addToDoTextInput = document.getElementById("addToDoTextInput");
		todoList.addToDo(addToDoTextInput.value);
		addToDoTextInput.value = "";
		view.displayToDos();
	},




	// addComment: function() {
	// 	var addCommentInput = document.getElementById("addCommentInput");
	// 	todoList.addComment(addCommentInput.value);
	// 	addCommentInput.value ="";
	// },







	changeToDo: function() {
		var changeToDoPositionInput = document.getElementById("changeToDoPositionInput");
		var changeToDoPositionText = document.getElementById("changeToDoPositionText");

		todoList.changeToDo(changeToDoPositionInput.valueAsNumber,changeToDoPositionText.value);
	
		changeToDoPositionInput.value = "";
		changeToDoPositionText.value = "";

		view.displayToDos();
	},

	deleteToDo: function() {
		var deleteToDoButton = document.getElementById("deleteToDoButton");
		var deleteToDoButtonInput = document.getElementById("deleteToDoButtonInput");
		todoList.deleteToDo(deleteToDoButtonInput.valueAsNumber);

		deleteToDoButtonInput.value = "";

		view.displayToDos();
	},

	toggleCompleted: function() {
		var toggleCompInputButton = document.getElementById("toggleCompdInputButton");
		var toggleCompInput = document.getElementById("toggleCompInput");

		todoList.toggleCompleted(toggleCompInput.valueAsNumber);

		toggleCompInput.value = "";

		view.displayToDos();

	},

	toggleAll: function() {
		todoList.toggleAll();

		view.displayToDos();
	}

};






var view = {
	displayToDos: function() {
		var todosUl = document.querySelector("ul");
		todosUl.innerHTML = "";
		for (var i = 0; i < todoList.todos.length; i++) {
			var todosLi = document.createElement("li");
			var todoTextWithCompletion = "";
			var todo = todoList.todos[i];


			if (todo.completed === true) {
				todoTextWithCompletion = '(x) ' + todo.todoText;
			} else {
				todoTextWithCompletion = '( ) ' + todo.todoText;
			}

			todosLi.id = i;
			todosLi.textContent = todoTextWithCompletion;
			todosLi.appendChild(this.createDeleteButton());
			todosUl.appendChild(todosLi);
		}
	},

	createDeleteButton: function() {
		var deleteButton = document.createElement("button");
		deleteButton.textContent = "Delete";
		deleteButton.className = "deleteButton";
		return deleteButton;
	}
};



<commit_msg>added new setUpEventListeners method to view object<commit_after>window.onload = function(){
	console.log("javascript file loaded");
};



var btnNew = document.getElementById("subBtn");//button





//making our todoList object
//an empty array to push the todos into
var todoList = {
		todos:[], 
		todoComment: [],
		// displayToDos: function() {
		// 	if(this.todos.length === 0){
		// 		console.log("Your Todo List is Empty");
		// 	} else {
		// 		console.log("My todos:");
		// 		for (var i = 0; i < this.todos.length; i++) {
		// 			if (this.todos[i].completed === true) {
		// 			console.log('(completed)', this.todos[i].todoText); 
		// 			} else {
		// 			console.log('(not completed)', this.todos[i].todoText);
		// 	  }
		// 	}
		//   }
		// },	


		addToDo: function(todoText) {
			this.todos.push ({
				todoText: todoText,
				completed: false
			});
			
		},

		addComment: function(todoComment) {
			this.todoComment.push ({
				todoComment: todoComment
			});
			console.log(this.todoComment);
		},


		changeToDo: function(position, todoText) {
			this.todos[position].todoText = todoText;
			
		},
		deleteToDo: function(position) {
			this.todos.splice(position, 1);
			
		},
		toggleCompleted: function(position) {
			var todo = this.todos[position];
			todo.completed = !todo.completed;
			
		},
		toggleAll: function() {
			var totalTodos = this.todos.length;
			var completedTodos = 0;

			for (var i = 0; i < totalTodos; i++) {
				if (this.todos[i].completed === true){
					 completedTodos++;
				}
			}
			if (completedTodos === totalTodos) {
			for (var i = 0; i < totalTodos; i++) {
				this.todos[i].completed = false;
			}
		} 	else {
			for (var i = 0; i < totalTodos; i++) {
				this.todos[i].completed = true;
			}
		}
		
  	}
  };		


var buttonHandlers = {


	addToDo: function() {
		var addToDoTextInput = document.getElementById("addToDoTextInput");
		todoList.addToDo(addToDoTextInput.value);
		addToDoTextInput.value = "";
		view.displayToDos();
	},




	// addComment: function() {
	// 	var addCommentInput = document.getElementById("addCommentInput");
	// 	todoList.addComment(addCommentInput.value);
	// 	addCommentInput.value ="";
	// },







	changeToDo: function() {
		var changeToDoPositionInput = document.getElementById("changeToDoPositionInput");
		var changeToDoPositionText = document.getElementById("changeToDoPositionText");

		todoList.changeToDo(changeToDoPositionInput.valueAsNumber,changeToDoPositionText.value);
	
		changeToDoPositionInput.value = "";
		changeToDoPositionText.value = "";

		view.displayToDos();
	},

	deleteToDo: function(position) {
		//var deleteToDoButton = document.getElementById("deleteToDoButton");
		//var deleteToDoButtonInput = document.getElementById("deleteToDoButtonInput");
		todoList.deleteToDo(position);
		view.displayToDos();
	},

	toggleCompleted: function() {
		var toggleCompInputButton = document.getElementById("toggleCompdInputButton");
		var toggleCompInput = document.getElementById("toggleCompInput");

		todoList.toggleCompleted(toggleCompInput.valueAsNumber);

		toggleCompInput.value = "";

		view.displayToDos();

	},

	toggleAll: function() {
		todoList.toggleAll();

		view.displayToDos();
	}

};






var view = {
	displayToDos: function() {
		var todosUl = document.querySelector("ul");
		todosUl.innerHTML = "";
		for (var i = 0; i < todoList.todos.length; i++) {
			var todosLi = document.createElement("li");
			var todoTextWithCompletion = "";
			var todo = todoList.todos[i];


			if (todo.completed === true) {
				todoTextWithCompletion = '(x) ' + todo.todoText;
			} else {
				todoTextWithCompletion = '( ) ' + todo.todoText;
			}

			todosLi.id = i;
			todosLi.textContent = todoTextWithCompletion;
			todosLi.appendChild(this.createDeleteButton());
			todosUl.appendChild(todosLi);
		}
	},

	createDeleteButton: function() {
		var deleteButton = document.createElement("button");
		deleteButton.textContent = "Delete";
		deleteButton.className = "deleteButton";
		return deleteButton;
	},

	setUpEventListeners: function() {
		var todosUl = document.querySelector("ul");
		todosUl.addEventListener("click", function(event){
		console.log(event.target.parentNode.id);

		var elementClicked = event.target;
		if(elementClicked.className === "deleteButton"){
		buttonHandlers.deleteToDo(parseInt(elementClicked.parentNode.id));	
			}
		});	
	}
};
	view.setUpEventListeners();




{'fraction_non_alphanumeric': 0.14947293616013266, 'fraction_numerical': 0.0018950609972758499, 'mean_word_length': 3.5941240478781284, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1301601', 'n_tokens_mistral': 3364, 'n_tokens_neox': 2880, 'n_words': 472}