sidebar.js 3.38 KB
Newer Older
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
1
2
3
4
5
6
var chartButton = document.getElementById('chartButton');
var heatingdemand = document.getElementById('filterswitch2');
var radio = document.getElementById('radio-group');
var filterswitches = document.getElementById('filterswitches');

//Show / hide chart
7
8
9
10
chartButton.addEventListener('click', function() {
    //sets as default attribute building function
    myChartArea("bar", "Building Function", 1, "Building Type", "Frequency", coloR);
    addGlobalData(areaChart, buildingType, btFrequency, btFrequency.length)
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
11

12
13
    if (drawBox === false) {
        swal("CAN'T LOAD DATA!", "mark an area first!", "error");
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
14
    } else {
15
        var x = document.getElementById('areaChartContainer');
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
16

17
18
19
20
21
22
23
24
        if (x.style.visibility === 'visible') {
            //button.firstChild.data = "Show chart";
            x.style.visibility = 'hidden';
        } else {
            //button.firstChild.data = "Hide chart";
            x.style.visibility = 'visible';
        }
    }
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
25
26
}, false);

27
28
29
30
31
32
heatingdemand.addEventListener('click', function() {
    var x = document.getElementById('heat-demand-legend');
    if (!document.getElementById('checkbox2').checked) {
        x.style.visibility = 'hidden';
    } else {
        x.style.visibility = 'visible';
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
33
34
35
    }
}, false);

36
radio.addEventListener('click', function() {
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
37
    if (document.getElementById("surface").checked) {
38
39
40
41
42
43
44
45
46
47
48
49
50
51
        document.getElementById("checkbox1").disabled = false;
        document.getElementById("checkbox2").disabled = true;
        if (document.getElementById("checkbox2").checked) {
            document.getElementById("checkbox2").checked = false;
            document.getElementById('heat-demand-legend').style.visibility = 'hidden';
            tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
        }
    } else {
        document.getElementById("checkbox1").disabled = true;
        document.getElementById("checkbox2").disabled = false;
        if (document.getElementById("checkbox1").checked) {
            document.getElementById("checkbox1").checked = false;
            tileContent.forEach(t => t.color = new Cesium.Color(1, 1, 1, 1))
        }
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
52
    }
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
}, false);

filterswitches.addEventListener('click', function() {
    if (drawBox === false) {
        swal("CAN'T LOAD DATA!", "mark an area first!", "error");
        document.getElementById("checkbox2").disabled = true;
        document.getElementById("checkbox1").disabled = true;
    } else {
        if (document.getElementById("surface").checked) {
            document.getElementById("checkbox1").disabled = false;
            document.getElementById("checkbox2").disabled = true;
        } else {
            document.getElementById("checkbox1").disabled = true;
            document.getElementById("checkbox2").disabled = false;
        }
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
68
69
70
71
72
    }

}, false);

function toggleSidebar(ref) {
73
    document.getElementById("sidebar").classList.toggle('active');
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
74
75
76
77
78
79
80
}

//loop through all dropdown buttons to toggle between hiding and showing its dropdown content
var dropdown = document.getElementsByClassName("dropdown-btn");
var i;

for (i = 0; i < dropdown.length; i++) {
81
82
83
84
85
86
87
88
89
    dropdown[i].addEventListener("click", function() {
        this.classList.toggle("active");
        var dropdownContent = this.nextElementSibling;
        if (dropdownContent.style.display === "block") {
            dropdownContent.style.display = "none";
        } else {
            dropdownContent.style.display = "block";
        }
    });
JOE Thunyathep S's avatar
update  
JOE Thunyathep S committed
90
}