-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-00.html
70 lines (47 loc) · 1.93 KB
/
index-00.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='2016-10-16' >
</head>
<body>
<script src=https://cdnjs.cloudflare.com/ajax/libs/showdown/1.6.0/showdown.min.js ></script>
<script>
// https://github.com/showdownjs/showdown
// https://github.com/jaanga/jaanga.github.io/tree/master/cookbook-html/templates2/open-index-or-markdown
var defaultFile = 'index.html';
location.hash = 'README.md';
var contents;
init();
function init() {
if ( location.hash.match( '.md' ) ) {
onHashChange();
} else {
window.location.href = defaultFile + location.hash;
}
}
function onHashChange() {
var css, converter, url, xhr;
css = document.head.appendChild( document.createElement( 'style' ) );
css.innerHTML =
'body { font: 12pt monospace; left: 0; margin: 0 auto; max-width: 800px; right: 0; }' +
'a { color: crimson; text-decoration: none; }' +
'button, input[type=button] { background-color: #eee; border: 2px #eee solid; color: #888; }' +
'';
contents = contents ? contents : document.body.appendChild( document.createElement( 'div' ) ) ;
converter = new showdown.Converter( { strikethrough: true, literalMidWordUnderscores: true, simplifiedAutoLink: true, tables: true });
url = location.hash.slice( 1 );
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>