-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmeteogram.html
More file actions
183 lines (161 loc) · 6.42 KB
/
Copy pathmeteogram.html
File metadata and controls
183 lines (161 loc) · 6.42 KB
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
<link rel="stylesheet" href="./dist/skewt.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/marchingsquares@1.3.3/dist/marchingsquares.min.js"></script>
<script type="text/javascript" src="./dist/SkewT.js"></script>
<script type="text/javascript" src="./dist/skewt_function.js"></script>
<script type="text/javascript" src="./dist/meteogram.js"></script>
<style>
html,
body {
height: 95%;
width: 100%;
margin: 0px;
padding: 0px;
color: #222;
list-style: none;
text-decoration: none;
font-family: "Verdana", Helvetica, sans-serif;
box-sizing: border-box;
font-size: 11px;
}
#scrollUp,
#scrollDown {
position: fixed;
left: 5px;
width: 48px;
height: 48px;
border-radius: 50%;
border: none;
background: rgba(0,0,0,0.7);
color: white;
font-size: 20px;
z-index: 1000;
}
#scrollUp {
bottom: 80px;
}
#scrollDown {
bottom: 20px;
}
</style>
</head>
<body onload='fnBodyResize();' onresize='fnBodyResize();' onscroll='fnScroll();'>
<div id=main_container style="margin-top:4px;">
<div id=mto_container style='display:flex;'>
<div>
<div id=mto_timediv style='position:relative; z-index:200;'></div>
<div id=mto_chartdiv style='position:relative; overflow-y:auto; overflow-x:hidden;'></div>
</div>
</div>
<div id=mto_skew_container style='z-index:1500; background-color:white;'>
<div id=controlView style="font-size:13px; cursor:pointer; margin-left:auto; color:blue; text-decoration: underline;" onclick="toggleControl();">Skew-T Hide</div>
<div id=mto_skew_time style='min-height:15px; line-height:15px;'></div>
<div id=mto_skew_image style='width:400px; border:2px solid white;'></div>
</div>
</div>
<button id="scrollUp">▲</button>
<button id="scrollDown">▼</button>
<script>
var controlView = true;
var mto_data;
document.getElementById("scrollUp").onclick = function () {
document.getElementById("mto_chartdiv").scrollBy({
top: -50,
behavior: "smooth"
});
};
document.getElementById("scrollDown").onclick = function () {
document.getElementById("mto_chartdiv").scrollBy({
top: 50,
behavior: "smooth"
});
};
fetch("https://hunter3789.github.io/skewt-meteogram-web/meteogram_data.json")
.then(response => {
if (!response.ok) {
throw new Error("Failed to load JSON");
}
return response.json();
})
.then(data => {
console.log(data);
mto_data = data;
mto(mto_data, '#mto_timediv', '#mto_chartdiv', '#mto_skew_time', '#mto_skew_image');
})
.catch(error => {
console.error(error);
});
function fnBodyResize() {
if (window.innerWidth < 500) {
document.getElementById('mto_skew_image').style.width = "250px";
}
else if (window.innerWidth < 800) {
document.getElementById('mto_skew_image').style.width = window.innerWidth * 0.5 + "px";
}
else {
document.getElementById('mto_skew_image').style.width = "400px";
}
document.getElementById('main_container')
if (window.innerWidth > 1200) {
document.getElementById('mto_chartdiv').style.width = (window.innerWidth - 410) + "px";
document.getElementById('mto_chartdiv').style.height = (window.innerHeight - 45) + "px";
document.getElementById('mto_skew_container').style.position = "absolute";
document.getElementById('mto_skew_container').style.right = "0px";
document.getElementById('mto_skew_container').style.top = "0px";
document.getElementById('mto_skew_container').style.bottom = "";
if (!controlView) {
toggleControl();
}
}
else {
document.getElementById('mto_chartdiv').style.width = (window.innerWidth - 14) + "px";
document.getElementById('mto_chartdiv').style.height = (window.innerHeight - 45) + "px";
document.getElementById('mto_skew_container').style.position = "absolute";
document.getElementById('mto_skew_container').style.right = "0px";
if (window.innerHeight > 360) {
document.getElementById('mto_skew_container').style.bottom = "0px";
document.getElementById('mto_skew_container').style.top = "";
}
else {
document.getElementById('mto_skew_container').style.top = "0px";
document.getElementById('mto_skew_container').style.bottom = "";
}
if (controlView) {
toggleControl();
}
}
if (mto_data != undefined) {
mto(mto_data, '#mto_timediv', '#mto_chartdiv', '#mto_skew_time', '#mto_skew_image');
}
}
function fnScroll() {
if (window.innerWidth <= 1200) {
var scrollY = window.scrollY;
var scrollX = window.scrollX;
document.getElementById('mto_skew_container').style.transform = `translate(${scrollX}px, ${scrollY}px)`;
document.getElementById('mto_skew_container').style.right = "0px";
}
}
function toggleControl() {
var node = document.getElementById("controlView");
if (controlView) {
node.innerText = "Skew-T View";
document.getElementById("mto_skew_time").style.display = "none";
document.getElementById("mto_skew_image").style.display = "none";
}
else {
node.innerText = "Skew-T Hide";
document.getElementById("mto_skew_time").style.display = "block";
document.getElementById("mto_skew_image").style.display = "block";
}
controlView = !controlView;
}
</script>
</body>
</html>