Skip to content

Commit 0c4b2fc

Browse files
committed
Final Commit with CSS added
1 parent 4f16f88 commit 0c4b2fc

File tree

5 files changed

+70
-51
lines changed

5 files changed

+70
-51
lines changed

module1-solution/app.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

module1-solution/index.html

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
<title>Lunch Checker</title>
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="styles/bootstrap.min.css">
7-
<script src="angular.min.js"></script>
8-
<script src="app.js"></script>
7+
<link rel="stylesheet" href="styles/text.css">
8+
<script src="script/angular.min.js"></script>
9+
<script src="script/app.js"></script>
910
<style>
1011
.message { font-size: 1.3em; font-weight: bold; }
1112
</style>
@@ -14,17 +15,18 @@
1415
<div class="container">
1516
<h1>Lunch Checker</h1>
1617
<div ng-controller="LunchCheckController">
17-
<div class="form-group">
18-
<input id="lunch-menu" type="text"
18+
<div class="form-group"><!--do NOT consider and empty item, i.e., , , as an item towards to the count -->
19+
<input id="lunch-menu" type="text"
1920
placeholder="list comma separated dishes you usually have for lunch"
2021
class="form-control"
21-
ng-model = "name">
22+
ng-model = "name"
23+
ng-class="msgBorder">
2224
</div>
2325
<div class="form-group">
24-
<button class="btn btn-default" ng-click="check();">Check If Too Much</button>
26+
<button class="btn btn-default" ng-click="check();">Check If Too Much</button>
2527
</div>
26-
<div class="form-group message">
27-
{{messages}}
28+
<div class="form-group message" ng-class="msgClass">
29+
{{messages}}
2830
</div>
2931
</div>
3032
</div>
File renamed without changes.

module1-solution/script/app.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
(function () {
2+
3+
angular.module('LunchCheck', [])
4+
.controller('LunchCheckController', LunchCheckController);
5+
6+
LunchCheckController.$inject = ['$scope'];
7+
8+
function LunchCheckController($scope) {
9+
$scope.name = "";
10+
$scope.messages = "";//for message
11+
$scope.msgClass = "text-success";//for color of o/p msg
12+
$scope.msgBorder = "";//for border of input text box
13+
14+
$scope.check = function() {
15+
16+
var input = $scope.name;
17+
var numberOfTypes = input.split(",");
18+
var numberOfItems = 0;
19+
20+
for (var i = 0; i < numberOfTypes.length; i++) {
21+
if (numberOfTypes[i].trim() !== "") {
22+
numberOfItems ++;
23+
}
24+
}
25+
26+
if(numberOfItems === 0)
27+
{
28+
$scope.messages = "Please enter data first";
29+
$scope.msgClass = "text-danger";
30+
$scope.msgBorder = "messageError";
31+
}
32+
else if(numberOfItems <= 3)
33+
{
34+
$scope.messages = "Enjoy!";
35+
$scope.msgClass = "text-success";
36+
$scope.msgBorder = "messageSuccess";
37+
}
38+
else
39+
{
40+
$scope.messages = "Too much!";
41+
$scope.msgClass = "text-danger";
42+
$scope.msgBorder = "messageError";
43+
}
44+
};
45+
46+
};
47+
48+
49+
50+
51+
})();

module1-solution/styles/text.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.messageError
2+
{
3+
border-color: red;
4+
}
5+
6+
.messageSuccess
7+
{
8+
border-color: green;
9+
}

0 commit comments

Comments
 (0)