-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
632 lines (585 loc) · 28.5 KB
/
index.html
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style>
.heatLossCell, .refHeatLossCell, .referenceArea {
display: none;
}
.form-check {
display: flex;
align-items: center;
padding-top: 20px;
}
.form-check-input {
margin-top: 0px;
}
.center {
margin: auto;
width: 50%;
padding-top: 20px;
width: 80%;
}
.table {
margin-top: 20px;
margin-bottom: 20px;
border-width: 10px;
}
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield;
}
select {
max-width: 100%;
white-space: normal;
/* For Firefox: */
text-overflow: ellipsis;
height: 50px !important;
}
input {
height: 50px !important;
}
#referenceTable {
margin-top: 140px;
}
@media (max-width: 1079px) {
#referenceTable {
margin-top: 0px;
}
}
@media (min-width: 1100px) {
td, th, input, p, label, option, select {font-size:0.8rem !important;}
}
</style>
<div class="container-fluid center">
<h2>Building Code H1/AS1 Calculation Method</h2>
<div class="row">
<div class="col-lg-8">
<p>This tool implements the calculation method of the H1/AS1 Fifth Edition - Amendment 1. Please add your building's thermal envelope areas and R-values in the table below. Note that wall and roof areas are 'net' meaning that the area of any windows, doors and skylights must be subtracted.<br>
Additional rows can be added with the button at the top-right.
Please set the territorial authority in which the building is to be constructed below.
The climate zone will be looked up automatically.<br>
Please also tick when the building will be submitted for building consent. The new H1 changes are being phased and this changes the required R-values.<br>
The building is compliant with the calculation method if its heat loss is less than or equal to the reference building heat loss.<br>For building elements with embedded heating systems, the minimum construction R-values shall be determined through the Schedule method. These apply whenever building elements that are part of the thermal envelope include heating systems and may not be reduced by applying the Calculation method. Refer H1/AS1 2.1.1.3.</p>
</div>
</div>
<div class="row">
<div class="col-lg-8" style="display: table;">
<div class="row">
<div class="col-6" style="display: flex; align-items: flex-end;">
<label for="pickAuthority">Territorial Authority</label>
</div>
<div class="col-2">
<div>
<label style="text-align: center" for="climateZone_2008">Climate Zone: H1 4th Edition</label>
</div>
</div>
<div class="col-2">
<div>
<label style="text-align: center" for="climateZone">Climate Zone: H1 5th Edition</label>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<select class="form-control" name="pickAuthority" id="pickAuthority">
</select>
</div>
<div class="col-2">
<div>
<input class="form-control" readonly style="text-align: center; width: 100px;" id="climateZone_2008"></input>
</div>
</div>
<div class="col-2">
<div>
<input class="form-control" readonly style="text-align: center; width: 100px;" id="climateZone"></input>
</div>
</div>
</div>
<div class="row">
<div class="col-10">
<div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault" id="dateConsent_1May2023">
<label class="form-check-label" for="flexRadioDefault1">
Building consent will be submitted on or after 1 May 2023 but before 2 November 2023
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault" id="dateConsent_2Nov2023">
<label class="form-check-label" for="flexRadioDefault1">
Building consent will be submitted on or after 2 November 2023
</label>
</div>
</div>
<div class="col-2" style="display: flex; flex-direction: row-reverse; align-items: flex-end;">
<button id="addElement" class="float-right btn btn-secondary">+</button>
</div>
</div>
<table class="table table-striped table-bordered table-sm">
<thead>
<tr>
<th style="border-right: none !important;" colspan="3">Proposed Building</th>
<th style="text-align: right; border-left: none !important;" colspan="1">Total heat loss (W/K):</th>
<th style="text-align: right;" id="totalHeatLoss" colspan="2"></th>
</tr>
<tr>
<th style="text-align: right; border-left: none !important;" colspan="4">Glazing area to total wall area ratio:</th>
<th style="text-align: right;" id="windowToWallRatio" colspan="2"></th>
</tr>
<tr>
<th style="vertical-align: top; text-align: right; border-left: none !important;" colspan="4">Compliant:</th>
<th style="text-align: right; width: 300px;" id="compliant" colspan="2"></th>
</tr>
<tr>
<th>Building element type</th>
<th>Description</th>
<th style="text-align: right;">Net area (m2)</th>
<th style="text-align: right;">R-value</th>
<th style="text-align: right;">Heat loss (W/K)</th>
<th></th>
</tr>
</thead>
<tbody id="tableBody">
<tr>
<td>
<select class="form-control elementType">
<option>Wall</option>
<option>Roof</option>
<option>Slab-on-ground floor</option>
<option>Floor other than slab-on-ground</option>
<option>Window or glazed door</option>
<option>Opaque door or panel</option>
<option>Skylight</option>
</select>
</td>
<td>
<input id='description' placeholder='Optional' class="form-control"></input>
</td>
<td>
<input type="number" min=0 style="text-align: right;" value=0.0 class="form-control proposedArea"></input>
</td>
<td>
<input type="number" min=0 style="text-align: right;" value=0.0 class="form-control proposedRvalue"></input>
</td>
<td class="heatLossCell" style="text-align: right; padding-top: 20px;"></td>
<td class="heatLossCellDisp" style="text-align: right; padding-top: 20px;"></td>
<td>
<button style="margin-top: 5px; display:block; margin-left: auto; margin-right: auto;" id="deleteRow" class="btn btn-secondary">-</button>
</td>
</tr>
</tbody>
</table>
</div>
<div style="display: table;" class="col-lg-4">
<table id="referenceTable" class="table table-striped table-bordered table-sm">
<thead>
<tr>
<th style="border-right: none !important;" colspan="1">Reference Building</th>
<th style="text-align: right; border-left: none !important;" colspan="2">Total heat loss (W/K):</th>
<th style="text-align: right;" id="refTotalHeatLoss"></th>
</tr>
<tr>
<th>Building element type</th>
<th style="text-align: right;">Net area (m2)</th>
<th style="text-align: right;">R-value</th>
<th style="text-align: right;">Heat loss (W/K)</th>
</tr>
</thead>
<tbody id="refTableBody">
<tr>
<td class="elementType">Wall</td>
<td style="text-align: right;" class="referenceArea"></td>
<td style="text-align: right;" class="referenceAreaDisp"></td>
<td style="text-align: right;" class="referenceRvalue"></td>
<td style="text-align: right;" class="refHeatLossCell"></td>
<td style="text-align: right;" class="refHeatLossCellDisp"></td>
</tr>
<tr>
<td class="elementType">Roof</td>
<td style="text-align: right;" class="referenceArea"></td>
<td style="text-align: right;" class="referenceAreaDisp"></td>
<td style="text-align: right;" class="referenceRvalue"></td>
<td style="text-align: right;" class="refHeatLossCell"></td>
<td style="text-align: right;" class="refHeatLossCellDisp"></td>
</tr>
<tr>
<td class="elementType">Slab-on-ground floor</td>
<td style="text-align: right;" class="referenceArea"></td>
<td style="text-align: right;" class="referenceAreaDisp"></td>
<td style="text-align: right;" class="referenceRvalue"></td>
<td style="text-align: right;" class="refHeatLossCell"></td>
<td style="text-align: right;" class="refHeatLossCellDisp"></td>
</tr>
<tr>
<td class="elementType">Floor other than slab-on-ground</td>
<td style="text-align: right;" class="referenceArea"></td>
<td style="text-align: right;" class="referenceAreaDisp"></td>
<td style="text-align: right;" class="referenceRvalue"></td>
<td style="text-align: right;" class="refHeatLossCell"></td>
<td style="text-align: right;" class="refHeatLossCellDisp"></td>
</tr>
<tr>
<td class="elementType">Window or door</td>
<td style="text-align: right;" class="referenceArea"></td>
<td style="text-align: right;" class="referenceAreaDisp"></td>
<td style="text-align: right;" class="referenceRvalue"></td>
<td style="text-align: right;" class="refHeatLossCell"></td>
<td style="text-align: right;" class="refHeatLossCellDisp"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
let climateZoneData = {
'Ashburton District Council': ['3','5'],
'Auckland Council': ['1','1'],
'Buller District Council': ['3','4'],
'Carterton District Council': ['2','4'],
"Central Hawke’s Bay District Council": ['2','2'],
'Central Otago District Council': ['3','6'],
'Chatham Islands Council': ['3','3'],
'Christchurch City Council': ['3','5'],
'Clutha District Council': ['3','5'],
'Dunedin City Council': ['3','5'],
'Far North District Council': ['1','1'],
'Gisborne District Council': ['2','2'],
'Gore District Council': ['3','6'],
'Grey District Council': ['3','4'],
'Hamilton City Council': ['2','2'],
'Hastings District Council': ['2','2'],
'Hauraki District Council': ['1','2'],
'Horowhenua District Council': ['2','3'],
'Hurunui District Council': ['3','5'],
'Hutt City Council': ['2','3'],
'Invercargill City Council': ['3','6'],
'Kaikōura District Council': ['3','3'],
'Kaipara District Council': ['1','1'],
'Kapiti Coast District Council': ['2','3'],
'Kawerau District Council': ['2','1'],
'Mackenzie District Council': ['3','6'],
'Manawatu District Council': ['2','3'],
'Marlborough District Council': ['3','3'],
'Masterton District Council': ['2','4'],
'Matamata–Piako District Council': ['2','2'],
'Napier City Council': ['2','2'],
'Nelson City Council': ['3','3'],
'New Plymouth District Council': ['2','2'],
'Ōpōtiki District Council': ['2','1'],
'Otorohanga District Council': ['2','2'],
'Palmerston North City Council': ['2','3'],
'Porirua City Council': ['2','3'],
'Queenstown–Lakes District Council': ['3','6'],
"Rangitikei District Council (north of 39o50'S (-39.83))": ['3','4'],
"Rangitikei District Council (south of 39o50'S (-39.83))": ['3','3'],
'Rotorua District Council': ['2','4'],
'Ruapehu District Council': ['3','4'],
'Selwyn District Council': ['3','5'],
'South Taranaki District Council': ['2','2'],
'South Waikato District Council': ['2','2'],
'South Wairarapa District Council': ['2','4'],
'Southland District Council': ['3','6'],
'Stratford District Council': ['2','2'],
'Tararua District Council': ['2','4'],
'Tasman District Council': ['3','3'],
'Taupō District Council': ['3','4'],
'Tauranga City Council': ['2','1'],
'Thames–Coromandel District Council': ['1','1'],
'Timaru District Council': ['3','5'],
'Upper Hutt City Council': ['2','4'],
'Waikato District Council': ['2','2'],
'Waimakariri District Council': ['3','5'],
'Waimate District Council': ['3','5'],
'Waipa District Council': ['2','2'],
'Wairoa District Council': ['2','2'],
'Waitaki District (true left of the Otekaieke river)': ['3','6'],
'Waitaki District (true right of the Otekaieke river)': ['3','5'],
'Waitomo District Council': ['2','2'],
'Wellington City Council': ['2','3'],
'Western Bay of Plenty District Council': ['2','1'],
'Westland District Council': ['3','4'],
'Whakatane District Council': ['2','1'],
'Whanganui District Council': ['2','2'],
'Whangarei District Council': ['1','1']
}
let mbieRvalues_2021 = {
'Wall': {
1: [2.0, 2.0],
2: [2.0, 2.0],
3: [2.0, 2.0],
4: [2.0, 2.0],
5: [2.0, 2.0],
6: [2.0, 2.0]
},
'Roof': {
1: [6.6, 6.6],
2: [6.6, 6.6],
3: [6.6, 6.6],
4: [6.6, 6.6],
5: [6.6, 6.6],
6: [6.6, 6.6]
},
'Slab-on-ground floor': {
1: [1.5, 1.5],
2: [1.5, 1.5],
3: [1.5, 1.5],
4: [1.5, 1.5],
5: [1.6, 1.6],
6: [1.7, 1.7]
},
'Floor other than slab-on-ground': {
1: [2.5, 2.5],
2: [2.5, 2.5],
3: [2.5, 2.5],
4: [2.8, 2.8],
5: [3.0, 3.0],
6: [3.0, 3.0]
},
'Window or glazed door': {
1: [0.37, 0.46],
2: [0.37, 0.46],
3: [0.46, 0.46],
4: [0.46, 0.46],
5: [0.50, 0.50],
6: [0.50, 0.50]
},
'Window or door': {
1: [0.37, 0.46],
2: [0.37, 0.46],
3: [0.46, 0.46],
4: [0.46, 0.46],
5: [0.50, 0.50],
6: [0.50, 0.50]
},
'Opaque door or panel': {
1: [0.37, 0.46],
2: [0.37, 0.46],
3: [0.46, 0.46],
4: [0.46, 0.46],
5: [0.50, 0.50],
6: [0.50, 0.50]
},
'Skylight': {
1: ['N/A', 'N/A'],
2: ['N/A', 'N/A'],
3: ['N/A', 'N/A'],
4: ['N/A', 'N/A'],
5: ['N/A', 'N/A'],
6: ['N/A', 'N/A']
}
}
let territorialAuthorities = Object.keys(climateZoneData)
let authorityList = document.getElementById('pickAuthority')
for (let i = 0; i < territorialAuthorities.length; i++) {
authorityList.innerHTML += "<option>" + territorialAuthorities[i] + "</option>"
}
let tableBody = document.getElementById('tableBody')
function updateRvalues() {
let climateZone_2008 = climateZoneData[document.getElementById('pickAuthority').value][0]
let climateZone = climateZoneData[document.getElementById('pickAuthority').value][1]
let tableBody = document.getElementById('tableBody')
let refTableBody = document.getElementById('refTableBody')
var windowAreaTotal = 0.0
var wallAreaTotal = 0.0
var grossWallArea = 0.0
var roofAreaTotal = 0.0
var skylightAreaTotal = 0.0
var slabAreaTotal = 0.0
var nonSlabAreaTotal = 0.0
var totalHeatLoss = 0.0
var refTotalHeatLoss = 0.0
var verticalGlazingArea = 0.0
document.getElementById('climateZone_2008').value = climateZone_2008;
document.getElementById('climateZone').value = climateZone;
for (let i = 0, row; row = tableBody.rows[i]; i++) {
let proposedRvalue = row.querySelector('.proposedRvalue').value
let proposedArea = row.querySelector('.proposedArea').value
let heatLossCell = row.querySelector('.heatLossCell')
let heatLossCellDisp = row.querySelector('.heatLossCellDisp')
let elementType = row.querySelector('.elementType');
if (proposedArea != 0 && proposedRvalue != 0) {
heatLossCell.innerHTML = (proposedArea / proposedRvalue)
}
else {
heatLossCell.innerHTML = 0.0
}
heatLossCellDisp.innerHTML = parseFloat(heatLossCell.innerHTML).toFixed(1)
if (elementType.value == 'Window or glazed door' || elementType.value == 'Opaque door or panel') {
windowAreaTotal += parseFloat(row.querySelector('.proposedArea').value)
}
if (elementType.value == 'Window or glazed door') {
verticalGlazingArea += parseFloat(row.querySelector('.proposedArea').value)
}
if (elementType.value == 'Wall') {
wallAreaTotal += parseFloat(row.querySelector('.proposedArea').value)
}
if (elementType.value == 'Roof') {
roofAreaTotal += parseFloat(row.querySelector('.proposedArea').value)
}
if (elementType.value == 'Slab-on-ground floor') {
slabAreaTotal += parseFloat(row.querySelector('.proposedArea').value)
}
if (elementType.value == 'Floor other than slab-on-ground') {
nonSlabAreaTotal += parseFloat(row.querySelector('.proposedArea').value)
}
if (elementType.value == 'Skylight') {
skylightAreaTotal += parseFloat(row.querySelector('.proposedArea').value)
}
totalHeatLoss += parseFloat(heatLossCell.innerHTML)
}
document.getElementById('totalHeatLoss').innerHTML = totalHeatLoss.toFixed(1)
grossWallArea = windowAreaTotal + wallAreaTotal
if (verticalGlazingArea != 0 && grossWallArea != 0) {
windowToWallRatio = (verticalGlazingArea / grossWallArea) * 100
} else {
windowToWallRatio = 0
}
document.getElementById('windowToWallRatio').innerHTML = windowToWallRatio.toFixed(1) + '%'
for (let i = 0, row; row = refTableBody.rows[i]; i++) {
let elementType = row.querySelector('.elementType');
let referenceRvalueCell = row.querySelector('.referenceRvalue');
if ($('#dateConsent_1May2023').prop("checked")) {
var referenceRvalue = mbieRvalues_2021[elementType.innerHTML][climateZone][0]
} else if ($('#dateConsent_2Nov2023').prop("checked")) {
var referenceRvalue = mbieRvalues_2021[elementType.innerHTML][climateZone][1]
}
referenceRvalueCell.innerHTML = referenceRvalue
if (elementType.innerHTML == 'Window or door') {
row.querySelector('.referenceArea').innerHTML = (grossWallArea * 0.3);
row.querySelector('.referenceAreaDisp').innerHTML = (grossWallArea * 0.3).toFixed(1);
}
if (elementType.innerHTML == 'Wall') {
row.querySelector('.referenceArea').innerHTML = (grossWallArea * 0.7);
row.querySelector('.referenceAreaDisp').innerHTML = (grossWallArea * 0.7).toFixed(1);
}
if (elementType.innerHTML == 'Roof') {
row.querySelector('.referenceArea').innerHTML = (roofAreaTotal + skylightAreaTotal);
row.querySelector('.referenceAreaDisp').innerHTML = (roofAreaTotal + skylightAreaTotal).toFixed(1);
}
if (elementType.innerHTML == 'Slab-on-ground floor') {
row.querySelector('.referenceArea').innerHTML = slabAreaTotal
row.querySelector('.referenceAreaDisp').innerHTML = slabAreaTotal.toFixed(1)
}
if (elementType.innerHTML == 'Floor other than slab-on-ground') {
row.querySelector('.referenceArea').innerHTML = nonSlabAreaTotal
row.querySelector('.referenceAreaDisp').innerHTML = nonSlabAreaTotal.toFixed(1)
}
let referenceArea = row.querySelector('.referenceArea').innerHTML
let refHeatLossCell = row.querySelector('.refHeatLossCell')
let refHeatLossCellDisp = row.querySelector('.refHeatLossCellDisp')
if (referenceArea != 0 && referenceRvalue != 0) {
refHeatLossCell.innerHTML = (referenceArea / referenceRvalue)
}
else {
refHeatLossCell.innerHTML = (0).toFixed(1)
}
refHeatLossCellDisp.innerHTML = parseFloat(refHeatLossCell.innerHTML).toFixed(1)
refTotalHeatLoss += parseFloat(refHeatLossCell.innerHTML)
}
document.getElementById('refTotalHeatLoss').innerHTML = refTotalHeatLoss.toFixed(1)
//check R-value is greater than half reference R-value
var rValueCheck = true
for (let i = 0, row; row = tableBody.rows[i]; i++) {
let proposedRvalue = row.querySelector('.proposedRvalue').value
let elementType = row.querySelector('.elementType').value;
let proposedRvalueCell = row.querySelector('.proposedRvalue');
if (proposedRvalueCell.nextSibling.nextSibling) {
proposedRvalueCell.nextSibling.nextSibling.remove();
}
if (elementType == 'Wall' ||
elementType == 'Floor' ||
elementType == 'Slab-on-ground floor' ||
elementType == 'Floor other than slab-on-ground' ||
elementType == 'Roof') {
for (let x = 0, refrow; refrow = refTableBody.rows[x]; x++) {
let refElementType = refrow.querySelector('.elementType').innerHTML;
if (refElementType == elementType) {
referenceRvalue = refrow.querySelector('.referenceRvalue').innerHTML;
if (proposedRvalue < 0.5 * referenceRvalue && proposedRvalue != 0) {
rValueCheck = false
let warning = document.createElement("p");
warning.innerHTML = "Value must be greater than 50% of reference R-value";
warning.style.cssText = 'color: red; padding-top: 5px; margin: 0px'
proposedRvalueCell.parentElement.append(warning)
}
}
}
}
}
if (rValueCheck == false) {
document.getElementById('compliant').innerHTML = 'No. All wall, roof and floor R-values must be at least 50% of the reference R-value.'
} else {
if (windowToWallRatio > 40) {
document.getElementById('compliant').innerHTML = 'N/A. The window-to-wall ratio must be less than 40%.'
} else {
if (totalHeatLoss <= refTotalHeatLoss) {
document.getElementById('compliant').innerHTML = 'Yes, the proposed building heat loss is less than the reference heat loss'
} else {
document.getElementById('compliant').innerHTML = 'No, the proposed building heat loss is greater than the reference heat loss'
}
}
}
}
$(document).on('click', '#deleteRow', function() {
let tableBody = document.getElementById('tableBody')
var rows = tableBody.getElementsByTagName('tr');
if (rows.length > 1) {
let rowToDelete = this.parentElement.parentElement
rowToDelete.remove()
updateRvalues()
}
});
function addRow(type) {
let tableBody = document.getElementById('tableBody')
var rows = tableBody.getElementsByTagName('tr');
var clone = cloneEl(rows[rows.length - 1]);
clone.querySelector('.elementType').value = type
clone.querySelector('#description').value = ''
clone.querySelector('#description').placeholder = "Optional"
clone.querySelector('.proposedArea').value = (0.0).toFixed(1)
clone.querySelector('.proposedRvalue').value = 0.0.toFixed(1)
tableBody.appendChild(clone);
}
function cloneEl(el) {
var clo = el.cloneNode(true);
return clo;
}
const startUpElements = [
'Roof',
'Slab-on-ground floor',
'Window or glazed door',
'Opaque door or panel',
'Skylight'
]
for (let i = 0; i < 5; i++) {
addRow(startUpElements[i])
}
updateRvalues()
$(document).on('click', '#addElement', function() {
addRow('Wall')
updateRvalues()
})
$(document).on('click', '.elementType', function() {
updateRvalues()
})
$(document).on('change', '#dateConsent_3Nov2022, #dateConsent_1May2023, #dateConsent_2Nov2023, .proposedRvalue, .proposedArea, #pickAuthority', function() {
updateRvalues();
});
window.addEventListener('beforeunload', function (e) {
e.preventDefault(); // If you prevent default behavior in Mozilla Firefox prompt will always be shown
// Chrome requires returnValue to be set
e.returnValue = '';
});
</script>