Skip to content

Commit

Permalink
fix javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
XanderG2 committed Apr 23, 2024
1 parent 58e7d30 commit 419a65e
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions website/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ function mainPage() {
"tools",
"weapons",
];
searchbar = document.createElement("input");
const searchbar = document.createElement("input");
searchbar.type = "search";
searchbar.id = "search";
searchbar.placeholder = "Search for recipe...";
select = document.createElement("select");
const select = document.createElement("select");
select.id = "select";
select.setAttribute("onchange", "openRecipesPrep()");
for (const optionText of options) {
Expand All @@ -34,11 +34,11 @@ function mainPage() {
option.value = optionText;
select.appendChild(option);
}
attribution = document.createElement("p");
const attribution = document.createElement("p");
attribution.textContent = "By Xander";
attribution.style.float = "right";
attribution.style.margin = "0";
homeButton = document.createElement("button");
const homeButton = document.createElement("button");
homeButton.textContent = "🏠";
homeButton.style.float = "right";
homeButton.onclick = () => {window.location.href = "https://xander.thegillams.co.uk"};
Expand Down Expand Up @@ -181,8 +181,6 @@ function view() {
completedDiv.appendChild(label1);
resultsDiv.appendChild(uncompletedDiv);
resultsDiv.appendChild(completedDiv);
//resultsRecipeDiv.innerHTML = "";
//let totalHTML2 = document.createElement("div");
for (const [ingredient, amount] of Object.entries(total)) {
const div3 = document.createElement("div");
const br = document.createElement("br");
Expand All @@ -204,18 +202,6 @@ function view() {
div3.className = "noNewLine";
uncompletedDiv.appendChild(div3);
}
//Display total on the right instead of next to
/*for (const [recipe, amount] of Object.entries(recipeAmounts)) {
console.log(recipeAmounts)
const br2 = document.createElement("br");
const text2 = document.createTextNode(`${recipe}: ${amount}`);
const div4 = document.createElement("div");
div4.appendChild(text2);
div4.appendChild(br2);
div4.className = "noNewLine";
totalHTML2.appendChild(div4);
}*/
//resultsRecipeDiv.appendChild(totalHTML2);
Array.from(document.getElementsByClassName("checkbox")).forEach(checkbox => {
checkbox.addEventListener("change", (e) => {
const ingredient = e.target.parentElement.querySelector("#ingredient").textContent
Expand Down

0 comments on commit 419a65e

Please sign in to comment.