-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
213 lines (140 loc) · 5.12 KB
/
script.js
File metadata and controls
213 lines (140 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
let totalBill;
function totalBillFunc() {
totalBill = document.getElementById('userInputBill').value;
console.log(totalBill);
return totalBill;
};
// let subButton = document.getElementById('subButton');
// subButton.addEventListener('click', totalBillFunc, false);
let orderQuality;
function OrderQualityFunc() {
if (document.getElementById('userInputQualityFair').checked === true) {
orderQuality = 1.10;
} else if (document.getElementById('userInputQualityGood').checked === true) {
orderQuality = 1.15;
} else if (document.getElementById('userInputQualityAwesome').checked === true) {
orderQuality = 1.20;
} else {
orderQuality = 1.25;
};
};
// this disables the on checked boxes (should have used radio instead...)
$(':checkbox').change(function(){
// "this" is the current checkbox
$(':checkbox').not(this).prop('disabled', this.checked);
});
// };
// function OrderQualityGoodFunc() {
// OrderQuality = document.getElementById('userInputQualityGood').value;
// OrderQuality = 1.10;
// console.log(userInputQuality);
// return userInputQuality;
// };
// function OrderQualityAwesomeFunc() {
// OrderQuality = document.getElementById('userInputQualityAwesome').value;
// OrderQuality = 1.15;
// console.log(userInputQuality);
// return userInputQuality;
// };
// function OrderQualityOutstandingFunc() {
// OrderQuality = document.getElementById('userInputQualityOutstandingOutstandng').value;
// OrderQuality = 1.20;
// console.log(userInputQuality);
// return userInputQuality;
// };
let partySize;
function partySizeFunc() {
partySize = document.getElementById('userInputSize').value;
console.log(partySize);
return partySize;
};
let totalAfterTip;
let totalTip;
function calculateTotalFunc() {
totalAfterTip = (totalBill * orderQuality) / partySize;
totalAfterTip = Math.round(totalAfterTip * 100) / 100;
totalAfterTip = totalAfterTip.toFixed(2);
console.log(orderQuality);
console.log(totalAfterTip);
console.log(totalBill);
console.log(partySize);
document.getElementById("totalBillWithTip").placeholder = totalAfterTip;
return totalAfterTip;
}
function totalTipFunc() {
totalTip = (orderQuality * totalBill - totalBill);
totalAfterTip = Math.round(totalAfterTip * 100) / 100;
totalTip = totalTip.toFixed(2);
console.log(totalTip);
document.getElementById("totalTip").placeholder = totalTip;
return totalTip;
}
// let userInputBill = 10;
// Gets the variable set by the text box
// let totalBill = function() {
// let userInput = document.getElementById('userInputBill').value;
// //To make sure we have the correct value
// console.log(userInput);
// return userInput;
// }
// let totalBill;
// function totalBillFunc() {
// totalBill = document.getElementById('userInputBill').value;
// console.log(totalBill);
// return totalBill;
// };
// let subButton = document.getElementById('subButton');
// subButton.addEventListener('click', totalBillFunc, false);
// let totalBill;
// function totalBillFunc() {
// totalBill = document.getElementById('userInputBill').value;
// console.log(totalBill);
// return totalBill;
// };
// //new line
// // console.log(totalBill());
// // let calculator = {
// // add: function(a,b) {return a+b;
// // },
// // };
// // function (a,b){console.log("I don't exist!")};
// // //point is cleaner code scope management etc
// // console.log(calculator.add(1,2));
// // let totalBill = {
// // input: function(userInput) {
// // userInput = document.getElementById('userInputBill').value;
// // return userInput;
// // }
// // }
// // console.log(totalBill.input(userInputBill));
// function testFunc() {
// let newValue = totalBill * 1.5;
// console.log(newValue);
// return newValue;
// };
// let subButton2 = document.getElementById('subButton2');
// subButton2.addEventListener('click', testFunc, false);
// function calculateTip (){
// let totalBill = document.getElementById('userInputTotalBill').value
// let partySize = document.getElementById('userInputPartySize').value
// let serviceQuality = document.getElementById('userInputServiceQuality').value
// }
// console.log(totalBill.userInputBill);
// let numberOfGuests = function() {
// let userInput = document.getElementById('userInputGuests').value;
// //To make sure we have the correct value
// console.log(userInputGuests);
//}
// let numberOfGuests = function() {
// let userInput = document.getElementById('userInputGuests').value;
// //To make sure we have the correct value
// console.log(userInputGuests);
// }
// test line 2
// let qualityOfService = function() {
// let userInput = document.getElementById('userInputService').value;
// //To make sure we have the correct value
// console.log(userInputService);
// }
// var subButton = document.getElementById('subButton');
// subButton.addEventListener('click', getInput, false)