diff --git a/todo-src/index.html b/todo-src/index.html index 89203ad..d3652d0 100644 --- a/todo-src/index.html +++ b/todo-src/index.html @@ -14,29 +14,55 @@

My little to do app!

-
- - - - +
+
+ + -

stuff i gotta do asap

+ +

stuff i gotta do asap: total things to do

+ -
+
+ +
+
+ +
+
+ +
+ + - - + +
diff --git a/todo-src/script.js b/todo-src/script.js index fe21743..a9d469d 100644 --- a/todo-src/script.js +++ b/todo-src/script.js @@ -4,23 +4,111 @@ var myApp = angular.module('app', []); myApp.controller('MainCtrl', function ($scope){ $scope.todos = ["Learn Angular", "Learn node"]; + $scope.dones = [false, false]; + $scope.editor = { text : null, index : null }; $scope.newItem = ""; - + $scope.addItem = function(){ + + console.log("in add"); + if ($scope.newItem !== ""){ + if($scope.todos.indexOf($scope.newItem) === -1){ + $scope.todos.push($scope.newItem); + } + $scope.newItem = ""; + } + } + + $scope.addItemHigh = function(){ console.log("in add"); if ($scope.newItem !== ""){ - $scope.todos.push($scope.newItem); + $scope.todos.push("NOW: " + $scope.newItem); $scope.newItem = ""; } } + + $scope.addItemMedium = function(){ + console.log("in add"); + if ($scope.newItem !== ""){ + $scope.todos.push("TOMORROW: " + $scope.newItem); + $scope.newItem = ""; + } + } + + $scope.addItemLow = function(){ + console.log("in add"); + if ($scope.newItem !== ""){ + $scope.todos.push("SOMEDAY: " + $scope.newItem); + $scope.newItem = ""; + } + } + + $scope.editItem = function(item){ + console.log("in edit"); + var index = $scope.todos.indexOf(item); + $scope.editor.index = index; + $scope.editor.text = item; + } + + $scope.saveItem = function(item){ + console.log("in save"); + $scope.todos[$scope.editor.index] = $scope.editor.text; + $scope.editor.index = null; + } + + $scope.cancelItem = function(item){ + console.log("in cancel"); + $scope.editor.index = null; + } + + $scope.editingMode = function(item){ + var index = $scope.todos.indexOf(item); + return $scope.editor.index === index; + } + $scope.deleteItem = function(item){ console.log("in delete"); var index = $scope.todos.indexOf(item); $scope.todos.splice(index, 1); + $scope.dones.splice(index, 1); } + + $scope.toggleItem = function(item){ + console.log("in toggle"); + var index = $scope.todos.indexOf(item); + $scope.dones[index] = !$scope.dones[index]; + } + + $scope.getActive = function(item){ + console.log("in toggle"); + var index = $scope.todos.indexOf(item); + return !$scope.dones[index]; + } + + $scope.deleteAll = function(){ + var length = $scope.dones.length; //get all the todos in the list + if(length !== 0){ + var a = confirm("Are you really sure you want to do this?"); + if(a){ + console.log("deleted All"); + for(i = 0; i < length; i++){ + if($scope.dones[i]){ + $scope.todos.splice(i,0); //delete all them from the list + $scope.dones.splice(i,0); + } + } + } + } + } + + $scope.get_len = function() { + return $scope.todos.length; + } + + }); /************************* diff --git a/todo-src/style.css b/todo-src/style.css index eb51b03..58e1723 100644 --- a/todo-src/style.css +++ b/todo-src/style.css @@ -1,4 +1,12 @@ /* Styles go here */ -body { - background: green; + +/*1.Change the background color of the to-do app*/ +body{ + background-color: #e7e7f6; } + +#DeleteAll { + background-color: red; + color: white; + +} \ No newline at end of file