Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
89d6339
Created Index and script files added the js code from previous branch
EL1VAS Dec 4, 2025
cc206bf
Added the html from previous branch
EL1VAS Dec 4, 2025
8bb26b9
Changed const films to state
EL1VAS Dec 4, 2025
3bcd058
Added the searcTerm and modified render to filter films
EL1VAS Dec 4, 2025
f4a220c
Changed films to filteredFilms
EL1VAS Dec 4, 2025
141cc0c
Added the search tab in html
EL1VAS Dec 4, 2025
8f605dd
Connected the search tab with js
EL1VAS Dec 4, 2025
de53c66
Changed id to search
EL1VAS Dec 4, 2025
237f1b1
Const to searchBox
EL1VAS Dec 4, 2025
2fa9a70
Created handleSearchInput function and fixed typos
EL1VAS Dec 4, 2025
1a2d846
Added the clearing body
EL1VAS Dec 4, 2025
83101e9
Added a film container in html
EL1VAS Dec 4, 2025
d1bb6da
Added a container instead of clearing the whole body
EL1VAS Dec 4, 2025
d0f03c7
Typo
EL1VAS Dec 4, 2025
0dd02a0
Updated the state
EL1VAS Dec 4, 2025
728f4c4
Appended to container
EL1VAS Dec 4, 2025
0470419
Fixed the author.value instead of title.value twice and fixed the typ…
EL1VAS Dec 4, 2025
7a006c6
Added a parenthesis in the iteration
EL1VAS Dec 4, 2025
70c99b1
Added quotes in id=i
EL1VAS Dec 4, 2025
f131192
Fixed the typo myLibrary
EL1VAS Dec 4, 2025
542f207
Added quotes in delBut id
EL1VAS Dec 4, 2025
fcbeea3
Added a =
EL1VAS Dec 4, 2025
38d4774
Changed false to true for checking
EL1VAS Dec 4, 2025
a6d0e50
Change all delBut to correct delButton of the variable
EL1VAS Dec 4, 2025
718a92c
Corrected clicks to click on delete button
EL1VAS Dec 4, 2025
2df5021
Added the author prerequisite too
EL1VAS Dec 4, 2025
9cc4c7d
Cleared the form after submit and remove the "" from id of buttons
EL1VAS Dec 4, 2025
6017249
Changed type of input to text
EL1VAS Dec 4, 2025
1e74067
Deleted comments
EL1VAS Dec 4, 2025
9d08d7e
Created html file
EL1VAS Dec 11, 2025
01110fe
Added divs and h1
EL1VAS Dec 11, 2025
9745809
Added paragraph
EL1VAS Dec 11, 2025
67b1661
Added input
EL1VAS Dec 11, 2025
8e6b254
Added h4 and p
EL1VAS Dec 11, 2025
8c98742
Created css and js files
EL1VAS Dec 11, 2025
66d8a96
Linked css and js files to my html
EL1VAS Dec 11, 2025
8666557
Writting my function
EL1VAS Dec 11, 2025
80960da
Fixed the id names with ""
EL1VAS Dec 11, 2025
3368e95
Testing
EL1VAS Dec 11, 2025
2a5130e
Testing
EL1VAS Dec 11, 2025
9c5ab43
Added var number
EL1VAS Dec 11, 2025
1fc25c5
Writting the ajax function
EL1VAS Dec 11, 2025
b8eaade
Coded along the video
EL1VAS Dec 11, 2025
ee5a4c2
Added the render function in the submit function
EL1VAS Jan 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions debugging/book-library/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ <h1>Library</h1>
<div class="form-group">
<label for="title">Title:</label>
<input
type="title"
type="text"
class="form-control"
id="title"
name="title"
required
/>
<label for="author">Author: </label>
<input
type="author"
type="text"
class="form-control"
id="author"
name="author"
Expand Down
33 changes: 23 additions & 10 deletions debugging/book-library/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,24 @@ function submit() {
if (
title.value == null ||
title.value == "" ||
author.value == null || // Added the author prerequisite too
author.value == "" || // Added the author prerequisite too
pages.value == null ||
pages.value == ""
) {
alert("Please fill all fields!");
return false;
} else {
let book = new Book(title.value, title.value, pages.value, check.checked);
library.push(book);
let book = new Book(title.value, author.value, pages.value, check.checked); // fixed the author.value
myLibrary.push(book); // Fixed the typo
render();

// We clear the form
title.value = "";
author.value = "";
pages.value = "";
check.checked = false;

render();
}
}
Expand All @@ -54,7 +64,8 @@ function render() {
let table = document.getElementById("display");
let rowsNumber = table.rows.length;
//delete old table
for (let n = rowsNumber - 1; n > 0; n-- {
for (let n = rowsNumber - 1; n > 0; n--) {
// Added a parenthesis
table.deleteRow(n);
}
//insert updated row and cells
Expand All @@ -72,11 +83,12 @@ function render() {

//add and wait for action for read/unread button
let changeBut = document.createElement("button");
changeBut.id = i;
changeBut.id = i; // Added quotes and then removed them as I understood the logic
changeBut.className = "btn btn-success";
wasReadCell.appendChild(changeBut);
let readStatus = "";
if (myLibrary[i].check == false) {
if (myLibrary[i].check === true) {
// Added a = and changed false to true
readStatus = "Yes";
} else {
readStatus = "No";
Expand All @@ -90,11 +102,12 @@ function render() {

//add delete button to every row and render again
let delButton = document.createElement("button");
delBut.id = i + 5;
deleteCell.appendChild(delBut);
delBut.className = "btn btn-warning";
delBut.innerHTML = "Delete";
delBut.addEventListener("clicks", function () {
delButton.id = i + 5; // changed to delButton from delBut
deleteCell.appendChild(delButton); // changed to delButton from delBut
delButton.className = "btn btn-warning"; // changed to delButton from delBut
delButton.innerHTML = "Delete"; // changed to delButton from delBut
delButton.addEventListener("click", function () {
// changed to delButton from delBut and click from clicks
alert(`You've deleted title: ${myLibrary[i].title}`);
myLibrary.splice(i, 1);
render();
Expand Down
29 changes: 29 additions & 0 deletions numberfacts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="style.css">
<Title>Document</Title>
</head>
<body class="main">
<div class="container">
<div class="row">
<div class="column">
<div class="card">
<h1>Number facts</h1>
<p>Enter a number and get a random fact</p>
<input type="number" id="numberInput" name="numberInput" placeholder="Enter any number..">
<div id="fact" class="card-body">
<h4 class="card-title">Number fact</h4>
<p id="factText" class="card-text"></p>
</div>
</div>
</div>
</div>

</div>
<script src="script.js" defer></script>
</body>
</html>
33 changes: 33 additions & 0 deletions numberfacts/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
let fact = document.getElementById("fact");
let factText = document.getElementById("factText");
let numberInput = document.getElementById("numberInput");

numberInput.addEventListener("input", getFactFetch);

function getFactAjax() {
let number = numberInput.value;
let xhr = new XMLHttpRequest();
xhr.open("GET", "http://numbersapi.com/"+number);
xhr.onload = function() {
if (this.status == 200 && number != ""){
fact.style.display = "block"
factText.innerText = this.responseText;
}

}
xhr.send();
}

function getFactFetch() {
let number = numberInput.value;

fetch("http://numbersapi.com/"+number).then(response => response.text()).then(data => {
if (number != "") {
fact.style.display = "block"
factText.innerText = data;
}

})
.catch(error => console.log(error));

}
Empty file added numberfacts/style.css
Empty file.
23 changes: 23 additions & 0 deletions preparation/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="script.js" defer></script>
<title>Document</title>
</head>
<body>
<input type="search" id="search" placeholder="Search films...">
<div id="film-container"></div>

<template id="film-card-template">
<section>
<h1>Film title</h1>
<p data-director>Director</p>
<time>Duration</time>
<p data-certificate>Certificate</p>
</section>
</template>
</body>
</html>
55 changes: 55 additions & 0 deletions preparation/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const state = {
films: [
{
title: "Killing of Flower Moon",
director: "Martin Scorsese",
times: ["15:35"],
certificate: "15",
duration: 112,
},
{
title: "Typist Artist Pirate King",
director: "Carol Morley",
times: ["15:00", "20:00"],
certificate: "12A",
duration: 108,
}
],
searchTerm: "",
};

// Goal refactor this project to use film card template
function createFilmCard(films) {
const filmCard = document.getElementById("film-card-template").content.cloneNode(true);

filmCard.querySelector("h1").textContent = films.title;
filmCard.querySelector("p[data-director]").textContent = films.director;
filmCard.querySelector("time").textContent = films.times;
filmCard.querySelector("p[data-certificate]").textContent = films.certificate;
return filmCard;
};

function render() {
const container = document.getElementById("film-container"); // Calls a container created in html
container.textContent = ""; // Clears the container

const filteredFilms = state.films.filter((film) =>
film.title.includes(state.searchTerm)
);
const filmCards = filteredFilms.map(createFilmCard);
container.append(...filmCards);
};

const searchBox = document.getElementById("search");

searchBox.addEventListener("input", handleSearchInput);

function handleSearchInput(event) {
state.searchTerm = event.target.value; // updates the state
render(); // Re render with filtered results
};

render();