-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
82 lines (70 loc) · 2.32 KB
/
app.js
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
//part one
function updateCaseNumber(isIncreasing) {
const caseInput = document.getElementById('case-number');
let caseNumber = caseInput.value;
if (isIncreasing) {
caseInput.value = 180;
}
else {
caseInput.value = 0;
}
//update case total
const caseTotal = document.getElementById('case-total');
caseTotal.innerText = parseInt(caseInput.value) + 1299;
}
//storage increase decrease events
//handle case increase decrease events
document.getElementById('memory-plus').addEventListener('click', function () {
updateCaseNumber(true);
});
document.getElementById('memory-minus').addEventListener('click', function () {
updateCaseNumber(false);
});
//part three
function updateCaseNumber2(isIncreas) {
const caseInput = document.getElementById('case-charge');
let caseNumber = caseInput.value;
if (isIncreas) {
caseInput.value = 0;
}
else {
caseInput.value = 20;
}
//update case total
const caseTotal = document.getElementById('case-total');
caseTotal.innerText = parseInt(caseInput.value) + 1299;
}
//storage increase decrease events
//handle case increase decrease events
document.getElementById('delivery1').addEventListener('click', function () {
updateCaseNumber2(true);
});
document.getElementById('delivery2').addEventListener('click', function () {
updateCaseNumber2(false);
});
//part two
document.getElementById('storage1').addEventListener('click',function(){
const caseInput = document.getElementById('case-storage');
const caseNumber = caseInput.value;
caseInput.value = 0;
});
document.getElementById('storage2').addEventListener('click',function(){
const caseInput = document.getElementById('case-storage');
const caseNumber = caseInput.value;
caseInput.value = 100;
});
document.getElementById('storage3').addEventListener('click',function(){
const caseInput = document.getElementById('case-storage');
const caseNumber = caseInput.value;
caseInput.value = 180;
});
//promo code
document.getElementById('user-promo').addEventListener('click', function () {
// get user promo
constpromoField = document.getElementById('promo');
const userPromo = passwordField.value;
// check promo
if ( userPassword == 'stevekaku') {
document.getElementById('case-total');
}
});