-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
66 lines (58 loc) · 1.92 KB
/
main.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
const deleteText = document.querySelectorAll('.fa-trash-xmark')
const thumbText = document.querySelectorAll('.fa-duotone fa-thumbs-up')
Array.from(deleteText).forEach((element) => {
element.addEventListener('click', deleteEvent)
})
Array.from(thumbText).forEach((element) => {
element.addEventListener('click', addLike)
})
async function deleteEvent() {
const fanName = this.parentNode.childNodes[1].innerText
const eventName = this.parentNode.childNodes[3].innerText
try {
const response = await fetch('deleteEvent', {
method: 'delete',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
'eventS': fanName,
'eventNameS': eventName,
'typeS': type,
'venueS': venue,
'locationS': location,
'setCountS': setCount,
'datesS': dates,
})
})
const data = await response.json()
console.log(data)
location.reload()
} catch (err) {
console.log(err)
}
}
async function addLike() {
const fanName = this.parentNode.childNodes[1].innerText
const eventName = this.parentNode.childNodes[3].innerText
const likes = Number(this.parentNode.childNodes[5].innerText)
try {
const response = await fetch('addOneLike', {
method: 'put',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
'eventS': fanName,
'eventNameS': eventName,
'typeS': type,
'venueS': venue,
'locationS': location,
'setCountS': setCount,
'datesS': dates,
'likeS': tlikes
})
})
const data = await response.json()
console.log(data)
location.reload()
} catch (err) {
console.log(err)
}
}