From 650bb41382622cd10d73a59940cbc2e4b4d40f07 Mon Sep 17 00:00:00 2001 From: Anurag Pandey Date: Sat, 1 Jun 2024 23:16:44 +0530 Subject: [PATCH] filtered file --- website/app.js | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/website/app.js b/website/app.js index 229c59a9..1a2959e1 100644 --- a/website/app.js +++ b/website/app.js @@ -3,22 +3,29 @@ const apiUrl = "https://api.github.com/repos/mdazfar2/HelpOps-Hub/contents"; fetch(apiUrl) .then((response) => response.json()) .then((data) => { - const foldersContainer = document.getElementById("folders-container"); - data.forEach((item) => { - if (item.type === "dir") { - // Create a card for each folder - const folderCard = document.createElement("div"); - folderCard.classList.add("folder-card"); - folderCard.innerHTML = ` + if (data) { + const filteredData = data.filter((file) => { + const iswebsite = file.name.toLowerCase() == "website"; + return !file.name.includes(".") && !iswebsite; + }); + + const foldersContainer = document.getElementById("folders-container"); + filteredData.forEach((item) => { + if (item.type === "dir") { + // Create a card for each folder + const folderCard = document.createElement("div"); + folderCard.classList.add("folder-card"); + folderCard.innerHTML = `

${item.name}

${item.path}

`; - // Add click event to redirect to folder - folderCard.addEventListener("click", () => { - window.location.href = item.html_url; - }); - foldersContainer.appendChild(folderCard); - } - }); + // Add click event to redirect to folder + folderCard.addEventListener("click", () => { + window.location.href = item.html_url; + }); + foldersContainer.appendChild(folderCard); + } + }); + } }) .catch((error) => console.error("Error fetching data:", error));