-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfee-calculator.js
90 lines (65 loc) · 2.21 KB
/
fee-calculator.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
const baseIncludes = [
["Reading of banns", 37],
["Fee to the PCC", 297],
["Fee to the Diocese", 247],
["Heating fee", 20],
["Verger's fee", 40],
["Organist's fee", 120]
]
const bellsItem = ["Ringing of bells", 50]
const choirItem = ["Choir's fee", 140]
const soloistItem = ["Soloist's fee", 40]
const erpOrganistItem = ["Permission to record organist's performance", 60]
const erpChoirItem = ["Permission to record choir's performance", 70]
const erpSoloistItem = ["Permission to record soloist's performance", 20]
const streamingItem = ["Live streaming of the service", 100]
const technicianItem = ["AV technician's fee", 95]
const memoryStickItem = ["Copy of service stream on a memory stick", 0]
function calculateCost() {
let includes = baseIncludes.slice()
const extraBells = document.getElementById('extraBells').checked
const extraChoir = document.getElementById('extraChoir').checked
const extraSoloist = document.getElementById('extraSoloist').checked
const extraOwnVideo = document.getElementById('extraOwnVideo').checked
const extraInHouseVideo = document.getElementById('extraInHouseVideo').checked
if (extraBells) {
includes.push(bellsItem)
}
if (extraChoir) {
includes.push(choirItem)
}
if (extraSoloist) {
includes.push(soloistItem)
}
// If we do either of the recording options, add record permissions
if (extraOwnVideo || extraInHouseVideo) {
includes.push(erpOrganistItem)
if (extraChoir) {
includes.push(erpChoirItem)
}
if (extraSoloist) {
includes.push(erpSoloistItem)
}
}
if (extraInHouseVideo) {
includes.push(streamingItem)
includes.push(technicianItem)
includes.push(memoryStickItem)
}
updateTotal(includes)
}
function updateTotal(includes) {
var includesList = ''
var totalCost = 0
includes.forEach(item => {
if (isNaN(item[1])) {
includesList += `<li>${item[0]} (N/A)</li>`
} else {
totalCost += item[1]
includesList += `<li>${item[0]} (£${item[1]})</li>`
}
});
document.getElementById("includesHeader").style.display = "block";
document.getElementById("total").innerHTML = `£${totalCost}`
document.getElementById('includesList').innerHTML = includesList
}