-
Notifications
You must be signed in to change notification settings - Fork 49
/
readme.html
70 lines (47 loc) · 1.79 KB
/
readme.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
<!doctype html>
<html lang=en >
<head>
<meta charset=utf-8 >
<title>Open Index or Markdown</title>
<meta name=viewport content='width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no' >
<meta name=description content='File wrangler. Default index.html file. Opens HTML or Markdown files. Passes location.hash.' >
<meta name=keywords content='ShowDown,Markdown,AJAX,JavaScript,HTML,CSS,GitHub,FOSS' >
<meta name=date content='2017-03-25' >
<style>
body { font: 12pt monospace; left: 0; margin: 0 auto; max-width: 800px; right: 0; }
a { color: crimson; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input[type=button] { background-color: #eee; border: 2px #eee solid; color: #888; }
</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js" ></script>
<script>
// https://github.com/showdownjs/showdown
// https://github.com/pushme-pullyou/pushme-pullyou.github.io/tree/master/tootoo-templates
let defaultFile = 'index.html';
location.hash = 'README.md';
let contents;
init();
function init() {
if ( location.hash.endsWith( '.md' ) ) {
onHashChange();
} else {
window.location.href = defaultFile + location.hash;
}
}
function onHashChange() {
contents = contents ? contents : document.body.appendChild( document.createElement( 'div' ) ) ;
showdown.setFlavor('github');
const converter = new showdown.Converter();
const url = location.hash.slice( 1 );
const xhr = new XMLHttpRequest();
xhr.open( 'get', url, true );
xhr.onload = function() { contents.innerHTML = converter.makeHtml( xhr.responseText ); };
xhr.send( null );
document.title = url.split( '/' ).pop();
window.addEventListener( 'hashchange', onHashChange, false );
}
</script>
</body>
</html>