Skip to content

Commit

Permalink
Merge pull request #673 from pandeyji711/New_web
Browse files Browse the repository at this point in the history
fixed no results
  • Loading branch information
jfmartinz authored Jun 1, 2024
2 parents 41559a3 + c75eec6 commit 03326b9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 52 deletions.
2 changes: 1 addition & 1 deletion website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ <h1 class="text-white text-4xl sm:text-6xl lg:text-7xl mb-30 text-center trackin
<input type="text" class="search-input w-full p-2 rounded-full bg-transparent text-white"
placeholder="Search..." oninput="filterCards()">
</div>
<div id="rate-limit-message" class="mb-4" ></div>
<div id="loading"></div>
<center>
<div id="card-container"
class="bg-black hover:text-black cards grid grid-cols-2 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 gap-2 ">
Expand Down
83 changes: 32 additions & 51 deletions website/mainapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@

// script.js
document.addEventListener("DOMContentLoaded", async function () {
const loading = document.getElementById("card-container");
loading.innerHTML = `
<p class="classic-4 text-white font-semibold text-center text-2xl ">Loading....</p>
`;
const loading = document.getElementById("loading");
loading.innerHTML = `<h1 class="loading">Loading</h1>`;
const cardContainer = document.getElementById("card-container");
//Api token fetching ,from different root
const _0x4fa59d = _0x1546;
Expand Down Expand Up @@ -170,11 +167,8 @@ document.addEventListener("DOMContentLoaded", async function () {
return _0x1b09();
}
function fetchGitHubData(url) {
const loading = document.getElementById("card-container");
loading.innerHTML = `
<p class="classic-4 text-white font-semibold text-center text-2xl ">Loading....</p>
`;
const loading1 = document.getElementById("loading1");
loading.innerHTML = `<h1 class="loading">Loading</h1>`;

fetch(url, {
headers: {
Expand All @@ -200,8 +194,10 @@ document.addEventListener("DOMContentLoaded", async function () {
<p style="font-size: x-large;">Error while fetching... <button onclick="window.location.reload()">Retry</button> </p>`;
throw new Error(`HTTP error! status: ${response.status}`);
} else {
const loading = document.getElementById("card-container");
loading.innerHTML = " ";
const loading2 = document.getElementById("card-container");
loading2.innerHTML = " ";
loading1.innerHTML = ``;
loading.innerHTML = ``;
return response.json();
}
})
Expand Down Expand Up @@ -291,47 +287,32 @@ function filterCards() {
}

// Filter and sort cards from the original set of cards
const filteredCards = originalCards.filter(card => {
const title = card.querySelector("p").textContent.toLowerCase();
return title.includes(val);
}).sort((a, b) => {
const titleA = a.querySelector("p").textContent.toLowerCase();
const titleB = b.querySelector("p").textContent.toLowerCase();
return titleA.localeCompare(titleB);
});
const filteredCards = originalCards
.filter((card) => {
const title = card.querySelector("p").textContent.toLowerCase();
return title.includes(val);
})
.sort((a, b) => {
const titleA = a.querySelector("p").textContent.toLowerCase();
const titleB = b.querySelector("p").textContent.toLowerCase();
return titleA.localeCompare(titleB);
});

// Clear the container
cardContainer.innerHTML = "";

// Append filtered and sorted cards with 10px left margin
filteredCards.forEach(card => {
filteredCards.forEach((card) => {
card.style.marginLeft = "85px";
cardContainer.appendChild(card);
});

// To check if any cards are displayed
const displayedCards = document.querySelectorAll(".card");
let count = 0;
displayedCards.forEach((card) => {
if (card.style.display === "block") {
count++;
}
});
if (count === 0) {
document.getElementById("rate-limit-message").style.display = "block";
document.getElementById("rate-limit-message").innerHTML = "No results";
} else {
document.getElementById("rate-limit-message").style.display = "none";
}
}

// Ensure the filterCards function runs initially after DOM content is loaded
document.addEventListener("DOMContentLoaded", filterCards);





// LOTTIE ANIMATION

// Load Lottie animation
Expand All @@ -352,24 +333,24 @@ window.addEventListener("resize", function () {
});

// fucntionality to tackle the light/dark mode toggle option.
document.addEventListener('DOMContentLoaded', () => {
const themeToggleButton = document.getElementById('theme-toggle');
document.addEventListener("DOMContentLoaded", () => {
const themeToggleButton = document.getElementById("theme-toggle");
const body = document.body;

// Load saved theme
if (localStorage.getItem('theme') === 'light') {
body.classList.add('light-mode');
themeToggleButton.checked = true;
if (localStorage.getItem("theme") === "light") {
body.classList.add("light-mode");
themeToggleButton.checked = true;
}

themeToggleButton.addEventListener('change', () => {
body.classList.toggle('light-mode');
themeToggleButton.addEventListener("change", () => {
body.classList.toggle("light-mode");

// Save theme preference
if (body.classList.contains('light-mode')) {
localStorage.setItem('theme', 'light');
} else {
localStorage.removeItem('theme');
}
// Save theme preference
if (body.classList.contains("light-mode")) {
localStorage.setItem("theme", "light");
} else {
localStorage.removeItem("theme");
}
});
});

0 comments on commit 03326b9

Please sign in to comment.