{#{% extends 'quiz/in_room.html' %}#}
{#{% block content %}#}
{#    <div id="display">#}
{##}
{#    </div>#}
{##}
{#    <script>#}
{#        $(document).ready(function () {#}
{##}
{#            setInterval(function () {#}
{#                $.ajax({#}
{#                    type: 'GET',#}
                    {#url: "/getMessages/{{room.room_id}}/",#}
{#                    url: "/getMessages/{{room.id}}/",#}
{#                    success: function (response) {#}
{#                        console.log(response);#}
{#                        $("#display").empty();#}
{#                        for (var key in response.messages) {#}
{#                            var temp = "<div class='container darker'><b>" + response.messages[key].user + "</b> : " + response.messages[key].value + "</div>";#}
                            {#"<span class='time-left'>" + response.messages[key].date + "</span></div>";#}
{#                            $("#display").append(temp);#}
{#                        }#}
{#                    },#}
{#                    error: function (response) {#}
{#                        alert('오류 발생')#}
{#                    }#}
{#                });#}
{#            }, 1000);#}
{#        })#}
{#    </script>#}
{##}
{##}
{#    <div class="container">#}
{#        <form id="post-form">#}
{#            {% csrf_token %}#}
{#            <input type="hidden" name="username" id="username" value="{{ username }}"/>#}
{#            <input type="hidden" name="room_id" id="room_id" value="{{ room_details.id }}"/>#}
{#            <input type="text" name="message" id="message" width="100px"/>#}
{#            <input type="submit" value="Send">#}
{#        </form>#}
{#    </div>#}
{##}
{#    <script type="text/javascript">#}
{#        $(document).on('submit', '#post-form', function (e) {#}
{#            e.preventDefault();#}
{##}
{#            $.ajax({#}
{#                type: 'POST',#}
{#                url: '/send',#}
{#                data: {#}
{#                    username: $('#username').val(),#}
{#                    room_id: $('#room_id').val(),#}
{#                    message: $('#message').val(),#}
{#                    csrfmiddlewaretoken: $('input[name=csrfmiddlewaretoken]').val(),#}
{#                },#}
{#                success: function (data) {#}
{#                    //alert(data)#}
{#                }#}
{#            });#}
{#            document.getElementById('message').value = ''#}
{#        });#}
{#    </script>#}
{#{% endblock %}#}