
diff --git a/100. Wikipedia Clone/app.js b/100. Wikipedia Clone/app.js new file mode 100644 index 0000000..73b6662 --- /dev/null +++ b/100. Wikipedia Clone/app.js @@ -0,0 +1,82 @@ +const searchForm = document.getElementById("search-form"); +const searchInput = document.getElementById("search-input"); +const searchResults = document.getElementById("search-results"); + +// Theme toggler elements +const themeToggler = document.getElementById("theme-toggler"); +const body = document.body; + +async function searchWikipeida(query) { + const encodedQuery = encodeURIComponent(query); + const endpoint = `https://en.wikipedia.org/w/api.php?action=query&list=search&prop=info&inprop=url&utf8=&format=json&origin=*&srlimit=10&srsearch=${encodedQuery}`; + + const reponse = await fetch(endpoint); + + if (!reponse.ok) { + throw new Error("Faild to fetch search results form wikipedia API."); + } + + const json = await reponse.json(); + return json; +} + +function displayResults(results) { + // Remove the loading spinner + searchResults.innerHTML = ""; + + results.forEach((result) => { + const url = `https://en.wikipedia.org/?curid=${results.pageid}`; + const titleLink = `${result.title} `; + const urlLink = `${url}`; + + const resultItme = document.createElement("div"); + resultItme.className = "result-item"; + resultItme.innerHTML = ` +
${result.snippet}
+ `; + + searchResults.appendChild(resultItme); + }); +} + +searchForm.addEventListener("submit", async (e) => { + e.preventDefault(); + + const query = searchInput.value.trim(); + + if (!query) { + searchResults.innerHTML = "Please enter a valid search term.
"; + return; + } + + searchResults.innerHTML = "No results found.
"; + } else { + displayResults(results.query.search); + } + } catch (error) { + console.error(error); + searchResults.innerHTML = `An error occured while searching. Please try again later.
`; + } +}); + +// Event listener for the theme toggler +themeToggler.addEventListener("click", () => { + body.classList.toggle("dark-theme"); + if (body.classList.contains("dark-theme")) { + themeToggler.textContent = "Dark"; + themeToggler.style.background = "#fff"; + themeToggler.style.color = "#333"; + } else { + themeToggler.textContent = "Light"; + themeToggler.style.border = "2px solid #ccc"; + themeToggler.style.color = "#333"; + } +}); diff --git a/100. Wikipedia Clone/index.html b/100. Wikipedia Clone/index.html new file mode 100644 index 0000000..c65e204 --- /dev/null +++ b/100. Wikipedia Clone/index.html @@ -0,0 +1,25 @@ + + + + ++ Art, also called (to distinguish it from other art forms) visual art, a + visual object or experience consciously + created through an expression of skill or imagination. +
++ The seven different art forms are + + Painting, Sculpture, Literature, Architecture, Theater, Film, and + Music + + . However, back in the day, the seven different art forms were called + the Liberal Arts, consisting of Grammar, Logic, Rhetoric, Arithmetic, + Geometry, Astronomy, and Music. +
+ ++ Lorem ipsum dolor sit amet consectetur, adipisicing elit. Unde + nostrum consequatur, nulla explicabo vero nesciunt architecto + officiis eius ullam alias. +
+ +${login}
+ +${bio}
+${description}
+${language}
+${watchers_count}
+Public
+ `; + singleElement.innerHTML = html; + reposContainer.append(singleElement); + } + ); + } catch (error) { + console.error(error); + } +} + +form.addEventListener("submit", async (e) => { + e.preventDefault(); + const val = input.value; + + if (val) { + try { + await fetchData(val); + await fetchRepos(val); + } catch (error) { + console.log(error); + } finally { + input.value = ""; + } + } + + document + .querySelector("input") + .addEventListener("click", () => location.reload()); +}); diff --git a/99. Github Profile Clone/git-fork_1.svg b/99. Github Profile Clone/git-fork_1.svg new file mode 100644 index 0000000..5caf333 --- /dev/null +++ b/99. Github Profile Clone/git-fork_1.svg @@ -0,0 +1,39 @@ + \ No newline at end of file diff --git a/99. Github Profile Clone/index.html b/99. Github Profile Clone/index.html new file mode 100644 index 0000000..d313fbd --- /dev/null +++ b/99. Github Profile Clone/index.html @@ -0,0 +1,289 @@ + + + + +Popular Repositories
+