-
Notifications
You must be signed in to change notification settings - Fork 29
/
index.html
365 lines (212 loc) · 9.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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<!doctype html>
<html lang = "en" >
<head>
<meta charset = "utf-8" >
<meta name = "viewport" content= "width=device-width, initial-scale=1">
<meta name = "description" content = "Cookbook examples for the Alpha Vantage API - created in plain-vanilla JavaScript" >
<meta name = "keywords" content = "Alpha Vantage,JavaScript,Showdown,Markdown,GitHub,FOSS" >
<meta name = "date" content = "2018-01-17" >
<title>predIQtiv ~ Alpha Vantage</title>
<style>
/* Copyright 2018 predIQtiv authors. MIT License */
/* https://www.w3schools.com/colors/colors_names.asp // use colors and borders to help identify the scope of particular elements */
html { --mnu-color: MediumSlateBlue; --mnu-back-color: ivory; --mnu-width:300px; height: 100%; }
body, html { font: 12pt monospace; height: 100%; margin: 0; }
a { color: var( --mnu-color ); text-decoration: none; }
a:hover, a:focus, #hamburger:hover { background-color: yellow; color: #8888; }
blockquote, pre { background-color: #eee; padding: 10px; }
button, input[ type=button ] { background-color: #ddd; border: none; color: var( --mnu-color ); cursor: pointer; padding: 3px 20px; }
button:hover { background-color: #ccc; color: #fff }
iframe { width: 100%; }
input[ type = range ] { -webkit-appearance: none; -moz-appearance: none; background-color: #ddd; width: 100%; }
input[ type = range ]::-moz-range-thumb { background-color: #888; border-radius: 0; width: 10px; }
input[ type = range ]::-webkit-slider-thumb { -webkit-appearance: none; background-color: #888; height: 20px; width: 10px; }
td { vertical-align: top; }
#divContainer { height: 100%; margin: 0 0 0 var( --mnu-width ); transition: margin-left .5s; position: relative; }
#divContents { height: 100%; left: 0; margin: 0 auto; right: 0;}
#divMenu { background-color: var( --mnu-back-color ); box-sizing: border-box; margin: 0; height: 100%;
overflow-x: hidden; padding: 30px 10px 0 10px; position: fixed; top: 0; width: var( --mnu-width ); z-index: 1; transition: 0.5s; }
#hamburger { background-color: pink; box-sizing: border-box; cursor: pointer; font-size: 30px; left: calc( var( --mnu-width ) - 100px );
line-height: 30px; margin: 0; padding: 5px 15px 8px 10px; position: fixed; top: 0; transition: left .5s; z-index: 10; }
</style>
</head>
<body>
<script src = "https://cdn.rawgit.com/showdownjs/showdown/1.8.6/dist/showdown.min.js" ></script>
<div id = "divMenu" >
<p>
<a href="http://predIQtiv.github.io/" target="_top" ><img src=https://prediqtiv.github.io/images/predIQtiv.png height=36 ></a>
<!--
<a href="http://www.ladybug.tools/spider/" target="_top" >🕸</a> »
<a href="../index.html" target="_"top style=font-size:24px; >⌂</a> »
-->
</p>
<h2>
<a id="urlInfo" target="_top" >info</a>
<a href="" ><script> document.write( document.title )</script></a>
</h2>
<p><script> document.write(document.head.querySelector( '[name=description]' ).content ); </script></p>
<div id = "divBreadcrumbs"></div>
<div id = "divMenuItems" ></div>
<hr>
<p><img src="https://status.github.com/images/invertocat.png" height=18 title='Octocat' > Click icon to view source code on GitHub.
<p> ❐ Click icon to go full screen & get link to individual file.</p>
<p>Tooltips provide file size.</p>
<hr>
<div id= "divFooter" >
<div title='many thanks!' ><a href=#pages/credits.md >Credits</a></div>
<div><a href=#pages/code-of-conduct.md >Code of Conduct</a></div>
<div><a href=#pages/contributing.md >Contributing</a></div>
<div><a href=#pages/license.md >License</a></div>
<div><a href=#pages/markdown-help.md >Markdown Help</a></div>
<div><a href="javascript:(function(){var script=document.createElement('script');script.onload=function(){var stats=new Stats();document.body.appendChild(stats.dom);requestAnimationFrame(function loop(){stats.update();requestAnimationFrame(loop)});};script.src='https://rawgit.com/mrdoob/stats.js/master/build/stats.min.js';document.head.appendChild(script);})()" title="Mr.doob's Stats.js appear in top left corner" >Show frames/second statistics</a></div>
<div><a href="https://api.github.com/rate_limit" target="_blank" title="Occasionally this script breaks if you go over the GitHub API rate limit" >github rate limits</a></div>
<p onclick=divMenu.scrollTop=0; style=cursor:pointer;text-align:center; title='go to top' ><img src=https://prediqtiv.github.io/images/five-boxes.png height=24 ></p>
</div>
</div>
<div id = "divContainer" >
<div id = "divContents" ></div>
</div>
<div id = "hamburger" onclick=toggleNav(); > slide ☰ </div>
<script>
const user = 'prediqtiv';
const repo = '/alpha-vantage-cookbook';
const pathRepo = '';
const uriDefaultFile = 'README.md';
// const uriDefaultFile = '../../plugins/view-github-issues.html'
const iconInfo = '<img src="https://status.github.com/images/invertocat.png" height=18 >';
const urlGitHubApiContents = 'https://api.github.com/repos/' + user + repo + '/contents/' + pathRepo;
let urlGitHubPage;
const urlGitHubSource = 'https://github.com/' + user + repo;
init();
function init() {
urlGitHubPage = location.pathname.includes( user + '/' + user + '.github.io' ) ? '' : 'https://rawgit.com/' + user + repo + '/master/';
//console.log( 'urlGitHubPage', urlGitHubPage );
urlInfo.href = urlGitHubSource;
urlInfo.innerHTML = iconInfo;
window.addEventListener ( 'hashchange', onHashChange, false );
onHashChange();
}
function onHashChange() {
let url, ulc, pathCurrent;
if ( !location.hash ) {
url = urlGitHubPage + uriDefaultFile;
ulc = url.toLowerCase();
pathCurrent = '';
} else {
url = location.hash.slice( 1 );
ulc = url.toLowerCase();
//console.log( 'url', url );
const crumbs = url.slice( urlGitHubPage.length );
pathCurrent = crumbs.lastIndexOf( '/' ) > 0 ? crumbs.slice( 0, crumbs.lastIndexOf( '/' ) ) : '';
//console.log( 'pathCurrent', pathCurrent );
}
getFolderContents( pathCurrent );
if ( ulc.endsWith( '.md' ) ) {
requestFile( url, callbackMarkdown );
} else if ( ulc.endsWith( '.html' ) ) {
document.body.style.overflow = 'hidden';
divContents.style.maxWidth = '';
divContents.innerHTML = '<iframe src=' + url + ' style=border:none;height:100%;width100%; ></iframe>';
} else if ( ulc.endsWith( '.gif' ) || ulc.endsWith( '.png' ) || ulc.endsWith( '.jpg' ) || ulc.endsWith( '.svg' ) || ulc.endsWith( '.ico' ) ) {
divContents.innerHTML = '<img src=' + urlGitHubPage + url + ' style=margin:20px; >';
} else {
requestFile( urlGitHubPage + url, callbackToTextarea );
}
}
function getFolderContents( path = '' ) {
const url = urlGitHubApiContents + path;
requestFile( url, callbackGitHubMenu );
setBreadcrumbs( path );
}
function setBreadcrumbs( path ) {
let txt =
'<b>' +
'<a href=JavaScript:getFolderContents(); >' +
( pathRepo ? pathRepo : '<span style=font-size:24px >⌂</span>' ) +
'</a> » ' +
'</b>';
let folders = path ? path.split( '/' ) : [] ;
let str = '';
for ( let folder of folders ) {
str += folder + '/';
txt += '<b><a href=JavaScript:getFolderContents("' + str.slice( 0, -1 ) + '"); >' + folder + '</a> » </b>';
}
divBreadcrumbs.innerHTML = txt;
}
function callbackGitHubMenu( xhr ) {
const response = xhr.target.response;
const items = JSON.parse( response );
const len = pathRepo.length;
let txt = '';
if ( items.message ) { alert( items.message ); return; }
const ignoreFolders = [ 'data' ]; //, 'plugins'
for ( let item of items ) {
if ( item.type === 'dir' ) {
if ( ignoreFolders.includes( item.name ) ) { continue; }
txt +=
'<div style=margin-bottom:8px; >' +
'<a href=JavaScript:getFolderContents("' + item.path.slice( len ) + '"); >📁 ' +
item.name +
'</a>' +
'</div>' +
'';
}
}
const ignoreFiles = [ '.gitattributes', '.gitignore' ];
for ( let item of items ) {
if ( item.type === 'file' ) {
if ( ignoreFiles.includes( item.name ) ) { continue; }
itemPath = encodeURI( item.path.slice( len ) );
txt +=
'<table><tr>' +
'<td><a href="' + urlGitHubSource + '/blob/master/' + itemPath + '" target=_top >' + iconInfo + '</a></td>' +
'<td>' +
'<a href=#' + urlGitHubPage + pathRepo + itemPath +
' title="' + item.size.toLocaleString() + ' bytes" > ' + item.name + '</a> ' +
( item.path.endsWith( 'html' ) ? '<a href=' + urlGitHubPage + pathRepo + itemPath + ' >❐</a>' : '' ) +
'</td>' +
'</tr></table>';
if ( ( !location.hash || location.hash.toLowerCase().endsWith( 'readme.md' ) )
&& item.path !== 'README.md' && item.name.toLowerCase() === 'readme.md' ) {
location.hash = urlGitHubPage + pathRepo + itemPath;
}
}
}
divMenuItems.innerHTML = txt;
}
function callbackMarkdown( xhr ){
showdown.setFlavor('github');
const converter = new showdown.Converter();
const response = xhr.target.response;
const html = converter.makeHtml( xhr.target.responseText );
document.body.style.overflow = '';
divContents.style.maxWidth = '800px';
divContents.innerHTML = html;
window.scrollTo( 0, 0 );
}
function callbackToTextarea( xhr ){
const response = xhr.target.response;
divContents.innerHTML = '<textarea style=height:100%;width:100%; >' + response + '</textarea>';
}
function requestFile( url, callback ) {
const xhr = new XMLHttpRequest();
xhr.crossOrigin = 'anonymous';
xhr.open( 'GET', url, true );
xhr.onerror = function( xhr ) { console.log( 'error:', xhr ); };
// xhr.onprogress = function( xhr ) { console.log( 'bytes loaded: ' + xhr.loaded.toLocaleString() ) }; /// or something
xhr.onload = callback;
xhr.send( null );
}
function toggleNav() {
const left = 'calc( var( --mnu-width ) - 100px )';
if ( hamburger.style.left === '' || hamburger.style.left === left ) {
divMenu.style.left = 'calc( -1 * var( --mnu-width ) - 20px )';
hamburger.style.left = '-100px';
} else {
divMenu.style.left = 0;
hamburger.style.left = left;
}
}
</script>
</body>
</html>