menu.html 15.8 KB
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        <meta name="description" content="" />
        <meta name="author" content="" />
        <title>Modern Business - Start Bootstrap Template</title>
        <!-- Favicon-->
        <link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
        <!-- Bootstrap icons-->
        <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css" rel="stylesheet" />
        <!-- Core theme CSS (includes Bootstrap)-->
        <link href="css/styles.css" rel="stylesheet" />
    </head>
    <body class="d-flex flex-column">
        <main class="flex-shrink-0">
            <!-- Navigation-->
            <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
                <div class="container px-5">
                    <a class="navbar-brand" href="/">휴게소 정보</a>
                    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
                    <div class="collapse navbar-collapse" id="navbarSupportedContent">
                        <ul class="navbar-nav ms-auto mb-2 mb-lg-0">
                            <li class="nav-item"><a class="nav-link" href="/">Home</a></li>
                            <li class="nav-item"><a class="nav-link" href="/menu">휴게소 메뉴</a></li>
                            <li class="nav-item"><a class="nav-link" href="/weather">날씨</a></li>
                            <li class="nav-item"><a class="nav-link" href="/lpg">LPG</a></li>
                            <li class="nav-item"><a class="nav-link" href="/post">Board</a></li>
                            <li class="nav-item dropdown">
                                <a class="nav-link dropdown-toggle" id="navbarDropdownBlog" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Blog</a>
                                <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownBlog">
                                    <li><a class="dropdown-item" href="blog-home.html">Blog Home</a></li>
                                    <li><a class="dropdown-item" href="blog-post.html">Blog Post</a></li>
                                </ul>
                            </li>
                            <li class="nav-item dropdown">
                                <a class="nav-link dropdown-toggle" id="navbarDropdownLogin" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Login</a>
                                <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownLogin">
                                    <li><a class="dropdown-item" href="/login">Login</a></li>
                                    <li><a class="dropdown-item" href="/signup">Sign-up</a></li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                </div>
            </nav>

            <!-- Header-->
            <header class="py-5">
                <div class="container px-5">
                    <div class="row justify-content-center">
                        <div class="col-lg-8 col-xxl-6">
                            <div class="text-center my-5">
                                <h1 class="fw-bolder mb-3">휴게소 메뉴 정보</h1>
                                <p class="lead fw-normal text-muted mb-4">Just search the name of the rest stop,<br>You'll find out what kind of food there is at the rest area.</p>
                                <p><h3>검색할 휴게소의 이름을 입력하세요</h3></p>
                                
                                <input type="text" placeholder="내용을 입력하세요" id="menuname"><input type="button"  onclick="Showmenu()" value="확인">
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </header>

            <!--추천메뉴-->
            <section class="py-5 bg-light">
                <div class="container px-2 my-2">
                    <div class="text-center">
                        <h2 class="fw-bolder">추천메뉴</h2>
                        <p class="lead fw-normal text-muted mb-5">Recommend the menu you can eat at the rest stop</p>
                    </div>
                    <div class="row gx-5 row-cols-1 row-cols-sm-2 row-cols-xl-4 justify-content-center">
                        <div class="col mb-5 mb-5 mb-xl-0">
                            <div class="text-center">
                                <img class="img-fluid rounded-circle mb-4 px-4" src="https://dummyimage.com/150x150/ced4da/6c757d" alt="..." />
                                <h5 class="fw-bolder"><recommend1></recommend1></h5>
                                <div class="fst-italic text-muted"><rec1></rec1></div>
                            </div>
                        </div>
                        <div class="col mb-5 mb-5 mb-xl-0">
                            <div class="text-center">
                                <img class="img-fluid rounded-circle mb-4 px-4" src="https://dummyimage.com/150x150/ced4da/6c757d" alt="..." />
                                <h5 class="fw-bolder"><recommend2></recommend2></h5>
                                <div class="fst-italic text-muted"><rec2></rec2></div>
                            </div>
                        </div>
                        <div class="col mb-5 mb-5 mb-sm-0">
                            <div class="text-center">
                                <img class="img-fluid rounded-circle mb-4 px-4" src="https://dummyimage.com/150x150/ced4da/6c757d" alt="..." />
                                <h5 class="fw-bolder"><recommend3></recommend3></h5>
                                <div class="fst-italic text-muted"><rec3></rec3></div>
                            </div>
                        </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>


            <!--menu1-->  
            <section class="py-3">
                <div class="container px-0.1 my-0.1">
                    <div class="text-center">
                        <h4 class="fw-bolder"> <menu1></menu1></h4>
                </div>
            </section>  
            
            <section class="py-5 bg-light" id="scroll-target">
                <div class="container px-2 my-2">
                    <div class="text-center">
                        <h2 class="fw-bolder"><foodname1></foodname1></h2>
                        <p class="lead fw-normal text-muted mb-0"><foodcost1></foodcost1></p>
                    </div>
                </div>
            </section>


            <!--menu2-->
            <section class="py-3">
                <div class="container px-0.1 my-0.1">
                    <div class="text-center">
                        <h4 class="fw-bolder"> <menu2></menu2></h4>
                </div>
            </section>  

            <section class="py-5 bg-light" id="scroll-target">
                <div class="container px-2 my-2">
                    <div class="text-center">
                        <h2 class="fw-bolder"><foodname2></foodname2></h2>
                        <p class="lead fw-normal text-muted mb-0"><foodcost2></foodcost2></p>
                    </div>
                </div>
            </section>


            <!--menu3-->
            <section class="py-3">
                <div class="container px-0.1 my-0.1">
                    <div class="text-center">
                        <h4 class="fw-bolder"> <menu3></menu3> </h4>
                </div>
            </section>  

            <section class="py-5 bg-light" id="scroll-target">
                <div class="container px-2 my-2">
                    <div class="text-center">
                        <h2 class="fw-bolder"><foodname3></foodname3></h2>
                        <p class="lead fw-normal text-muted mb-0"><foodcost3></foodcost3></p>
                    </div>
                </div>
            </section>


            <!--menu4-->
            <section class="py-3">
                <div class="container px-0.1 my-0.1">
                    <div class="text-center">
                        <h4 class="fw-bolder"> <menu4></menu4></h4>
                </div>
            </section>  

            <section class="py-5 bg-light" id="scroll-target">
                <div class="container px-2 my-2">
                    <div class="text-center">
                            <h2 class="fw-bolder"><foodname4></foodname4></h2>
                            <p class="lead fw-normal text-muted mb-0"><foodcost4></foodcost4></p>
                    </div>
                </div>
            </section>


            <!--menu5-->
            <section class="py-3">
                <div class="container px-0.1 my-0.1">
                    <div class="text-center">
                        <h4 class="fw-bolder"> <menu5></menu5> </h4>
                </div>
            </section>  

            <section class="py-5 bg-light" id="scroll-target">
                <div class="container px-2 my-2">
                    <div class="text-center">
                        <h2 class="fw-bolder"><foodname5></foodname5></h2>
                        <p class="lead fw-normal text-muted mb-0"><foodcost5></foodcost5></p>
                    </div>
                </div>
            </section>
            

            <!--menu6-->
            <section class="py-3">
                <div class="container px-0.1 my-0.1">
                    <div class="text-center">
                        <h4 class="fw-bolder"> <menu6></menu6> </h4>
                </div>
            </section>  

            <section class="py-5 bg-light" id="scroll-target">
                <div class="container px-2 my-2">
                    <div class="text-center">
                        <h2 class="fw-bolder"><foodname6></foodname6></h2>
                        <p class="lead fw-normal text-muted mb-0"><foodcost6></foodcost6></p>
                    </div>
                </div>
            </section>    

            <!--menu7-->
            <section class="py-3">
                <div class="container px-0.1 my-0.1">
                    <div class="text-center">
                        <h4 class="fw-bolder"> <menu7></menu7> </h4>
                </div>
            </section>  

            <section class="py-5 bg-light" id="scroll-target">
                <div class="container px-2 my-2">
                    <div class="text-center">
                        <h2 class="fw-bolder"><foodname7></foodname7></h2>
                        <p class="lead fw-normal text-muted mb-0"><foodcost7></foodcost6></p>
                    </div>
                </div>
            </section>  

            <!--menu8-->
            <section class="py-3">
                <div class="container px-0.1 my-0.1">
                    <div class="text-center">
                        <h4 class="fw-bolder"> <menu8></menu8> </h4>
                </div>
            </section>  

            <section class="py-5 bg-light" id="scroll-target">
                <div class="container px-2 my-2">
                    <div class="text-center">
                        <h2 class="fw-bolder"><foodname8></foodname8></h2>
                        <p class="lead fw-normal text-muted mb-0"><foodcost8></foodcost8></p>
                    </div>
                </div>
            </section>        

        </main>
        <!-- Footer-->
        <footer class="bg-dark py-4 mt-auto">
            <div class="container px-5">
                <div class="row align-items-center justify-content-between flex-column flex-sm-row">
                    <div class="col-auto"><div class="small m-0 text-white">Copyright &copy; Your Website 2022</div></div>
                    <div class="col-auto">
                        <a class="link-light small" href="#!">Privacy</a>
                        <span class="text-white mx-1">&middot;</span>
                        <a class="link-light small" href="#!">Terms</a>
                        <span class="text-white mx-1">&middot;</span>
                        <a class="link-light small" href="#!">Contact</a>
                    </div>
                </div>
            </div>
        </footer>

        <!--fetch로 오픈 api 데이터 끌어오기-->
        <script>  

            function Showmenu() {
            menuname = document.getElementById('menuname').value

            fetch('http://data.ex.co.kr/openapi/restinfo/restBestfoodList?key=6806352377&type=json&numOfRows=1000' + '&stdRestNm='+menuname).then(function(response){
                  method: 'GET';
                  body: JSON.stringify(this.obj)
                  response.text().then(function(text){
                  
                  //데이터 정렬 및 text data-> array data 변환
                  index1=text.indexOf('[')
                  index2=text.indexOf(']')
                  ndata=text.substr(index1+1, index2-index1+1)
                  nndata=ndata.split('},');
                  
                  for(let i=0; i<8; i++){
                    index3=nndata[i].indexOf('"foodNm":"')
                    index4=nndata[i].indexOf('"foodCost":"')
                    index5=nndata[i].indexOf('"etc"')
                    foodname=nndata[i].substr(index3+10, index4-index3-12)
                    foodcost=nndata[i].substr(index4+12, index5-index4-14)
                    console.log(foodname,foodcost)
        
                    //foodname 
                    document.querySelector('foodname'+String(i+1)).innerHTML = foodname;
                    //foodcost
                    document.querySelector('foodcost'+String(i+1)).innerHTML = foodcost+"원";
                  
                  }

                    //recommend menu
                    index3=nndata[1].indexOf('"foodNm":"')
                    index4=nndata[1].indexOf('"foodCost":"')
                    index5=nndata[1].indexOf('"etc"')
                    foodname1=nndata[1].substr(index3+10, index4-index3-12)
                    foodcost1=nndata[1].substr(index4+12, index5-index4-14)
                    document.querySelector('recommend1').innerHTML = foodname1;
                    document.querySelector('rec1').innerHTML = foodcost1+"원";

                    index3=nndata[4].indexOf('"foodNm":"')
                    index4=nndata[4].indexOf('"foodCost":"')
                    index5=nndata[4].indexOf('"etc"')
                    foodname1=nndata[4].substr(index3+10, index4-index3-12)
                    foodcost1=nndata[4].substr(index4+12, index5-index4-14)
                    document.querySelector('recommend2').innerHTML = foodname1;
                    document.querySelector('rec2').innerHTML = foodcost1+"원";

                    index3=nndata[5].indexOf('"foodNm":"')
                    index4=nndata[5].indexOf('"foodCost":"')
                    index5=nndata[5].indexOf('"etc"')
                    foodname1=nndata[5].substr(index3+10, index4-index3-12)
                    foodcost1=nndata[5].substr(index4+12, index5-index4-14)
                    document.querySelector('recommend3').innerHTML = foodname1;
                    document.querySelector('rec3').innerHTML = foodcost1+"원";

                    for(let i=1; i<9; i++)
                    document.querySelector('menu'+String(i)).innerHTML = "< "+"menu"+String(i)+" >";
                
            }
        

                )
              })
            }
              </script>
              
        <!-- Bootstrap core JS-->
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
        <!-- Core theme JS-->
        <script src="js/scripts.js"></script>
    </body>
</html>