Skip to content

Commit 72f4414

Browse files
committed
(feat:JS) declutter and reformat code
1 parent 5c3a10c commit 72f4414

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

public/index.js

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import {
1212
stopAudio,
1313
createAudio,
1414
createUserRecipe,
15-
cacheData,
16-
CACHE_NAME_AUDIO,
1715
audioElement,
18-
alert_message
16+
alert_message,
1917
} from "./js_utilities/functions_and_variables.js";
2018

2119
import {
@@ -49,7 +47,7 @@ import {
4947
pictureEmailSection,
5048
previousPage,
5149
sendToUserInbox,
52-
wrapper
50+
wrapper,
5351
} from "./js_utilities/query_selector.js";
5452

5553
let currentCameraIndex = 0;
@@ -190,25 +188,14 @@ recipeButtons.forEach((button) => {
190188
if (eventData.image) {
191189
data.image = eventData.image;
192190
}
193-
191+
194192
console.log("data.audio", eventData.audio);
195193
console.log("data.image", eventData.image);
196194

197195
if (data.audio && data.image) {
196+
createImage(data);
198197

199-
createImage(data)
200-
201-
202-
203-
204-
205-
///
206-
207-
// await cacheData(imageUrl, CACHE_NAME_URL, "image");
208-
209-
// const audio_data = createAudio(data.audio);
210-
// await cacheData(audio_data, CACHE_NAME_AUDIO, "audio");
211-
const {speedBtn, speechBtns } = createTextToSpeech(data);
198+
const { speedBtn, speechBtns } = createTextToSpeech(data);
212199

213200
userWantAnotherRecipe.addEventListener("click", () => {
214201
displayElements([headline, allergies, ...recipeButtons, mainElement]);
@@ -241,7 +228,6 @@ recipeButtons.forEach((button) => {
241228
});
242229
});
243230

244-
245231
function createImage(param) {
246232
removeElements([loadingContainer]);
247233
const imageUrl = param.image.data[0].url;
@@ -259,7 +245,7 @@ function createTextToSpeech(param) {
259245
this.pause();
260246
this.currentTime = 0;
261247
};
262-
return {speedBtn, speechBtns };
248+
return { speedBtn, speechBtns };
263249
}
264250

265251
// Picture section
@@ -313,7 +299,6 @@ async function initializeCamera() {
313299

314300
initializeCamera();
315301

316-
317302
function capturePhoto() {
318303
context.drawImage(video, 0, 0, 400, 100);
319304
}
@@ -352,7 +337,6 @@ takePicture.addEventListener("click", () => {
352337
// Menu icon toggle
353338
const menuIcon = document.querySelector(".menu-icon");
354339

355-
356340
menuIcon.addEventListener("click", () => {
357-
wrapper.classList.toggle("change");
341+
wrapper.classList.toggle("change");
358342
});

public/js_utilities/functions_and_variables.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ function loopOverArrayOfElements(array, display) {
113113

114114

115115

116+
117+
118+
119+
116120
function displayElements(array) {
117121
loopOverArrayOfElements(array, "block");
118122
}

public/url_folder.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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
1+
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

speech.mp3

-752 KB
Binary file not shown.

0 commit comments

Comments
 (0)