-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
98 lines (84 loc) · 2.5 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
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
import {
threeInit,
setMeasurements,
targetPercentage,
sgDg,
} from "./modules/threeInit";
import {
valuesStartEnd,
measureLocation,
fetchSiteData,
} from "./modules/fetchApi.js";
import { FluidMeter } from "./modules/js-fluid-meter.js";
import { playFunction } from "./modules/playpause-icon.js";
export const playbtn = document.getElementById("play-pause");
measureLocation().then((locations) => {
const dropdown = document.getElementById("location");
// Build options list from this data
locations.forEach((location) => {
const option = document.createElement("option");
option.value = location.Code;
option.text = location.Description;
dropdown.appendChild(option);
});
});
document
.querySelector('form[name="data"]')
.addEventListener("submit", function (event) {
event.preventDefault();
const location = document.getElementById("location").value;
const startDate = document.getElementById("startdate").value;
const endDate = document.getElementById("enddate").value;
fetchSiteData(location).then((siteData) => {
valuesStartEnd(startDate, endDate, location).then((measurements) => {
setMeasurements({ measurements, sgDg: siteData });
});
});
});
threeInit();
const today = new Date().toISOString().split("T")[0];
document.getElementById("startdate").setAttribute("max", today);
document.getElementById("enddate").setAttribute("max", today);
const startDateInput = document.getElementById("startdate");
const endDateInput = document.getElementById("enddate");
startDateInput.addEventListener("change", function () {
endDateInput.min = this.value;
});
var fm3 = new FluidMeter();
fm3.init({
targetContainer: document.getElementById("fluid-meter-3"),
fillPercentage: 45,
options: {
fontSize: "30px",
drawPercentageSign: true,
drawBubbles: false,
size: 300,
borderWidth: 0,
backgroundColor: "#e2e2e2",
foregroundColor: "#1F2937",
foregroundFluidLayer: {
fillStyle: "#16E1FF",
angularSpeed: 5,
maxAmplitude: 5,
frequency: 30,
horizontalSpeed: -20,
},
backgroundFluidLayer: {
fillStyle: "#4F8FC6",
angularSpeed: 5,
maxAmplitude: 3,
frequency: 22,
horizontalSpeed: 20,
},
},
});
window.onload = function () {
const playbtn = document.getElementById("play-pause");
playbtn.disabled = true;
setInterval(function () {
fm3.setPercentage(targetPercentage);
});
};
playbtn.addEventListener("click", function () {
playFunction(playbtn);
});