diff --git a/happy.png b/happy.png new file mode 100644 index 0000000..29deb74 Binary files /dev/null and b/happy.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..f423d43 --- /dev/null +++ b/index.html @@ -0,0 +1,34 @@ + + + + + HappyApp + + + + + + +
+

HAPPYAPP

+

General average happiness over time since 1986

+

History

+ +

Average rating: {{ getAvg() }}

+
+
+
+ Happy + OK + Unhappy +
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..8944780 --- /dev/null +++ b/js/app.js @@ -0,0 +1,34 @@ +angular.module('happyapp', []) + .controller('HappyController', HappyController) + + +function HappyController($scope){ + $scope.allEmotion = []; + + $scope.getAvg = function(){ + var eArr =$scope.allEmotion.map(function(str){ + if (str =='Happy'){ + return 1; + } else if (str == 'OK'){ + return 0; + } else { return -1}; + }) + var total = 0; + total = eArr.reduce(function(a,b){ + return a+b + }) + var avg = total / eArr.length; + if (avg>=0.5){ + return 'Happy'; + } else if ( avg >=0){ + return 'OK'; + } else {return 'Unhappy'}; + } + + $scope.addNewEmotion = function (){ + $scope.allEmotion.push($scope.dailyemotion); + $scope.dailyemotion = ''; + } +} + + diff --git a/ok.png b/ok.png new file mode 100644 index 0000000..92b660a Binary files /dev/null and b/ok.png differ diff --git a/unhappy.png b/unhappy.png new file mode 100644 index 0000000..6e50dbb Binary files /dev/null and b/unhappy.png differ