From 3ef4e82e2d2bb64af86d6733e440877b0ae69219 Mon Sep 17 00:00:00 2001 From: Philippa Johnstone Date: Mon, 30 Nov 2015 18:53:26 +0800 Subject: [PATCH 1/3] basics working --- app.js | 29 +++++++++++++++++++++++++++++ index.html | 31 +++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 app.js create mode 100644 index.html diff --git a/app.js b/app.js new file mode 100644 index 0000000..c4354f1 --- /dev/null +++ b/app.js @@ -0,0 +1,29 @@ +angular.module("happyApp", []) + + .controller("happyController", function ($scope){ + + // var date = Date.now(); + + $scope.allHappy = [ + + ]; + + $scope.newHappy = { + status : '', + date : '' + } + + $scope.addHappy = function () { + + $scope.allHappy.push({ + status : $scope.newHappy.status, + date : ''}) + + $scope.newHappy.status = ""; + + }; + + + }); + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..2c75a18 --- /dev/null +++ b/index.html @@ -0,0 +1,31 @@ + + + + Document + + + + + + +
+

HAPPYAPP

+

Generally average happiness over time, since 1986

+
+ +
+ + +
+ + + + + + + \ No newline at end of file From 09321b17839b7b306177d66472fa8eeae98ddb67 Mon Sep 17 00:00:00 2001 From: Philippa Johnstone Date: Mon, 30 Nov 2015 22:41:18 +0800 Subject: [PATCH 2/3] working with emoticon images, but no average rating --- app.js | 39 +++++++++++++++++++++++++++++++-------- index.html | 43 +++++++++++++++++++++++++++++++++++-------- style.css | 9 +++++++++ 3 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 style.css diff --git a/app.js b/app.js index c4354f1..81fcfe6 100644 --- a/app.js +++ b/app.js @@ -2,11 +2,8 @@ angular.module("happyApp", []) .controller("happyController", function ($scope){ - // var date = Date.now(); + $scope.allHappy = []; - $scope.allHappy = [ - - ]; $scope.newHappy = { status : '', @@ -14,16 +11,42 @@ angular.module("happyApp", []) } $scope.addHappy = function () { + $scope.date = new Date (); $scope.allHappy.push({ - status : $scope.newHappy.status, - date : ''}) + status : $scope.emoticonSelected, + date : $scope.date + }) - $scope.newHappy.status = ""; + $scope.emoticonSelected = ""; }; + console.log($scope.allHappy); + + $scope.getAverage = function () { + var averageArray = $scope.allHappy.map(function (string){ + if (string == 'happy') { + return 1; + } else if (string == 'ok') { + return 0; + } else { return -1}; + }) + + var total = 0; - }); + total = averageArray.reduce (function (a,b) { + return a + b; + }) + var avgerage = total/averageArray.length; + + if (avgerage >= 0.5) { + return 'Happy'; + } else if ( avgerage >= 0) { + return 'Ok'; + } else { return 'Sad'}; + + } +}); \ No newline at end of file diff --git a/index.html b/index.html index 2c75a18..ebd0036 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,8 @@ + + @@ -13,19 +15,44 @@

HAPPYAPP

Generally average happiness over time, since 1986

-
+ -
    -
  • - {{ happy.status }} - Day {{ $index +1 }} -
  • -
+ + + + + +
+ + +
Your'e emotional state is: {{ emoticonSelected }}
+
+ +
+ + + +
+

Your average rating is: {{ getAverage() }}

\ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..68ce7fb --- /dev/null +++ b/style.css @@ -0,0 +1,9 @@ +body { + font-family: 'Happy Monkey', cursive; + text-align: center; +} + +img { + height: 100px; + width: auto; +} \ No newline at end of file From d4ccd5e7650c5b779b13239108a86dd29982ffae Mon Sep 17 00:00:00 2001 From: Philippa Johnstone Date: Tue, 1 Dec 2015 23:32:15 +0800 Subject: [PATCH 3/3] no average ratings working --- app.js | 56 +++++++++++++++++++++++++++---------------------------- style.css | 12 ++++++++++++ 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/app.js b/app.js index 81fcfe6..de86764 100644 --- a/app.js +++ b/app.js @@ -4,11 +4,10 @@ angular.module("happyApp", []) $scope.allHappy = []; - - $scope.newHappy = { - status : '', - date : '' - } + // $scope.newHappy = { + // status : '', + // date : '' + // } $scope.addHappy = function () { $scope.date = new Date (); @@ -20,33 +19,34 @@ angular.module("happyApp", []) $scope.emoticonSelected = ""; - }; + console.log($scope.allHappy); + // angular.forEach(allHappy, function (){ + // console.log(allHappy.status); + // }) - console.log($scope.allHappy); + // $scope.getAverage = function () { + // var averageArray = $scope.allHappy.map(function (string){ + // if (string == 'happy') { + // return 1; + // } else if (string == 'ok') { + // return 0; + // } else { return -1}; + // }) - $scope.getAverage = function () { - var averageArray = $scope.allHappy.map(function (string){ - if (string == 'happy') { - return 1; - } else if (string == 'ok') { - return 0; - } else { return -1}; - }) + // var total = 0; - var total = 0; + // total = averageArray.reduce (function (a,b) { + // return a + b; + // }) - total = averageArray.reduce (function (a,b) { - return a + b; - }) + // var avgerage = total/averageArray.length; - var avgerage = total/averageArray.length; - - if (avgerage >= 0.5) { - return 'Happy'; - } else if ( avgerage >= 0) { - return 'Ok'; - } else { return 'Sad'}; - - } + // if (avgerage >= 0.5) { + // return 'Happy'; + // } else if ( avgerage >= 0) { + // return 'Ok'; + // } else { return 'Sad'}; + // } + }; }); \ No newline at end of file diff --git a/style.css b/style.css index 68ce7fb..b413310 100644 --- a/style.css +++ b/style.css @@ -6,4 +6,16 @@ body { img { height: 100px; width: auto; +} + +label > input{ /* HIDE RADIO */ + visibility: hidden; /* Makes input not-clickable */ + position: absolute; /* Remove input from document flow */ +} +label > input + img{ /* IMAGE STYLES */ + cursor:pointer; + border:2px solid transparent; +} +label > input:checked + img{ /* (RADIO CHECKED) IMAGE STYLES */ + border:2px solid #f00; } \ No newline at end of file