attendance-flask-mini-app/templates/template.html

61 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var socket = io();
socket.on('connect', function() {
socket.emit('connection', {data: 'Connected to server'});
});
socket.on('initial_qr', function(msg, cb) {
$('#qrcode').prop('src', msg.data[0]);
$('#url').prop('href', msg.data[1]).text(msg.data[1]);
$('#log').empty();
msg.data[2].forEach(function(item) {
$('#log').append('<li>' + item[0] + ': ' + item[1] + '</li>');
}
);
if (cb)
cb();
});
socket.on('qr_used', function(msg, cb) {
/*
location.reload(true);
*/
$('#qrcode').prop('src', msg.data[0]).fadeTo('fast', 0.05, function(){$(this).delay(100).fadeTo('slow', 1)});
$('#url').prop('href', msg.data[1]).text(msg.data[1]);
//$('#log').fadeIn(500, function() { $(this).prepend('<li>' + msg.data[2] + ': ' + msg.data[3] + '</li>') });
var new_entry = '<li>' + msg.data[2] + ': ' + msg.data[3] + '</li>';
$(new_entry).hide().prependTo('#log').fadeIn('slow');
$('#log').fadeIn(500, function() { $(this).prepend() });
$('#log li:gt(9)' ).remove();
if (cb)
cb();
});
});
</script>
<title>Example</title>
</head>
<body>
<h1>QR Code:</h1>
{#
<p>For URL <a href="{{ request.url_root + next_uuid }}">{{ request.url_root + next_uuid }}</a></p>
<img id="qrcode" src="{{ qrcode(request.url_root + next_uuid, box_size=12, border=5) }}">
#}
<p>For URL <a id="url" href="/">__loading...__</a></p>
<img id="qrcode" src="/static/loading.gif">
<h1>Last 10 users:</h1>
<div><ul id="log"></ul></div>
{#
<ul>
{% for hit in hits %}
<li>{{ hit['created'] }}, {{ hit['user'] }}</li>
{% endfor %}
</ul>
#}
</body>
</html>