Sistema de Apoio ao Processo Legislativo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

236 lines
8.4 KiB

{% load i18n %}
{% load common_tags %}
{% load render_bundle from webpack_loader %}
{% load webpack_static from webpack_loader %}
<!DOCTYPE HTML>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>{% block head_title %}{% trans 'SAPL - Sistema de Apoio ao Processo Legislativo' %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% render_chunk_vendors 'css' %}
{% render_bundle 'global' 'css' %}
{% render_bundle 'painel' 'css' %}
<style type="text/css">
html, body {
max-width: 100%;
overflow-x: hidden;
}
@media screen {
body {
background: #1c1b1b;
}
ul, li {
list-style-type: none;
}
#date, #relogio, #resultado_votacao, #blocoprincipal, #blocoerro {
font-family: Verdana;
}
#votos
{
text-align:center;
}
#votosim, #votonao, #votoabstencao
{
display:inline;
}
#voltar {
margin-left: 5rem;
}
}
</style>
</head>
<body>
{% if not error_message %}
<div id="blocoprincipal" style="display:block">
<h1><b><font color="#4FA64D"><p align="center">{{sessao}}</p></font></b></h1>
<table style="width:90%">
<tr>
<td style="text-align:center"><font color="white" size="4">Data Início: {{data}}</font></td>
<td style="text-align:center"><font color="white" size="4">Hora Início: {{hora}}</font></td>
</tr>
<tr>
<td style="text-align:center"><font color="white" size="6"><span id="date"></span></font></td>
<td style="text-align:center"><font color="white" size="6"><span id="relogio"></span></font></td>
</tr>
</table>
</br>
</br>
<h2>
<font color="white">
<p align="center" style="font-family:Verdana">Voto:
{% if voto_parlamentar == "Sim" %}
<font color="#449d44">{{voto_parlamentar}}</font>
{% elif voto_parlamentar == "Não" %}
<font color="#d9534f">{{voto_parlamentar}}</font>
{% elif voto_parlamentar == "Abstenção" %}
<font color="#eaeaea">{{voto_parlamentar}}</font>
{% endif %}
</p>
</font>
</h2>
{% if status_message %}
<p align="center" style="font-family:Verdana">
<font color="#8fbfe0">{{status_message}}</font>
</p>
{% endif %}
</br>
</br>
<h2><font color="#459170"><p align="center" style="font-family:Verdana">Matéria em Votação</p></font></h2>
<table style="width:75%; border:1px;" align="center">
<tr><th style="text-align:center"><h4><font color="white" size="5">{{materia}}</font></h4></th></tr>
<tr><th style="text-align:center"><h4><font color="white">{{ementa}}</font></h4></th></tr>
<tr><th style="text-align:center"><font color="#45919D"><span id="resultado_votacao"></span></font></th></tr>
</table>
<br /><br />
<form method='POST'>
{% csrf_token %}
<div class="row" align="center">
<div class="col-md-12" id="votos">
<div id="votosim"><input type="submit" class="btn btn-lg btn-success" id="voto" name="voto" type="submit" value="Sim" /></div>
&nbsp;
<div id="votonao"><input type="submit" class="btn btn-lg btn-danger" id="voto" name="voto" type="submit" value="Não"/></div>
&nbsp;
<div id="votoabstencao"><input type="submit" class="btn btn-lg btn-secondary" id="voto" name="voto" type="submit" value="Abstenção"/></div>
</div>
</div>
</br>
</br>
<center><table style="width:30%">
<tr>
<td style="text-align:center"><button type="button" class="btn btn-lg btn-primary" onclick="javascript:window.location.reload(true)">Atualizar</button></td>
<td style="text-align:center"><button type="button" class="btn btn-lg btn-secondary" onclick="javascript:window.close()">Sair</button></td>
</tr>
</table></center>
</form>
</div>
{% else %}
<div id="blocoerro" style="display:block">
<h1><font color="#eaeaea"><p align="center" style="font-family:Verdana"></p></font></h1>
<h2><font color="#f0ad4e"><p align="center" style="font-family:Verdana">{{error_message}}</p></font></h2>
</br>
</br>
</br>
<center><table style="width:30%">
<tr>
<td style="text-align:center"><button type="button" class="btn btn-lg btn-primary" onclick="javascript:window.location.reload(true)">Atualizar</button></td>
<td style="text-align:center"><button type="button" class="btn btn-lg btn-secondary" onclick="javascript:window.close()">Sair</button></td>
</tr>
</table></center>
</div>
{% endif %}
</body>
</html>
{% if not error_message %}
{% render_chunk_vendors 'js' %}
{% render_bundle 'global' 'js' %}
{% render_bundle 'painel' 'js' %}
<script type="text/javascript">
$(window).on('beforeunload', function () {
$("input[type=submit], input[type=button]").prop("disabled", "disabled");
});
//TODO: Este código é necessário?
// $( "#votosim" ).mouseleave(function(){document.location.reload(true);});
// $( "#votonao" ).mouseleave(function(){document.location.reload(true);});
// $( "#votoabstencao" ).mouseleave(function(){document.location.reload(true);});
$(document).on('keyup', (e) => {
var tecla_press = e.keyCode;
switch (tecla_press) {
case 83: // 83 = valor da tecla S
document.querySelectorAll("#votosim input")[0].click();
break;
case 78: //78 = valor da tecla N
document.querySelectorAll("#votonao input")[0].click();
break;
case 65: //65 = valor da tecla A
document.querySelectorAll("#votoabstencao input")[0].click();
break;
case 86: //86 = valor da tecla V
document.querySelectorAll("#voltar button")[0].click();
break;
};
});
function checkTime(i) {
if (i<10)
i = "0" + i; // add zero in front of numbers < 10
return i;
}
function startTime() {
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
m = checkTime(m);
s = checkTime(s);
$("#relogio").text(h+":"+m+":"+s)
var t = setTimeout(() => startTime(), 500);
}
$(document).ready(function(){
var d = new Date();
var n = d.toLocaleDateString();
$("#date").text(n);
startTime();
});
</script>
{% endif %}
<script type="text/javascript">
// Substitui o antigo reload automático de página inteira a cada 30s por
// um poll leve (fetch simples, sem depender do jQuery/bundle carregado
// condicionalmente acima) que só recarrega a página quando o estado
// realmente muda — economiza o custo de renderizar a página inteira a
// cada poll em cada um dos tablets. Roda nas duas telas (voto e erro),
// já que "aguardando abertura de matéria" também precisa se recuperar
// sozinho quando o estado mudar.
(function() {
var estadoAtual = {
materiaId: "{% if materia %}{{ materia.id }}{% endif %}",
errorMessage: "{{ error_message|default:''|escapejs }}",
statusMessage: "{{ status_message|default:''|escapejs }}",
votoParlamentar: "{{ voto_parlamentar|default:''|escapejs }}"
};
function verificaEstado() {
fetch("{% url 'sapl.painel:voto_individual_status' %}", {credentials: 'same-origin'})
.then(function(resp) { return resp.json(); })
.then(function(data) {
var novo = {
materiaId: data.materia_id ? String(data.materia_id) : "",
errorMessage: data.error_message || "",
statusMessage: data.status_message || "",
votoParlamentar: data.voto_parlamentar || ""
};
if (novo.materiaId !== estadoAtual.materiaId ||
novo.errorMessage !== estadoAtual.errorMessage ||
novo.statusMessage !== estadoAtual.statusMessage ||
novo.votoParlamentar !== estadoAtual.votoParlamentar) {
document.location.reload();
}
})
.catch(function() { /* tenta de novo no próximo poll */ });
}
setInterval(verificaEstado, 5000);
})();
</script>