-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
131 lines (113 loc) · 3.77 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
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>WebGL Globe</title>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600" rel="stylesheet">
<link rel="stylesheet" href="fontawesome-free-5.4.1-web/css/all.css">
<script src="fontawesome-free-5.4.1-web/js/all.js"></script>
<link rel="stylesheet" href="css/custom.css">
</head>
<body>
<div id="container"></div>
<div>
<a href="http://www.chromeexperiments.com/globe">
<img id="ce" src="nasa.png">
</a>
</div>
<div class="btn-group">
<button>
<div class="tooltip">
<i class="fa fa-arrow-circle-up" style="color: white" aria-hidden="true">
</i>
<span class="tooltiptext">
Gain
</span>
</div>
</button>
<!-- <label class="hovertext">Test</label> -->
<button>
<div class="tooltip">
<i class="fa fa-arrow-circle-down" style="color: white" aria-hidden="true">
</i>
<span class="tooltiptext">
Loss
</span>
</div>
</button>
<button>
<div class="tooltip">
<i class="fa fa-tree" style="color: white" aria-hidden="true">
</i>
<span class="tooltiptext">
Cover
</span>
</div>
</button>
<!-- <label class="hovertext">Test</label> -->
</div>
<div id="currentInfo">
<span id="year1990" class="year">2000</span>
<span id="year1995" class="year">2004</span>
<span id="year2000" class="year">2008</span>
<span id="year2000" class="year">2012</span>
<span id="year1990" class="year">2016</span>
</div>
<div id="title">
Affected Forest Cover
</div>
<script type="text/javascript" src="/globe/third-party/Detector.js"></script>
<script type="text/javascript" src="/globe/third-party/three.min.js"></script>
<script type="text/javascript" src="/globe/third-party/Tween.js"></script>
<script type="text/javascript" src="/globe/globe.js"></script>
<script type="text/javascript">
if(!Detector.webgl){
Detector.addGetWebGLMessage();
} else {
var years = ['1990','1995','2000'];
var container = document.getElementById('container');
var globe = new DAT.Globe(container);
console.log(globe);
var i, tweens = [];
var settime = function(globe, t) {
return function() {
new TWEEN.Tween(globe).to({time: t/years.length},500).easing(TWEEN.Easing.Cubic.EaseOut).start();
var y = document.getElementById('year'+years[t]);
if (y.getAttribute('class') === 'year active') {
return;
}
var yy = document.getElementsByClassName('year');
for(i=0; i<yy.length; i++) {
yy[i].setAttribute('class','year');
}
y.setAttribute('class', 'year active');
};
};
for(var i = 0; i<years.length; i++) {
var y = document.getElementById('year'+years[i]);
y.addEventListener('mouseover', settime(globe,i), false);
}
var xhr;
TWEEN.start();
xhr = new XMLHttpRequest();
xhr.open('GET', '/globe/population909500.json', true);
xhr.onreadystatechange = function(e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
window.data = data;
for (i=0;i<data.length;i++) {
globe.addData(data[i][1], {format: 'magnitude', name: data[i][0], animated: true});
}
globe.createPoints();
settime(globe,0)();
globe.animate();
document.body.style.backgroundImage = 'none'; // remove loading
}
}
};
xhr.send(null);
}
</script>
</body>
</html>