Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kkyh12180 committed Nov 12, 2023
2 parents 17eb86c + 74c7d5c commit edb9fae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 33 deletions.
27 changes: 14 additions & 13 deletions src/html/initial.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,14 @@ <h1>탑승 가능한 열차 목록</h1>
</tbody>
</table>


<br>
<h1>카카오톡으로 받기</h1><br>

<div>
<a href="javascript:sendLink();"><img
src="https://developers.kakao.com/assets/img/about/logos/kakaolink/kakaolink_btn_medium.png" /></a>
</div>
<br>
<br>
<h1>카카오톡으로 받기 <a href="javascript:sendLink();"><img
src="https://developers.kakao.com/assets/img/about/logos/kakaolink/kakaolink_btn_medium.png" style="width: 50px; padding-left: 10px;"/></a></h1><br>
<br>
<br>
<br>


</div>
Expand Down Expand Up @@ -905,23 +905,24 @@ <h1 class="footer-logo">
<script>
async function submitRowAsync(dep, arr, date, time) {
try {
const { text } = await (
const script = await (
await fetch(`/api/onecall_script`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
dep: dep,
arr: arr,
date: date,
time: time,
"dep": dep,
"arr": arr,
"date": date,
"time": time,
}),
})
).text();
console.log(script)

// 서버에서 받아온 텍스트 데이터를 script 엘리먼트에 설정
document.querySelector('#script').textContent = text;
document.querySelector('#script').textContent = script;

//Kakao.init('391acf89e1f687dc86a1818add37f25a'); // 초기화 (한 번만 초기화 필요)
//
Expand Down
23 changes: 3 additions & 20 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>KK</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&amp;display=swap">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/reset.min.css">

<!-- kakaotalk message api -->
<script src="https://developers.kakao.com/sdk/js/kakao.js"></script>

<!-- 자동으로 첫화면으로 이동하게 코드 삽입 -->
<script language="javascript"> location.href='./html/initial.html'; </script>

<style>
body {
Expand Down Expand Up @@ -313,20 +314,6 @@ <h1>Vanilla JavaScript App</h1>
// 여기에서 서버 응답 처리
console.log(responseData);
document.querySelector('#script').textContent = responseData;

Kakao.init('391acf89e1f687dc86a1818add37f25a'); // 초기화

function sendLink() { // 카카오톡 공유하기
Kakao.Link.sendDefault({
objectType: 'text',
text: '안녕하세요, 원콜 서비스를 이용하려 합니다. 물금역에서 대전역으로 12월 11일 오후 12시 23분에 출발하는 기차 승차권 3매를 예매하고 싶어요. 제 이름은 홍길동입니다.',
link: {
mobileWebUrl: 'https://developers.kakao.com/docs/js/kakaotalklink#텍스트-템플릿-보내기',
webUrl: 'https://developers.kakao.com/docs/js/kakaotalklink#텍스트-템플릿-보내기',
},
})
}

} catch (error) {
// 오류 처리
console.error('Error submitting form:', error);
Expand All @@ -338,10 +325,6 @@ <h1>Vanilla JavaScript App</h1>

</script>

<div>
<a href="javascript:sendLink();"><img
src="https://developers.kakao.com/assets/img/about/logos/kakaolink/kakaolink_btn_medium.png" /></a>
</div>
</body>

</html>

0 comments on commit edb9fae

Please sign in to comment.