forked from jaanga/jaanga.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cca51ce
commit 62c5667
Showing
48 changed files
with
2,191 additions
and
1,642 deletions.
There are no files selected for viewing
165 changes: 165 additions & 0 deletions
165
cookbook-html/templates/menu-content-browser/github-api-menu-of-readme-files-r4.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
<!doctype html> | ||
<html lang=en > | ||
<head> | ||
<meta charset=utf-8 > | ||
<title>GitHub API Menu of Read Me Files R4</title> | ||
<meta name=viewport content='width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no' > | ||
<meta name=description content='Browse and view files written in Markdown format. | ||
Uses Github API to find directories with readme.md files.' > | ||
<meta name=keywords content='Jaanga,GitHub API,JavaScript,GitHub,FOSS' > | ||
<meta name=date content='2016-07-23' > | ||
</head> | ||
<body> | ||
<script src=https://cdnjs.cloudflare.com/ajax/libs/showdown/1.4.2/showdown.min.js ></script> | ||
<script> | ||
|
||
// http://jaanga.github.io/cookbook-html/templates/menu-content-browser/github-api-menu-of-readme-files/ | ||
|
||
var urlAPIContents = 'https://api.github.com/repos/jaanga/jaanga.github.io/git/trees/master?recursive=1'; | ||
var converter = new showdown.Converter( { strikethrough: true, literalMidWordUnderscores: true, simplifiedAutoLink: true, tables: true }); | ||
|
||
var dirs = location.href.split( '/' ); | ||
|
||
home = 'jaanga.github.io'; | ||
index = dirs.indexOf( home ) + 1; | ||
|
||
folders = dirs.slice( index, dirs.length - 1 ).join( '/' ) + '/' ; | ||
|
||
console.log( 'folder', folders ); | ||
|
||
var searchForFile = 'readme.md'; | ||
|
||
// var searchInFolder = 'cookbook-html/templates/'; | ||
var searchInFolder = folders; | ||
|
||
var path = './'; | ||
|
||
var files; | ||
|
||
init(); | ||
|
||
function init() { | ||
|
||
var css, menu, contents; | ||
|
||
css = document.body.appendChild( document.createElement( 'style' ) ); | ||
css.innerHTML = | ||
|
||
'body { font: 12pt monospace; margin: 0; }' + | ||
'h2 a { color: crimson; }' + | ||
'a { text-decoration: none; }' + | ||
'button, input[type=button] { background-color: #eee; border: 2px #eee solid; color: #888; }' + | ||
|
||
'#menu { box-sizing: border-box; background-color: #ccc; max-width: 300px; padding: 0 10px; position: absolute; }' + | ||
'#contents { border: 0px red solid; left: 350px; overflow: auto; position: absolute; top: 0; width: ' + ( window.innerWidth - 370 ) + 'px; }' + | ||
|
||
''; | ||
|
||
menu = document.body.appendChild( document.createElement( 'div' ) ); | ||
menu.id = 'menu'; | ||
|
||
contents = document.body.appendChild( document.createElement( 'div' ) ); | ||
contents.id = 'contents'; | ||
|
||
window.addEventListener ( 'hashchange', hashChange, false ); | ||
|
||
requestAPIContents(); | ||
|
||
hashChange(); | ||
|
||
} | ||
|
||
function requestAPIContents() { | ||
|
||
var xhr, response, file; | ||
|
||
xhr = new XMLHttpRequest(); | ||
xhr.open( 'GET', urlAPIContents, true ); | ||
xhr.onload = callback; | ||
xhr.send( null ); | ||
|
||
function callback() { | ||
|
||
response = JSON.parse( xhr.response ); | ||
files = []; | ||
|
||
for ( var i = 0; i < response.tree.length; i++ ) { | ||
|
||
file = response.tree[ i ].path; | ||
|
||
if ( !file.match( searchInFolder ) ) { continue; } | ||
|
||
if ( !file.match( searchForFile ) ) { continue; } | ||
|
||
files.push( file ); | ||
|
||
} | ||
|
||
//console.log( 'files', files ); | ||
|
||
createTableOfContents(); | ||
|
||
} | ||
|
||
} | ||
|
||
function createTableOfContents() { | ||
|
||
var txt = | ||
|
||
'<h2>' + | ||
'<a href=http://jaanga.github.io title="Jaanga - your 3D happy place" > ❦ </a><br>' + | ||
'<a href="" title="Click here to refresh this page" >' + document.title + '</a>' + | ||
// '<a href=index.html#readme.md title="Click here for help and information" > ⓘ </a>' + | ||
'</h2>'; | ||
|
||
for ( var i = 0; i < files.length; i++ ) { | ||
|
||
file = files[ i ].replace( searchInFolder, '' ); | ||
txt += | ||
|
||
'<h3><a href=#' + path + file + ' >'+ file.replace( '/readme.md', '' ).replace( /-/g, ' ' ) + '<a></h3>' + | ||
|
||
''; | ||
|
||
} | ||
|
||
menu.innerHTML = txt + | ||
|
||
'<details >' + | ||
'<summary><h3 style=display:inline; >About</h3></summary>' + | ||
'<p>Copyright © 2016 Jaanga authors. <a href=http://jaanga.github.io/home/r4/index.html#http://jaanga.github.io/jaanga-copyright-and-mit-license.md >MIT license</a>.</p>' + | ||
'<p>Click the \'i in a circle\' icon for more <a href=index.html#readme.md title="Click here for help and information" >help</a>.</p>' + | ||
'<p></p>' + | ||
'</details>' + | ||
|
||
'<hr><center><a href=javascript:window.scrollTo(0,0); style=text-decoration:none; title="Jaanga - your 3D happy place" ><h1> ❦ <h1></a></center>' + | ||
|
||
''; | ||
|
||
} | ||
|
||
function hashChange() { | ||
|
||
var fileName; | ||
|
||
fileName = location.hash ? location.hash.slice( 1 ) : searchForFile; | ||
|
||
getMarkdown( fileName, contents ); | ||
|
||
} | ||
|
||
function getMarkdown( fileName, target ) { | ||
|
||
var xhr; | ||
|
||
xhr = new XMLHttpRequest(); | ||
xhr.open( 'GET', fileName, true ); | ||
xhr.onload = function() { target.innerHTML = converter.makeHtml( xhr.responseText ); }; | ||
xhr.send( null ); | ||
|
||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
165 changes: 165 additions & 0 deletions
165
...u-content-browser/github-api-menu-of-readme-files/github-api-menu-of-readme-files-r4.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
<!doctype html> | ||
<html lang=en > | ||
<head> | ||
<meta charset=utf-8 > | ||
<title>GitHub API Menu of Read Me Files R4</title> | ||
<meta name=viewport content='width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no' > | ||
<meta name=description content='Browse and view files written in Markdown format. | ||
Uses Github API to find directories with readme.md files.' > | ||
<meta name=keywords content='Jaanga,GitHub API,JavaScript,GitHub,FOSS' > | ||
<meta name=date content='2016-07-23' > | ||
</head> | ||
<body> | ||
<script src=https://cdnjs.cloudflare.com/ajax/libs/showdown/1.4.2/showdown.min.js ></script> | ||
<script> | ||
|
||
// http://jaanga.github.io/cookbook-html/templates/menu-content-browser/github-api-menu-of-readme-files/ | ||
|
||
var urlAPIContents = 'https://api.github.com/repos/jaanga/jaanga.github.io/git/trees/master?recursive=1'; | ||
var converter = new showdown.Converter( { strikethrough: true, literalMidWordUnderscores: true, simplifiedAutoLink: true, tables: true }); | ||
|
||
var dirs = location.href.split( '/' ); | ||
|
||
home = 'jaanga.github.io'; | ||
index = dirs.indexOf( home ) + 1; | ||
|
||
folders = dirs.slice( index, dirs.length - 1 ).join( '/' ) + '/' ; | ||
|
||
console.log( 'folder', folders ); | ||
|
||
var searchForFile = 'readme.md'; | ||
|
||
// var searchInFolder = 'cookbook-html/templates/'; | ||
var searchInFolder = folders; | ||
|
||
var path = '../'; | ||
|
||
var files; | ||
|
||
init(); | ||
|
||
function init() { | ||
|
||
var css, menu, contents; | ||
|
||
css = document.body.appendChild( document.createElement( 'style' ) ); | ||
css.innerHTML = | ||
|
||
'body { font: 12pt monospace; margin: 0; }' + | ||
'h2 a { color: crimson; }' + | ||
'a { text-decoration: none; }' + | ||
'button, input[type=button] { background-color: #eee; border: 2px #eee solid; color: #888; }' + | ||
|
||
'#menu { box-sizing: border-box; background-color: #ccc; max-width: 300px; padding: 0 10px; position: absolute; }' + | ||
'#contents { border: 0px red solid; left: 350px; overflow: auto; position: absolute; top: 0; width: ' + ( window.innerWidth - 370 ) + 'px; }' + | ||
|
||
''; | ||
|
||
menu = document.body.appendChild( document.createElement( 'div' ) ); | ||
menu.id = 'menu'; | ||
|
||
contents = document.body.appendChild( document.createElement( 'div' ) ); | ||
contents.id = 'contents'; | ||
|
||
window.addEventListener ( 'hashchange', hashChange, false ); | ||
|
||
requestAPIContents(); | ||
|
||
hashChange(); | ||
|
||
} | ||
|
||
function requestAPIContents() { | ||
|
||
var xhr, response, file; | ||
|
||
xhr = new XMLHttpRequest(); | ||
xhr.open( 'GET', urlAPIContents, true ); | ||
xhr.onload = callback; | ||
xhr.send( null ); | ||
|
||
function callback() { | ||
|
||
response = JSON.parse( xhr.response ); | ||
files = []; | ||
|
||
for ( var i = 0; i < response.tree.length; i++ ) { | ||
|
||
file = response.tree[ i ].path; | ||
|
||
if ( !file.match( searchInFolder ) ) { continue; } | ||
|
||
if ( !file.match( searchForFile ) ) { continue; } | ||
|
||
files.push( file ); | ||
|
||
} | ||
|
||
//console.log( 'files', files ); | ||
|
||
createTableOfContents(); | ||
|
||
} | ||
|
||
} | ||
|
||
function createTableOfContents() { | ||
|
||
var txt = | ||
|
||
'<h2>' + | ||
'<a href=http://jaanga.github.io title="Jaanga - your 3D happy place" > ❦ </a><br>' + | ||
'<a href="" title="Click here to refresh this page" >' + document.title + '</a>' + | ||
// '<a href=index.html#readme.md title="Click here for help and information" > ⓘ </a>' + | ||
'</h2>'; | ||
|
||
for ( var i = 0; i < files.length; i++ ) { | ||
|
||
file = files[ i ].replace( searchInFolder, '' ); | ||
txt += | ||
|
||
'<h3><a href=#' + path + file + ' >'+ file.replace( '/readme.md', '' ).replace( /-/g, ' ' ) + '<a></h3>' + | ||
|
||
''; | ||
|
||
} | ||
|
||
menu.innerHTML = txt + | ||
|
||
'<details >' + | ||
'<summary><h3 style=display:inline; >About</h3></summary>' + | ||
'<p>Copyright © 2016 Jaanga authors. <a href=http://jaanga.github.io/home/r4/index.html#http://jaanga.github.io/jaanga-copyright-and-mit-license.md >MIT license</a>.</p>' + | ||
'<p>Click the \'i in a circle\' icon for more <a href=index.html#readme.md title="Click here for help and information" >help</a>.</p>' + | ||
'<p></p>' + | ||
'</details>' + | ||
|
||
'<hr><center><a href=javascript:window.scrollTo(0,0); style=text-decoration:none; title="Jaanga - your 3D happy place" ><h1> ❦ <h1></a></center>' + | ||
|
||
''; | ||
|
||
} | ||
|
||
function hashChange() { | ||
|
||
var fileName; | ||
|
||
fileName = location.hash ? location.hash.slice( 1 ) : searchForFile; | ||
|
||
getMarkdown( fileName, contents ); | ||
|
||
} | ||
|
||
function getMarkdown( fileName, target ) { | ||
|
||
var xhr; | ||
|
||
xhr = new XMLHttpRequest(); | ||
xhr.open( 'GET', fileName, true ); | ||
xhr.onload = function() { target.innerHTML = converter.makeHtml( xhr.responseText ); }; | ||
xhr.send( null ); | ||
|
||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.