diff --git a/todo-src/index.html b/todo-src/index.html index 89203ad..99e0032 100644 --- a/todo-src/index.html +++ b/todo-src/index.html @@ -1,44 +1,91 @@ - - + + - - - - - - - - + + + + + + + + +

My little to do app!

- -
- -
- + +
+
+ +
+ + +
+
+ +
+
- - -
- -

stuff i gotta do asap

- -
    - -
  • + + + + +
+ + +
+
+

stuff i gotta do asap

+ -
- - + {{do.name}} + +
+ + +
+ + +
+ + + + + + +
+ +
+ + + +
+ - + + +
+ + diff --git a/todo-src/script.js b/todo-src/script.js index fe21743..702175e 100644 --- a/todo-src/script.js +++ b/todo-src/script.js @@ -1,36 +1,66 @@ -// Code goes here - -var myApp = angular.module('app', []); - -myApp.controller('MainCtrl', function ($scope){ - $scope.todos = ["Learn Angular", "Learn node"]; +// Code goes here + + +var myApp = angular.module('app', []); + + +myApp.controller('MainCtrl', function ($scope){ + $scope.todos = []; $scope.newItem = ""; - - $scope.addItem = function(){ - console.log("in add"); - if ($scope.newItem !== ""){ - $scope.todos.push($scope.newItem); + //used to safeguard against undefined + var un_defined; + + $scope.addItem = function(){ + console.log("add"); + if ($scope.newItem !== "" && $scope.priority !== un_defined){ + $scope.todos.push({name:$scope.newItem, priority:$scope.priority});} + $scope.todos.sort(function(a,b) { + if(a.priority > b.priority) {return 1;} + if(a.priority < b.priority) {return -1;} + return 0; + }); $scope.newItem = ""; - } + } + + $scope.deleteItem = function(index){ + console.log("delete"); + $scope.todos.splice(index, 1); } - - $scope.deleteItem = function(item){ - console.log("in delete"); + + $scope.editItem = function(item, uInput, priority){ + console.log("in edit"); var index = $scope.todos.indexOf(item); - $scope.todos.splice(index, 1); - } + if (uInput) { + $scope.todos[index].name = uInput; + } + else{ + $scope.todos[index].name = $scope.todos[index].name; + } + $scope.uInput = ""; - -}); + $scope.todos[index].priority = priority; + //if (1){ + //$scope.todos.splice(index, 1); + //$scope.todos.push({name:uInput, priority:priority});} + $scope.todos.sort(function(a,b) { + if(a.priority > b.priority) {return 1;} + if(a.priority < b.priority) {return -1;} + return 0; + }); -/************************* - * Homework (not rly): - * - "enter" button functionality instead of clicking button - * - edit button functionality - * - button to mark item as "complete" - * - have a total number of items at the top - * - make it prettier - * - add a due date - * - add reminder (setInterval) - * - * *********************/ \ No newline at end of file + } + +}); + + + /************************* + * Homework (not rly): + * - "enter" button functionality instead of clicking button + * - edit button functionality + * - button to mark item as "complete" + * - have a total number of items at the top + * - make it prettier + * - add a due date + * - add reminder (setInterval) + * + * *********************/ diff --git a/todo-src/style.css b/todo-src/style.css index eb51b03..d694848 100644 --- a/todo-src/style.css +++ b/todo-src/style.css @@ -1,4 +1,16 @@ -/* Styles go here */ -body { - background: green; +/* Styles go here */ +body { + background: green; +} +/*Priority coloring*/ +.High { + color: red; } + +.Med { + color: orange; +} +/*must be lower case to enforce sorting order of High, Medium, low....i.e. capital M comes before lower case l but after uppercase L*/ +.low { + color: black; +} \ No newline at end of file