-
Notifications
You must be signed in to change notification settings - Fork 0
/
moneyApp.js
196 lines (174 loc) · 7.74 KB
/
moneyApp.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
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
//sending
const sendDoneButton = document.getElementById("sendDoneButton")
if (sendDoneButton) {
sendForm.addEventListener('submit', (event) => {
if (!event.submitter.dataset["submit"]) {
event.preventDefault()
}
if (document.getElementById('sendCashAmount').value && document.getElementById('sendNote').value) {
var personSelect = document.getElementById("sendPersonSelect")
if (personSelect.options[personSelect.selectedIndex].value != "?null") {
document.getElementById("confirmation").classList.remove("hidden")
document.getElementById('sendConfirm').innerHTML = "Are you sure you'd like to send $" + document.getElementById('sendCashAmount').value + " to " + document.getElementById("sendPersonSelect").options[document.getElementById("sendPersonSelect").selectedIndex].text + " for " + document.getElementById('sendNote').value + "?"
} else {
event.preventDefault()
alert("Please select who you'd like to send to")
}
} else {
event.preventDefault()
alert("Please fill in ALL fields or check that you only inputted numbers in the money field")
}
})
document.getElementById("sendConfirmYes").addEventListener('click', (event) => {
document.getElementById('sendCashAmount').value
})
document.getElementById("sendConfirmNo").addEventListener('click', (event) => {
document.getElementById("confirmation").classList.add("hidden")
event.preventDefault()
})
}
//requesting
const requestDoneButton = document.getElementById("requestDoneButton")
if (requestDoneButton) {
requestForm.addEventListener('submit', (event) => {
if (!event.submitter.dataset["submit"]) {
event.preventDefault()
}
if (document.getElementById('requestCashAmount').value && document.getElementById('requestNote').value) {
var personSelect = document.getElementById("requestPersonSelect")
if (personSelect.options[personSelect.selectedIndex].value != "?null") {
document.getElementById("confirmation").classList.remove("hidden")
document.getElementById('requestConfirm').innerHTML = "Are you sure you'd like to request $" + document.getElementById('requestCashAmount').value + " from " + document.getElementById("requestPersonSelect").options[document.getElementById("requestPersonSelect").selectedIndex].text + " for " + document.getElementById('requestNote').value + "?"
} else {
event.preventDefault()
alert("Please fill the person select field")
}
} else {
event.preventDefault()
alert("Please fill in ALL fields or check that you only inputted numbers in the money field")
}
})
document.getElementById("requestConfirmYes").addEventListener('click', (event) => {
document.getElementById('requestCashAmount').value
})
document.getElementById("requestConfirmNo").addEventListener('click', (event) => {
document.getElementById("confirmation").classList.add("hidden")
event.preventDefault()
})
}
//signing up
const signupForm = document.getElementById("signupForm")
if (signupForm) {
const passwordCreate = document.getElementById("passwordCreate")
const passwordCreateCheck = document.getElementById("passwordCreateCheck")
signupForm.addEventListener('submit', (event) => {
if (passwordCreate.value == passwordCreateCheck.value) {
document.getElementById("signupDoneButton").innerHTML = "create account"
} else {
alert("be sure your passwords match!")
event.preventDefault()
}
})
}
//entering family name
const familySetupForm = document.getElementById("familySetup");
const familyNameInput = document.getElementById("familyName")
if (familySetupForm){
familySetupForm.addEventListener('submit', (event) => {
if (!familyNameInput.value) {
alert("Please enter a family name!")
event.preventDefault()
}
})
}
//family edit page
if (document.getElementsByClassName('familyEditDOW')) {
Array.from(document.getElementsByClassName('familyEditDOW')).forEach(selectEl => {
selectEl.addEventListener('change', () => {
selectEl.classList.add('familyEditChanged')
})
})
}
//transaction history page
if (document.getElementById('filterIcon')) {
document.getElementById("filterIcon").addEventListener('click', (event) => {
document.getElementById("filtersContainer").classList.toggle("hidden")
document.getElementById("filterIcon").classList.toggle("open")
document.getElementById("filterIcon").classList.toggle("closed")
})
}
//index page
if (document.getElementById('topMessage')) {
setTimeout(() => {
document.getElementById("topMessage").classList.add("topMessageHidden")
document.getElementById("topMessage").classList.remove("topMessageShown")
}, 3000);
document.getElementById("topMessage").addEventListener('click', (event) => {
document.getElementById("topMessage").classList.add("topMessageHidden")
document.getElementById("topMessage").classList.remove("topMessageShown")
})
}
//navbar
if (document.getElementById('topBar')) {
window.onscroll = function () { scrollFunction('0') };
menuButton = document.getElementById("menuButton");
topBar = document.getElementById("topBar");
title = document.getElementById("title");
menu = document.getElementById("menu");
exitIcon = document.getElementById("exitIcon");
dimmedScreen = document.getElementById("dimmedScreen");
topBar.addEventListener('click', (event) => {
scrollFunction('1');
})
menuButton.addEventListener('click', (event) => {
menu.style.left = "0px";
})
exitIcon.addEventListener('click', (event) => {
menu.style.left = "-800px";
})
}
function scrollFunction(click) {
if (click == '1') {
topBar.style.height = "150px";
topBar.style.opacity = "1";
title.style.fontSize = "110px";
menuButton.style.width = "120px";
menuButton.style.height = "120px";
menuButton.style.transform = "rotate(0deg)";
menuButton.style.opacity = "1";
} else if (document.body.scrollTop > 80 || document.documentElement.scrollTop > 80) {
topBar.style.height = "80px";
topBar.style.opacity = "0.5";
title.style.fontSize = "40px";
menuButton.style.width = "80px";
menuButton.style.height = "80px";
menuButton.style.transform = "rotate(90deg)";
menuButton.style.opacity = "0";
} else {
topBar.style.height = "150px";
topBar.style.opacity = "1";
title.style.fontSize = "110px";
menuButton.style.width = "120px";
menuButton.style.height = "120px";
menuButton.style.transform = "rotate(0deg)";
menuButton.style.opacity = "1";
}
}
// promiseCards
const cards = document.getElementsByClassName('promiseCard')
Array.from(cards).forEach(card => {
card.addEventListener('click', () => {
card.classList.toggle('promiseCardFlipped')
Array.from(card.getElementsByClassName('promiseCardText')).forEach(text => {
setTimeout(() => {
text.classList.toggle('hidden')
Array.from(card.getElementsByClassName('promiseCardBack')).forEach(back => {
back.classList.toggle('hidden')
})
Array.from(card.getElementsByClassName('promiseCardBackground')).forEach(background => {
background.classList.toggle('hidden')
})
}, 150);
})
})
})