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-09 10:17:33 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
07bc6d22e3bcfc995dc300214c1d83006267c2a2
07bc6d22
2 parents
10369b05
2d3c21ce
Update main.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
17 deletions
main/main.js
main/main.js
View file @
07bc6d2
Kakao
.
init
(
'fill your own key'
);
const
APP_ID
=
'fill your own ID'
;
const
APP_KEY
=
'fill your own key'
;
var
caloriesLimit
=
9999
;
function
getCheckboxValue
(
event
)
{
if
(
event
.
target
.
checked
)
{
...
...
@@ -7,11 +10,9 @@ function getCheckboxValue(event) {
}
}
const
searchForm
=
document
.
querySelector
(
'form'
);
const
searchResultDiv
=
document
.
querySelector
(
'.search-result'
)
const
APP_ID
=
'0a67fbc1'
;
const
APP_KEY
=
'225d31b59bf211d7ede34e2e885f1f3b'
;
searchForm
.
addEventListener
(
'submit'
,
function
(
event
){
if
(
document
.
getElementById
(
'name'
).
value
.
length
===
0
){
alert
(
'한글자 이상 입력해주세요'
);
...
...
@@ -27,19 +28,33 @@ searchForm.addEventListener('submit', function(event){
fetchAPI
();
}
});
function
shareRecipe
(
sns
,
urlInfo
)
{
console
.
log
(
urlInfo
);
var
thisUrl
=
document
.
URL
;
var
snsWrite
=
"요리 레시피 공유하기"
+
urlInfo
;
function
shareRecipe
(
sns
,
urlInfo
,
foodImage
,
foodLabel
)
{
var
documentUrl
=
document
.
URL
;
var
snsWrite
=
"친구에게 요리 레시피 추천! 같이 요리 해먹자~"
+
urlInfo
;
if
(
sns
==
'facebook'
)
{
var
url
=
"http://www.facebook.com/sharer/sharer.php?u="
+
encodeURIComponent
(
thisUrl
);
var
url
=
"http://www.facebook.com/sharer/sharer.php?u="
+
encodeURIComponent
(
urlInfo
);
window
.
open
(
url
,
""
,
"width=600, height=4060"
);
}
else
if
(
sns
==
'twitter'
)
{
var
url
=
"http://twitter.com/share?url="
+
encodeURIComponent
(
this
Url
)
+
"&text="
+
encodeURIComponent
(
snsWrite
);
var
url
=
"http://twitter.com/share?url="
+
encodeURIComponent
(
document
Url
)
+
"&text="
+
encodeURIComponent
(
snsWrite
);
window
.
open
(
url
,
"tweetPop"
,
"width=600, height=400,scrollbars=yes"
);
}
else
if
(
sns
==
'kakaotalk'
){
Kakao
.
Link
.
createDefaultButton
({
container
:
'#buttonkakao'
,
objectType
:
'feed'
,
content
:{
title
:
"친구에게 요리 레시피 추천!"
,
description
:
foodLabel
+
" 같이 요리 해먹자~"
,
imageUrl
:
foodImage
,
link
:{
mobileWebUrl
:
urlInfo
,
webUrl
:
urlInfo
},
},
});
}
}
async
function
fetchAPI
(){
const
recipeURL
=
`https://api.edamam.com/search?q=
${
searchQuery
}
&app_id=
${
APP_ID
}
&app_key=
${
APP_KEY
}
`
;
const
response
=
await
fetch
(
recipeURL
);
...
...
@@ -71,14 +86,18 @@ function boxinfo(results){
<a href="
${
result
.
recipe
.
url
}
" target="_blank">View Recipe</a>
<!--result.recipe.labe에 + home + recipe 한 검색결과 페이지를 버튼에 링크시켜놓음-->
<a href="https://www.youtube.com/results?search_query=
${
result
.
recipe
.
label
}
+home+recipe" target="_blank">View Videos</a>
<ul class="sns">
<li class="facebook">
<a href="#n" onclick="shareRecipe('facebook','
${
result
.
recipe
.
url
}
'');return false;" class="facebook" target="_self" title="페이스북 공유"><span class="skip">페이스북</span></a>
</li>
<li class="twitter">
<a href="#n" onclick="shareRecipe('twitter','
${
result
.
recipe
.
url
}
');return false;" class="twitter" target="_self" title="트위터 공유"><span class="skip">트위터</span></a>
</li>
</ul>
<ul class="sns">
<li class="facebook">
<a href="#n" onclick="shareRecipe('facebook','
${
result
.
recipe
.
url
}
');return false;" class="facebook" target="_self" title="페이스북 공유"><span class="skip">페이스북</span></a>
</li>
<li class="twitter">
<a href="" onclick="shareRecipe('twitter','
${
result
.
recipe
.
url
}
');return false;" class="twitter" target="_self" title="트위터 공유"><span class="skip">트위터</span></a>
</li>
<li class="kakaotalk">
<a href="javascript:shareRecipe('kakaotalk','
${
result
.
recipe
.
url
}
','
${
result
.
recipe
.
image
}
','
${
result
.
recipe
.
label
}
')" id="buttonkakao" onclick="shareRecipe('kakaotalk','
${
result
.
recipe
.
url
}
','
${
result
.
recipe
.
image
}
','
${
result
.
recipe
.
label
}
');return false;" class="kakaotalk" target="_self" title="카카오톡 새창열림"><span class="skip">카카오톡</span></a>
</li>
</ul>
</div>
${(
cal
=>
{
if
(
cal
>=
2000
)
{
...
...
Please
register
or
login
to post a comment