-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
242 lines (233 loc) · 9.35 KB
/
index.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index of /</title>
<meta name="google-site-verification" content="C6tra7qp9MtfyUZAX885levrTavCbgsoTpVa4Hve7Nc" />
<meta name="robots" content="index, follow" />
<link rel="canonical" href="index.html" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="shortcut icon" type="image/png" sizes="192x192" href="/favicon-192x192.png" />
<link rel="preload" href="/fonts/Nunito-Regular-latin.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
<link rel="preload" href="/fonts/Nunito-Regular-latin-ext.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
<link rel="stylesheet" href="/fonts/font.css" />
<link rel="stylesheet" href="/styles/style.css" />
<script src="/scripts/tablesort.min.js"></script>
</head>
<body>
<noscript>
<p class="no-script">JavaScript is disabled, please enable JavaScript and reload the page.</p>
</noscript>
<div id="content">
<div>
<h1 class="title">Index of /</h1>
</div>
<div id="table_main">
<table id="index_data" class="table-hoverable rc-table noftfs">
<thead class="th-bg">
<tr>
<th class="rc-cell colname" role="columnheader">
<a href="#" onclick="return false">Repository</a>
</th>
<th class="rc-cell colname" data-sort-method="number" role="columnheader">
<a href="#" onclick="return false">Description</a>
</th>
<th class="rc-cell colname" data-sort-method="number" role="columnheader">
<a href="#" onclick="return false">Last Mod.</a>
</th>
</tr>
</thead>
<tbody id="files-list"></tbody>
</table>
</div>
<div class="quote-container">
<p>
<span id="quote"></span>
<span style="white-space: nowrap; font-weight: bold"> - <span id="author"></span></span>
</p>
</div>
</div>
<script>
var docLoad = setInterval(function () {
if (document.readyState !== "complete") return;
new Tablesort(document.querySelector("#index_data"));
var indexpath = "/";
if (window.location.pathname) indexpath = window.location.pathname.substring(1);
// else indexpath = window.location.hostname;
var indexof = "Index of /" + indexpath.substring(0, indexpath.lastIndexOf("/"));
document.title = indexof;
document.querySelector(".title").innerText = indexof;
getData();
clearInterval(docLoad);
}, 100);
Number.prototype.padLeft = function (base, chr) {
var len = String(base || 10).length - String(this).length + 1;
return len > 0 ? new Array(len).join(chr || "0") + this : this;
};
var addFolderRow = function (name, dest, description, datetime) {
var tbody = document.getElementById("files-list");
var tr = tbody.insertRow(0);
var img = document.createElement("img");
img.className = "icon";
img.src = "/images/icons/icon-folder.svg";
img.alt="dir";
var span = document.createElement("span");
span.innerText = name;
var a = document.createElement("a");
a.appendChild(img);
a.appendChild(span);
if (!dest) dest = "#";
a.href = dest;
if (!name) name = "-";
var td1 = tr.insertCell(0);
td1.appendChild(a);
td1.className = "rc-cell";
if (!description) description = "-";
var td2 = tr.insertCell(1);
td2.innerText = description;
td2.className = "rc-cell";
if (!datetime) {
var tempdate = Date.now();
var ld = new Date(tempdate),
formattedDate =
[ld.getFullYear(), (ld.getMonth() + 1).padLeft(), ld.getDate().padLeft()].join("-") +
" " +
[ld.getHours().padLeft(), ld.getMinutes().padLeft()].join(":");
var time = new Date(tempdate).getTime();
var date = formattedDate;
}
var td3 = tr.insertCell(2);
td3.innerText = date;
td3.setAttribute("data-sort", time);
td3.className = "rc-cell";
};
var getLastModifiedDate = (...args) => {
var result = {};
var user = "adithsuresh";
if (window.location.hostname.split(".")[1] === "github") user = window.location.hostname.split(".")[0];
var lm_api = "https://api.github.com/repos/" + user + "/" + args[0] + "/branches/master";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState !== 4) return;
if (xhr.status >= 200 && xhr.status < 300) {
var data = JSON.parse(xhr.responseText);
var utcdate = data.commit.commit.committer.date;
var ld = new Date(utcdate),
formattedDate =
[ld.getFullYear(), (ld.getMonth() + 1).padLeft(), ld.getDate().padLeft()].join("-") +
" " +
[ld.getHours().padLeft(), ld.getMinutes().padLeft()].join(":");
result.time = new Date(utcdate).getTime();
result.date = formattedDate;
args[1].datetime = result;
getLastModifiedDateCallback(args[1]);
} else {
console.log("ERROR WHILE FETCHING DATA");
}
};
xhr.open("GET", lm_api);
xhr.onerror = function (err) {
console.log(err);
};
xhr.send();
};
function getLastModifiedDateCallback({ tbody, data, i, datetime }) {
var tr = tbody.insertRow(0);
var a = document.createElement("a");
a.href = data[i].homepage;
a.target = "_blank";
a.innerText = data[i].name;
var td1 = tr.insertCell(0);
td1.appendChild(a);
td1.className = "rc-cell";
if (!data[i].description) data[i].description = "-";
var td2 = tr.insertCell(1);
td2.innerText = data[i].description;
td2.className = "rc-cell";
var td3 = tr.insertCell(2);
td3.innerText = datetime.date;
td3.setAttribute("data-sort", datetime.time);
td3.className = "rc-cell";
}
var getData = function () {
var user = "adithsuresh";
if (window.location.hostname.split(".")[1] === "github") user = window.location.hostname.split(".")[0];
var api = "https://api.github.com/users/" + user + "/repos";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState !== 4) return;
if (xhr.status >= 200 && xhr.status < 300) {
var data = JSON.parse(xhr.responseText);
processData(data);
} else {
processError();
}
};
xhr.open("GET", api);
xhr.onerror = function (err) {
processError(err);
};
xhr.send();
};
var processData = function (data) {
var tbody = document.getElementById("files-list");
tbody.innerHTML = "";
if (!data.length || data.length < 1) {
processError();
} else {
for (var i = data.length - 1; i >= 0; i--) {
if (data[i].homepage) {
if (data[i].name === window.location.host) {
continue;
}
var lmd_reponame = encodeURIComponent(data[i].name);
getLastModifiedDate(lmd_reponame, { tbody, data, i });
}
}
}
addFolderRow("pages/", "./pages/", "directory");
document.getElementById("content").style.display = "flex";
getQuote();
};
var processError = function (err) {
var tbody = document.getElementById("files-list");
tbody.innerHTML = "";
var td = tbody.insertRow(0);
td.insertCell(0).innerText = "No Data";
td.style.textAlign = "center";
tbody.rows[0].cells[0].className = "rc-cell";
tbody.rows[0].cells[0].colSpan = 3;
document.getElementById("content").style.display = "flex";
getQuote();
};
var getQuote = function () {
var api = "https://api.quotable.io/random?maxLength=130";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState !== 4) return;
if (xhr.status >= 200 && xhr.status < 300) {
var data = JSON.parse(xhr.responseText);
processQuoteData(data);
} else {
console.log("Error while retrieving quote...!");
}
};
xhr.open("GET", api);
xhr.onerror = function (err) {
console.log(err);
};
xhr.send();
};
var processQuoteData = function (data) {
document.getElementById("quote").innerText = data.content;
document.getElementById("author").innerText = data.author;
document.getElementsByClassName("quote-container")[0].style.display = "flex";
};
</script>
</body>
</html>