-
Notifications
You must be signed in to change notification settings - Fork 1
/
terrain-srtm30-plus.html
235 lines (139 loc) · 5.54 KB
/
terrain-srtm30-plus.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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!doctype html>
<html lang=en >
<head>
<title>Jaanga Terrain SRTM 30 Plus</title>
<meta charset=utf-8 />
<meta name=viewport content='width=device-width,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0' />
</head>
<body>
<script src=http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js ></script>
<script>
var header, menu;
init();
function init() {
var txt = 'lorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? quis autem vel eum iure reprehenderit, qui in ea voluptate velit esse, quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo voluptas nulla pariatur?';
var css = document.body.appendChild( document.createElement('style') );
css.innerHTML = 'body { font: 600 12pt monospace; margin: 0; overflow: hidden; }' +
'h1 { margin: 0; }' +
'h1 a, #bars { text-decoration: none; }' +
'h2 { background-color: #f8f8f8; padding: 0 5px; }' +
'h2.close::before { content: "► "; }' +
'h2.open::before { content: "▼ "; }' +
'#bars { color: #ccc; }' +
'';
header = document.body.appendChild( document.createElement( 'div' ) );
header.style.cssText = 'position: absolute; left: 350px; top: 20px; transition: left 1s; ';
header.innerHTML = '<h1><a href=JavaScript:slideMenu(); id=bars >☰</a></h1>';
menu = header.appendChild( document.createElement( 'div' ) );
menu.style.cssText = 'background-color: #eee; height: ' + ( 0.95 * window.innerHeight ) + 'px; left: -350px; opacity: 0.85; overflow: auto; ' +
'padding: 0 15px; position: absolute; top: 0px; width: 300px; ';
loadMarkdownInMenu( 'terrain-srtm30-plus-menu.md', menu );
loadMarkdownInIframe( '#readme.md#' );
// loadHTMLInIframe( '#../template-threejs.html#' );
// slideMenu();
window.addEventListener ( 'hashchange', onHashChange, false );
}
function slideMenu(){
header.style.left = header.style.left === '20px' ? '350px' : '20px';
}
function onHashChange() {
hashes = location.hash.split ( '#' );
if ( hashes.length < 1 ) { return; }
var fileName = hashes[ 1 ].toLowerCase();
var fileType = (fileName.substr( fileName.lastIndexOf( '.' )).toLowerCase() );
if ( fileType === '.html' || fileType === '.htm' ) {
loadHTMLInIframe( location.hash );
} else if ( fileType === '.md' ) {
loadMarkdownInIframe( location.hash );
}
}
function loadHTMLInIframe( hash, callback ) {
ifr = resetIframe( callback );
ifr.src = hash.substr( 1 );
}
function loadMarkdownInMenu( fileName, panel ) {
var converter = new Showdown.converter();
var xmlHttp = new XMLHttpRequest ();
xmlHttp.open( 'GET', fileName, true );
xmlHttp.onreadystatechange = callback;
xmlHttp.send( null );
function callback() {
text = xmlHttp.responseText;
panel.innerHTML = converter.makeHtml( text );
items = document.body.getElementsByTagName( 'h2' );
for ( var i = 0; i < items.length; i++ ) {
items[ i ].id = 't' + i;
if ( items[ i ].innerHTML.indexOf( '(open)' ) === -1 ) {
items[ i ].className += ' close';
item = items[ i ].nextElementSibling;
while ( item && item.tagName !== 'H2' ) {
item.style.display = 'none';
item = item.nextElementSibling;
}
} else {
items[ i ].className += ' open';
items[ i ].innerHTML = items[ i ].innerHTML.replace( '(open)','' );
}
items[ i ].onclick = function() { toggle( this ); };
}
}
}
function toggle( element ) {
element = document.getElementById( element.id );
content = element.nextElementSibling;
if ( content.style.display === '' ) {
while ( content && content.tagName !== 'H2' ) {
content.style.display = 'none';
content = content.nextElementSibling;
}
element.className = 'toggle close';
} else {
while ( content && content.tagName !== 'H2' ) {
content.style.display = '';
content = content.nextElementSibling;
}
element.className = 'toggle open';
}
}
function loadMarkdownInIframe( hash, callback ) {
ifr = resetIframe( callback );
var srcdoc =
"<div id=doc ><\/div>" +
"<script src=http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js ><\/script>" +
"<script>" +
" doc.style.cssText = 'font: bold 12pt monospace; margin: auto; max-width: 900px';" +
" var xmlHttp;" +
" var converter = new Showdown.converter();" +
" requestFile( '" + hash.substr( 1 ) + "' );" +
" function requestFile( fileName ) {" +
" xmlHttp = new XMLHttpRequest();" +
" xmlHttp.open( 'GET', fileName, true );" +
" xmlHttp.onreadystatechange = callback;" +
" xmlHttp.send( null );" +
" }" +
" function callback() {" +
" var text = xmlHttp.responseText;" +
" text = converter.makeHtml( text );" +
" doc.innerHTML = text;" +
" }" +
"<\/script>" +
"";
ifr.srcdoc = srcdoc;
// slideMenu(); // to hide
// location.hash = '';
};
function resetIframe( callback ) {
var iframes = document.getElementsByTagName( 'iframe' );
for ( var i = 0, len = iframes.length; i < len; i++ ) {
iframes[0].parentNode.removeChild( iframes[ 0 ] );
}
var ifr = document.body.appendChild( document.createElement( 'iframe' ) );
ifr.width = window.innerWidth;
ifr.height = window.innerHeight;
ifr.style.cssText = 'border-width: 0; position: absolute; z-index: -10';
ifr.onload = callback || function() {};
return ifr;
}
</script>
</body>
</html>