Skip to content

Commit

Permalink
(feat:JS) declutter and reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
josueJURE committed Aug 3, 2024
1 parent 5c3a10c commit 72f4414
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
30 changes: 7 additions & 23 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import {
stopAudio,
createAudio,
createUserRecipe,
cacheData,
CACHE_NAME_AUDIO,
audioElement,
alert_message
alert_message,
} from "./js_utilities/functions_and_variables.js";

import {
Expand Down Expand Up @@ -49,7 +47,7 @@ import {
pictureEmailSection,
previousPage,
sendToUserInbox,
wrapper
wrapper,
} from "./js_utilities/query_selector.js";

let currentCameraIndex = 0;
Expand Down Expand Up @@ -190,25 +188,14 @@ recipeButtons.forEach((button) => {
if (eventData.image) {
data.image = eventData.image;
}

console.log("data.audio", eventData.audio);
console.log("data.image", eventData.image);

if (data.audio && data.image) {
createImage(data);

createImage(data)





///

// await cacheData(imageUrl, CACHE_NAME_URL, "image");

// const audio_data = createAudio(data.audio);
// await cacheData(audio_data, CACHE_NAME_AUDIO, "audio");
const {speedBtn, speechBtns } = createTextToSpeech(data);
const { speedBtn, speechBtns } = createTextToSpeech(data);

userWantAnotherRecipe.addEventListener("click", () => {
displayElements([headline, allergies, ...recipeButtons, mainElement]);
Expand Down Expand Up @@ -241,7 +228,6 @@ recipeButtons.forEach((button) => {
});
});


function createImage(param) {
removeElements([loadingContainer]);
const imageUrl = param.image.data[0].url;
Expand All @@ -259,7 +245,7 @@ function createTextToSpeech(param) {
this.pause();
this.currentTime = 0;
};
return {speedBtn, speechBtns };
return { speedBtn, speechBtns };
}

// Picture section
Expand Down Expand Up @@ -313,7 +299,6 @@ async function initializeCamera() {

initializeCamera();


function capturePhoto() {
context.drawImage(video, 0, 0, 400, 100);
}
Expand Down Expand Up @@ -352,7 +337,6 @@ takePicture.addEventListener("click", () => {
// Menu icon toggle
const menuIcon = document.querySelector(".menu-icon");


menuIcon.addEventListener("click", () => {
wrapper.classList.toggle("change");
wrapper.classList.toggle("change");
});
4 changes: 4 additions & 0 deletions public/js_utilities/functions_and_variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ function loopOverArrayOfElements(array, display) {







function displayElements(array) {
loopOverArrayOfElements(array, "block");
}
Expand Down
2 changes: 1 addition & 1 deletion public/url_folder.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://oaidalleapiprodscus.blob.core.windows.net/private/org-nYbqgo3O0LNnYYAoKAmApBfx/user-58Je7efi0iy880e2UYCdYpBm/img-fbR4IrnpCaFXDhT8PUcmxpzx.png?st=2024-08-03T13%3A15%3A50Z&se=2024-08-03T15%3A15%3A50Z&sp=r&sv=2023-11-03&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-08-03T02%3A55%3A58Z&ske=2024-08-04T02%3A55%3A58Z&sks=b&skv=2023-11-03&sig=sG/XDU1mSuiPQI07H8PG/7h3tfkc0OOEVLwAOds4aIg%3D
https://oaidalleapiprodscus.blob.core.windows.net/private/org-nYbqgo3O0LNnYYAoKAmApBfx/user-58Je7efi0iy880e2UYCdYpBm/img-ovb7qD0yHMLLx0Ooe4iCpSOE.png?st=2024-08-03T13%3A22%3A53Z&se=2024-08-03T15%3A22%3A53Z&sp=r&sv=2023-11-03&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-08-03T04%3A05%3A06Z&ske=2024-08-04T04%3A05%3A06Z&sks=b&skv=2023-11-03&sig=bDE%2Bp86dJ7jZ6nydnnnKPumw/XA0M1VaghM8Bm5XY5E%3D
Binary file modified speech.mp3
Binary file not shown.

0 comments on commit 72f4414

Please sign in to comment.