This repository has been archived by the owner on Mar 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
siteTree.html
68 lines (56 loc) · 2.44 KB
/
siteTree.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
---
title: Site Tree
layout: doc
author: Joe Shields
date: 2019-11-14
---
<p>
Can't find what you're looking for? Here's a tree of all the pages on this site. <br/>
The <a href='#footer'>search box at the bottom of every page</a> may also be helpful.
If you still can't find what you need, try <a href="https://github.com/psu-epl/psu-epl.github.com/search">searching the repo</a> or just ask a manager.
</p>
<pre id="preTree"></pre>
<script type="text/javascript" src="/functions.js"></script>
<script>
console.log('hello world');
pages_fxn = function(pages, otherArgs){
// note: Everything requiring the `pages` object must happen inside this function.
console.log('here is the JSON response: ')
console.log(pages); // should be a JS array of the site pages at this point
// evaluate the parent/child/sibling information for each page
censoredPages = censorPages(pages);
pages = censoredPages; // avoids scope fuckery with censorPages()
var rootIndex = linkChildren(pages);
console.log('pages is: ');
console.log(pages);
// use the parent/child/sibling relations to build a JS object with the same hierarchy as the site
siteTree = getRelations(rootIndex, pages);
console.log('siteTree is: ');
console.log(siteTree);
// ulTree = '<ul>'+listFromTree(siteTree, 'ul')+'</ul>';
// create a preformatted tree similar to the tree command in Linux
preTree = preFromTree(siteTree, '', {pages});
// insert the tree into this page
document.getElementById("preTree").innerHTML = preTree
}
useJson('/sitePages.json', null, pages_fxn);
// get some JSON using the helpers in functions.js
// sitePages_fxn = function(sitePages, otherArgs){
// console.log('here is the JSON response: ')
// console.log(sitePages);
// document.getElementById("foo").innerHTML = JSON.stringify(sitePages);
// }
// useJson('sitePages.json', null, sitePages_fxn);
// get some JSON using vanilla JS
// var request = new XMLHttpRequest();
// request.open('GET', 'sitePages.json', true);
// request.onload = function() {
// // Sadly, it's a bit of a thing to just wait for something to finish in JS.
// // So, everything that requires the JSON needs to be inside this function.
// var jsonData = JSON.parse(this.response);
// console.log('here is the JSON response: ')
// console.log(jsonData);
// document.getElementById("foo").innerHTML = JSON.stringify(jsonData);
// }
// request.send();
</script>