index.ejs 4.13 KB
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>OSSW</title>
    <link rel="stylesheet" href="../css/style.css" crossorigin="anonymous">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
        integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/css?family=Noto+Sans+KR&display=swap" rel="stylesheet">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"
    integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT"
    crossorigin="anonymous"></script>
</head>

<body>
    <nav class="navbar navbar-light bg-light" style="border-bottom: 1px solid lightgray;">
        <a class="navbar-brand" href="#" style="margin-left: 15px;">
            <img src="./image/logo.png" style="height:250px;" />
        </a>
    </nav>
    <div class="loading" style="display:none; font-size: 100px; text-align:center; margin-top: 50%;">
        <div class="loading_message">LOADING...</div>
    </div>
    <div class="first">
        <div class="main">
            <img src="./image/thermometer.jpg" class="icon">
        </div>
        <div class="sub">
            <input type="text" id="location_input" value="영통1동" autofocus="true">
            <input id="location_button" type="submit" value="입력">
        </div>
    </div>
    <div class="second" style="display: none;">
        <div class="main">
            <span class="result_icon">
                <div>최저</div>
                <div class="low temper"><%=low%>ºC</div>
            </span>
            <span class="result_icon">
                <div>평균</div>
                <div class="middle temper"><%=middle%>ºC</div>
            </span>
            <span class="result_icon">
                <div>최고</div>
                <div class="high temper"><%=high%>ºC</div>
            </span>
        </div>
        <div class="sub" style="margin: 100px 0px 100px 0px;">
            <div class="ment"><%=ment%></div>
        </div>
        <div style="text-align: center;">
            <img class="cloth cloth0" />
            <img class="cloth cloth1" />
            <img class="cloth cloth2" />
            <img class="cloth cloth3" />
            <img class="cloth cloth4" />
            <img class="cloth cloth5" />
        </div>
    </div>
        
        <script>
            $("#location_button").click(function(){
                $(".first").hide();
                $(".loading").show();
                $.ajax({
                    url: '/location',
                    async: true,
                    type: 'POST',
                    data:{
                        location: $("#location_input").val()
                    },
                    dataType: 'json',
                    success: function(data) {
                        console.log(data);
                        $.get('/data', function(data) {
                            $(".low").html(data.low + "ºC");
                            $(".middle").html(data.middle + "ºC");
                            $(".high").html(data.high + "ºC");
                            $(".ment").html(data.ment);
                            for(var i = 0; i < 6; i++){
                                $(".cloth" + i).attr("src", "image/"+ data.cloth[i]+".jpg");
                            }
                            $(".loading").hide();
                            $(".second").show();
                            $(".first").hide();
                        });
                    }
                });
            });
        </script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
            integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
            crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
            integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
            crossorigin="anonymous"></script>
        <script src = "/js/agency.js"></script>
</body>

</html>