Toggle navigation
Toggle navigation
This project
Loading...
Sign in
구희연
/
Food_recipe_info
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
윤희찬
2021-12-05 00:20:21 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dfaf523d8f1e2621031eff42b51ab23a036caac2
dfaf523d
1 parent
da4e68fd
Add calories color
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletions
main/main.js
main/main.js
View file @
dfaf523
...
...
@@ -27,6 +27,9 @@ async function fetchAPI(){
function
boxinfo
(
results
){
let
boxsinfo
=
''
;
results
.
map
(
result
=>
{
const
object
=
{
cal
:
result
.
recipe
.
calories
.
toFixed
(
0
)
};
boxsinfo
+=
`
<style>
...
...
@@ -52,7 +55,18 @@ function boxinfo(results){
<h1 class="title">
${
result
.
recipe
.
label
}
</h1>
<a href="
${
result
.
recipe
.
url
}
" target="_blank">View Recipe</a>
</div>
<p class="item-data">Calories:
${
result
.
recipe
.
calories
.
toFixed
(
0
)}
</p>
${(
cal
=>
{
if
(
cal
>=
2000
)
{
return
`<p style="color:red">
${
cal
}
</p>`
;
}
else
if
(
cal
>=
1000
&&
cal
<
2000
){
return
`<p style="color:yellow">
${
cal
}
</p>`
;
}
else
{
return
`<p style="color:green">
${
cal
}
</p>`
;
}
})(
object
.
cal
)
}
<
/div
>
`
})
...
...
Please
register
or
login
to post a comment