Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
vikdevelop authored Jun 28, 2024
1 parent 2913f38 commit e9b2ca4
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions wiki/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,32 @@ <h1>SaveDesktop wiki viewer</h1>
<th>Last Modified</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="..">Home page</a></td>
<td>-</td>
</tr>
<tbody id="folder-list"></tbody>
</tbody>
<tbody id="folder-list"></tbody>
</table>

<script>
fetch('/wiki')
.then(response => response.text())
.then(data => {
const parser = new DOMParser();
const doc = parser.parseFromString(data, 'text/html');
const folderList = doc.querySelectorAll('a[href$="/"]');
const githubUser = 'vikdevelop';
const githubRepo = 'SaveDesktop';
const githubBranch = 'webpage';

fetch(`https://api.github.com/repos/${githubUser}/${githubRepo}/contents/wiki?ref=${githubBranch}`)
.then(response => response.json())
.then(data => {
const folderListElement = document.getElementById('folder-list');
folderList.forEach(folder => {
const tr = document.createElement('tr');
const td1 = document.createElement('td');
const td2 = document.createElement('td');

td1.innerHTML = `<span class="directory"><a href="${folder.href}">${folder.textContent}</a></span>`;
td2.textContent = '-';
data.forEach(item => {
if (item.type === 'dir') {
const tr = document.createElement('tr');
const td1 = document.createElement('td');
const td2 = document.createElement('td');

td1.innerHTML = `<span class="directory"><a href="${item.html_url}">${item.name}/</a></span>`;
td2.textContent = item.updated_at;

tr.appendChild(td1);
tr.appendChild(td2);
folderListElement.appendChild(tr);
tr.appendChild(td1);
tr.appendChild(td2);
folderListElement.appendChild(tr);
}
});
})
.catch(error => console.error(error));
Expand Down

0 comments on commit e9b2ca4

Please sign in to comment.