{% extends "base.html" %}
{#% load endless %#}
{% load static %}

{% block head %}

<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>

<!-- Load js for initializing tables via their server-side options -->
<script type="text/javascript" charset="utf8" src="{% static 'js/datatableview.js' %}"></script>
<script type="text/javascript">
    datatableview.auto_initialize = false;
    $(function(){

        var xeditable_options = {};
        datatableview.initialize($('.datatable'), {
            fnRowCallback: datatableview.make_xeditable(xeditable_options),
        });

        $('#btn-download').on('click', function() {
            var $this = $(this);
            var loadingText = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>  Loading...';
            if ($(this).html() !== loadingText) {
            $this.data('original-text', $(this).html());
            $this.html(loadingText);
            }
            setTimeout(function() {
            $this.html($this.data('original-text'));
            }, 20000);
        });
    });  


</script>
{% endblock %}


{% block content %}
    <h2>List treatments</h2>
    <div class="d-flex">
        <div class="ml-auto p-2">
            <form class="form-inline">
                <button id="btn-download" name="download" type="submit" class="btn btn-primary btn-sm d-flex"><span class="material-icons">download</span>報到機</button>
            </form>
        </div>
    </div>
      
    {{ datatable }}


{% endblock %}

