-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
111 lines (89 loc) · 2.99 KB
/
Copy pathscripts.js
File metadata and controls
111 lines (89 loc) · 2.99 KB
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
//all page load, all common onLoads.
function allPageLoad()
{
fixFooterHeight();
getLastModified();
}
//any special page loads
function ProjectPageLoad()
{
allPageLoad();
loadGitHubTable();
}
function loadGitHubTable()
{
const xhttp = new XMLHttpRequest();
xhttp.onload=function(){
var response = this.responseText;
//parse json
var JObj = JSON.parse(response);
//build table.
//create table open tag
var htmlTable = "";
htmlTable += "<table>";
//add table headers
htmlTable += "<tr><th>Project Name</th><th>Language</th><th>Created</th><th>Last Updated</th><th>Availability</th></tr>";
//loop arournd the Jobj, adding rows.
for(let i=0;i<JObj.length;i++)
{
//add tr tag
htmlTable +="<tr>";
//name - is also a link
htmlTable+="<td>";
var link = "<a target=\"blank\" href=\""+JObj[i]["html_url"]+"\"a>"+JObj[i]["name"]+"</a>";
htmlTable +=link;
htmlTable+="</td>";
//language
htmlTable+="<td>";
htmlTable+=JObj[i]["language"];
htmlTable+="</td>";
//created
htmlTable+="<td>";
var createdDTStr = JObj[i]["created_at"];
var createdDate = new Date(createdDTStr);
htmlTable+=createdDate.toLocaleDateString("en-US");
htmlTable+="</td>";
//last updated
htmlTable+="<td>";
var updatedDTStr = JObj[i]["pushed_at"];
var updatedDate = new Date(updatedDTStr);
htmlTable+=updatedDate.toLocaleDateString("en-US");
htmlTable+="</td>";
//availability
htmlTable+="<td>";
htmlTable+=JObj[i]["visibility"];
htmlTable+="</td>";
//close tr
htmlTable +="</tr>";
}
//close tag
htmlTable += "</table>"
document.getElementById("githubTable").innerHTML=htmlTable;
}
xhttp.open("GET","https://api.github.com/users/rafjohnson/repos",true)
xhttp.setRequestHeader("accept","application/vnd.github+json");
xhttp.send();
}
function getLastModified()
{
//single place for the last modified date
var lastModified = "2022-08-09";
document.getElementById("lastModified").innerText=lastModified;
}
function fixFooterHeight()
{
var sidebar= document.querySelector('.sidebar');
var content = document.querySelector('.content');
var sidebarHeight = sidebar.offsetHeight;
var contentHeight = content.offsetHeight;
if(contentHeight<sidebarHeight)
{
//make content height the same as sidebar height
//single content div, luckily, so shouldn't need to iterate, but we will anyways
var contents = document.getElementsByClassName("content");
for (var i=0; i<contents.length;i++ )
{
contents[i].style.height=sidebarHeight;
}
}
}