-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
124 lines (114 loc) · 2.99 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
<!DOCTYPE html>
<html>
<head>
<title>astro</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="js/UAI_module.js"></script>
</head>
<style>
.planete {
margin: 0px;
padding: 0px;
background-color: #ccc;
color: #FF0000;
font-size: 15pt;
}
</style>
<body>
<h2>Demo <a href='https://github.com/mkgrgis/openPlanetWMS'>openPlanetWMS</a></h2>
<div id="planet_"></div>
</br>
<script>
var Config = {
URI: {
data: "https://raw.githubusercontent.com/mkgrgis/OpenPlanetaryData/master/",
wikidata: "https://www.wikidata.org/wiki/Special:EntityData/"
}
}
var lingua = navigator.language.split('-')[0];
IO_json(
'OpenPlanetaryDataUniversal',
Config.URI.data + 'universal.json',
Universal_ok,
null
);
function Universal_ok(o) {
if (o.req.currentTarget.status != 200){
alert ('"Non ' + Config.URI.data + 'universal.json!' );
return;
}
var planetStruct = JSON.parse(o.req.currentTarget.responseText);
var div0 = document.getElementById('planet_');
for (var planete in planetStruct.systeme){
var p = planetStruct.systeme[planete];
var d_p = document.createElement('div');
d_p.lang = lingua;
p.div = d_p;
var a_p = document.createElement('a');
if (p.wms)
a_p.href = planete + '.html';
d_p.className='planete';
a_p.innerText = planete;
var wd = p.wikidata;
IO_json(
wd,
Config.URI.wikidata + wd + '.json',
Wikidata_ok,
{
a: a_p,
div: d_p,
wd: wd
}
);
div0.appendChild(d_p);
d_p.appendChild(a_p);
}
for (var element in planetStruct.element){
var e = planetStruct.element[element];
var d_e = document.createElement('div');
var a_e = document.createElement('a');
var e_norm = element[0].toUpperCase() + element.slice(1).toLowerCase();
a_e.href = e + ' - ' + e_norm + '.html';
d_e.className='element';
a_e.innerText = e_norm;
/*var wd = p.wikidata;
IO_json(
wd,
Config.URI.wikidata + wd + '.json',
Wikidata_ok,
{
a: a_p,
div: d_p,
wd: wd
}
);
div0.appendChild(d_p);
d_p.appendChild(a_p);
p.div = d_p;*/
for (var planete in planetStruct.systeme){
if (planete == e){
var base_div = planetStruct.systeme[planete].div;
base_div.parentNode.insertBefore(d_e, base_div.nextSibling);
d_e.appendChild(a_e);
}
}
}
console.log('∀ ✔');
}
function Wikidata_ok(o) {
if (o.req.currentTarget.status != 200){
console.warn(' wikidata ' + o.req.context );
return;
}
var wd_json = JSON.parse(o.req.currentTarget.responseText);
var txt = wd_json.entities[o.context.wd];
var p = document.createElement('p');
p.className = 'planetdescription';
p.innerText += '(' + txt.descriptions[lingua].value + ')';
o.context.div.appendChild(p);
o.context.a.innerText += ' ' + txt.labels[lingua].value;
}
</script>
</body>
</html>