Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kenmusonda/HTML-CSS-JavaScript-100-Projects
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: HuXn-WebDev/HTML-CSS-JavaScript-100-Projects
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 9 commits
  • 21 files changed
  • 1 contributor

Commits on Apr 13, 2023

  1. New URL Added

    HuXn-WebDev committed Apr 13, 2023
    Copy the full SHA
    94e6567 View commit details

Commits on Jun 21, 2023

  1. BookList Project

    HuXn-WebDev committed Jun 21, 2023
    Copy the full SHA
    837f9ef View commit details
  2. The Art Landing Page

    HuXn-WebDev committed Jun 21, 2023
    Copy the full SHA
    97be8cd View commit details
  3. Copy the full SHA
    efc36b6 View commit details
  4. Meal Finder Project

    HuXn-WebDev committed Jun 21, 2023
    Copy the full SHA
    87aa8c5 View commit details
  5. Meal Finder rename

    HuXn-WebDev committed Jun 21, 2023
    Copy the full SHA
    0908960 View commit details

Commits on Jun 22, 2023

  1. Github Profile Clone

    HuXn-WebDev committed Jun 22, 2023
    Copy the full SHA
    b3f3c76 View commit details

Commits on Jun 23, 2023

  1. 100 Projects Done

    HuXn-WebDev committed Jun 23, 2023
    Copy the full SHA
    4c167ef View commit details
  2. 100 Projects Done

    HuXn-WebDev committed Jun 23, 2023
    Copy the full SHA
    8214145 View commit details
82 changes: 82 additions & 0 deletions 100. Wikipedia Clone/app.js
Original file line number Diff line number Diff line change
@@ -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 = `<a href="${url}" target="_blank" rel="noopener">${result.title} </a>`;
const urlLink = `<a href="${url} class="result-link" target="_blank" rel="noopener">${url}</a>`;

const resultItme = document.createElement("div");
resultItme.className = "result-item";
resultItme.innerHTML = `
<h3 class="result-title">${titleLink}</h3>
${urlLink}
<p class="result-snippet">${result.snippet}</p>
`;

searchResults.appendChild(resultItme);
});
}

searchForm.addEventListener("submit", async (e) => {
e.preventDefault();

const query = searchInput.value.trim();

if (!query) {
searchResults.innerHTML = "<p>Please enter a valid search term. </p>";
return;
}

searchResults.innerHTML = "<div class='spinner'>Loading ... </div>";

try {
const results = await searchWikipeida(query);

if (results.query.searchinfo.totalhits === 0) {
searchResults.innerHTML = "<p>No results found. </p>";
} else {
displayResults(results.query.search);
}
} catch (error) {
console.error(error);
searchResults.innerHTML = `<p>An error occured while searching. Please try again later. </p>`;
}
});

// 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";
}
});
25 changes: 25 additions & 0 deletions 100. Wikipedia Clone/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Wiki Clone</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<div class="header-container">
<h1>Search Wikipedia</h1>
<span id="theme-toggler">Light</span>
</div>

<form id="search-form">
<input type="text" id="search-input" placeholder="Enter search term" />
<button type="submit">Search</button>
</form>

<div id="search-results"></div>
</div>

<script src="app.js"></script>
</body>
</html>
131 changes: 131 additions & 0 deletions 100. Wikipedia Clone/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
* {
box-sizing: border-box;
}

body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}

.container {
max-width: 800px;
margin: 0 auto;
padding: 2rem;
}

h1 {
font-size: 3rem;
margin-bottom: 2rem;
}

#search-form {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 2rem;
}

#search-input {
font-size: 1.2rem;
padding: 0.5rem 1rem;
margin-right: 1rem;
border: 2px solid #ccc;
border-radius: 0.25rem;
flex-grow: 1;
}

#search-input:focus {
outline: none;
border-color: #0074d9;
}

button[type="submit"] {
font-size: 1.2rem;
padding: 0.5rem 1rem;
background-color: #0074d9;
color: #fff;
border: none;
border-radius: 0.25rem;
cursor: pointer;
}

button[type="submit"]:hover {
background-color: #0063ad;
}

#search-results {
margin-bottom: 2rem;
}

.result-item {
margin-bottom: 1rem;
}

.result-title {
font-size: 1.5rem;
margin-top: 0;
}

.result-link {
display: block;
font-size: 1.2rem;
margin-bottom: 0.5rem;
color: #0074d9;
}

.result-link:hover {
text-decoration: underline;
}

.result-snippet {
margin-top: 0;
}

.spinner {
display: flex;
justify-content: center;
align-items: center;
font-size: 2rem;
height: 10rem;
}

/* Dark theme */
.header-container {
display: flex;
justify-content: space-between;
align-items: center;
}

#theme-toggler {
border: none;
background: transparent;
cursor: pointer;
background: #e2e2e2;
padding: 10px 20px;
border-radius: 100px;
}

.dark-theme {
background-color: #282c34;
color: #fff;
}

.dark-theme #search-input {
background-color: #454545;
color: #fff;
border-color: #fff;
}

.dark-theme #search-input:focus {
border-color: #0074d9;
}

.dark-theme button[type="submit"] {
background-color: #0074d9;
}

.dark-theme .result-link,
.dark-theme .result-link:hover {
color: #90caf9;
}
2 changes: 1 addition & 1 deletion 41. Random Images Feed/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const container = document.querySelector(".content");
const baseURL = "https://source.unsplash.com/random/";
const baseURL = "https://source.unsplash.com/all/";
const rows = 7;

for (let i = 0; i < rows * 3; i++) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading