This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_recipe.js
66 lines (57 loc) · 1.73 KB
/
display_recipe.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const { ipcRenderer } = require('electron');
window.$ = window.jQuery = require('jquery');
ipcRenderer.send('display_recipe_ready', "ready");
var link;
ipcRenderer.on('random_recipe_return', (event, arg ) => {
let recipename = document.getElementById('recipename');
let ingredients = document.getElementById('ingredients');
let directions = document.getElementById('directions');
let origin = document.getElementById('origin');
let prep = document.getElementById('prep');
let course = document.getElementById('course');
let ingString = "";
let dirString = "";
let img = document.getElementById('img');
recipename.textContent = arg.recipename;
if(arg.origin != ""){
origin.textContent = "Origin: " + arg.origin;
}
else{
origin.textContent = "Origin: N/A";
}
if(arg.prep != ""){
prep.textContent = "Prep Time: " + arg.prep;
}
else{
prep.textContent = "Prep Time: N/A";
}
if(arg.course != ""){
course.textContent = "Course: " + arg.course;
}
else{
course.textContent = "Course: N/A";
}
if (arg.img != "") img.innerHTML = "<img src = images/" + arg.img + ' width="512" height="360"> </img>';
else img.innerHTML = "";
for(let i = 0; i < arg.ingredients.length; i++){
if(i == arg.ingredients.length - 1){
ingString += arg.ingredients[i];
}
else{
ingString += arg.ingredients[i] + ", ";
}
}
ingredients.textContent = "Ingredients: " + ingString;
for(let i = 0; i < arg.directions.length; i++){
if(i == arg.directions.length - 1){
dirString += arg.directions[i];
}
else{
dirString += arg.directions[i] + ", ";
}
}
directions.textContent = "Directions: " + dirString;
})
document.getElementById('redirect').addEventListener('click', function(){
ipcRenderer.send('redirect_return', link);
})