Much better progress tracker in voting booth #9
This commit is contained in:
parent
7bbffb47af
commit
4ebdd8450c
@ -19,6 +19,7 @@
|
||||
"semantic": "semantic-ui#^2.2.13",
|
||||
"nunjucks": "^3.0.1",
|
||||
"dragula.js": "dragula#^3.7.2",
|
||||
"fingerprintjs2": "^1.5.1"
|
||||
"fingerprintjs2": "^1.5.1",
|
||||
"progress-tracker": "^1.4.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{#
|
||||
Eos - Verifiable elections
|
||||
Copyright © 2017 RunasSudo (Yingtong Li)
|
||||
Copyright © 2017-18 RunasSudo (Yingtong Li)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
@ -23,7 +23,7 @@
|
||||
{# Convert the template name to a numerical index for comparison #}
|
||||
{% if template == 'booth/welcome.html' %}
|
||||
{% set menuindex = 1 %}
|
||||
{% elif template == 'booth/selections.html' %}
|
||||
{% elif template == 'booth/selections.html' or template == 'booth/encrypt.html' %}
|
||||
{% set menuindex = 2 %}
|
||||
{% elif template == 'booth/review.html' %}
|
||||
{% set menuindex = 3 %}
|
||||
@ -35,14 +35,23 @@
|
||||
{% set menuindex = 6 %}
|
||||
{% endif %}
|
||||
|
||||
<div class="ui secondary pointing menu" id="election-tab-menu">
|
||||
{# oh dear god #}
|
||||
<span class="ui{% if menuindex >= 1 %} active{% endif %} item"{% if menuindex != 1 %} style="color: #767676;{% if menuindex > 1 %} font-weight: 400;{% endif %}"{% endif %}>1. Welcome</span>
|
||||
<span class="ui{% if menuindex >= 2 %} active{% endif %} item"{% if menuindex != 2 %} style="color: #767676;{% if menuindex > 2 %} font-weight: 400;{% endif %}"{% endif %}>2. Make selections</span>
|
||||
<span class="ui{% if menuindex >= 3 %} active{% endif %} item"{% if menuindex != 3 %} style="color: #767676;{% if menuindex > 3 %} font-weight: 400;{% endif %}"{% endif %}>3. Review selections</span>
|
||||
<span class="ui{% if menuindex >= 4 %} active{% endif %} item"{% if menuindex != 4 %} style="color: #767676;{% if menuindex > 4 %} font-weight: 400;{% endif %}"{% endif %}>4. Audit ballot</span>
|
||||
<span class="ui{% if menuindex >= 5 %} active{% endif %} item"{% if menuindex != 5 %} style="color: #767676;{% if menuindex > 5 %} font-weight: 400;{% endif %}"{% endif %}>5. Cast ballot</span>
|
||||
</div>
|
||||
{% macro menuitem(index, text) %}
|
||||
<li class="progress-step{% if menuindex > index %} is-complete{% elif menuindex == index %} is-active{% endif %}">
|
||||
<span class="progress-marker">{% if menuindex > index or menuindex == 6 %}<span style="font-family: Icons;"></span>{% else %}{{ index }}{% endif %}</span>
|
||||
<span class="progress-text">
|
||||
{{ text }}
|
||||
</span>
|
||||
</li>
|
||||
{% endmacro %}
|
||||
|
||||
<ul class="progress-tracker progress-tracker--word progress-tracker--word-center" id="election-tab-menu" style="margin-bottom: 20px;">
|
||||
{{ menuitem(1, "Welcome") }}
|
||||
{{ menuitem(2, "Select") }}
|
||||
{{ menuitem(3, "Review") }}
|
||||
{{ menuitem(4, "Audit") }}
|
||||
{{ menuitem(5, "Cast") }}
|
||||
{{ menuitem(6, "Finish") }}
|
||||
</ul>
|
||||
|
||||
<div class="ui container">
|
||||
{% block content %}{% endblock %}
|
||||
|
@ -1,6 +1,8 @@
|
||||
{% extends templates['booth/base.html'] %}
|
||||
|
||||
{#
|
||||
Eos - Verifiable elections
|
||||
Copyright © 2017 RunasSudo (Yingtong Li)
|
||||
Copyright © 2017-18 RunasSudo (Yingtong Li)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
@ -16,62 +18,68 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
|
||||
<div class="ui active text loader">Preparing your ballot. Please wait.</div>
|
||||
{% block content %}
|
||||
<div class="ui basic segment" style="min-height: 4em;">
|
||||
<div class="ui active text loader">Preparing your ballot. Please wait.</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
<script>
|
||||
boothWorker.onmessage = function(msg) {
|
||||
try {
|
||||
rawAnswers = [];
|
||||
for (var answer_json of booth.answers) {
|
||||
rawAnswers.push(eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(answer_json, null));
|
||||
}
|
||||
{% block after %}
|
||||
<script>
|
||||
boothWorker.onmessage = function(msg) {
|
||||
try {
|
||||
rawAnswers = [];
|
||||
for (var answer_json of booth.answers) {
|
||||
rawAnswers.push(eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(answer_json, null));
|
||||
}
|
||||
|
||||
encryptedAnswers = [];
|
||||
for (var encrypted_answer_json of msg.data.encrypted_answers) {
|
||||
encryptedAnswers.push(eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(encrypted_answer_json, null));
|
||||
}
|
||||
encryptedAnswers = [];
|
||||
for (var encrypted_answer_json of msg.data.encrypted_answers) {
|
||||
encryptedAnswers.push(eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(encrypted_answer_json, null));
|
||||
}
|
||||
|
||||
booth.ballot = eosjs.eos.base.election.__all__.Ballot();
|
||||
booth.ballot.answers = rawAnswers;
|
||||
booth.ballot.encrypted_answers = encryptedAnswers;
|
||||
booth.ballot.election_id = election._id;
|
||||
booth.ballot.election_hash = eosjs.eos.core.hashing.__all__.SHA256().update_obj(election).hash_as_b64();
|
||||
booth.ballot = eosjs.eos.base.election.__all__.Ballot();
|
||||
booth.ballot.answers = rawAnswers;
|
||||
booth.ballot.encrypted_answers = encryptedAnswers;
|
||||
booth.ballot.election_id = election._id;
|
||||
booth.ballot.election_hash = eosjs.eos.core.hashing.__all__.SHA256().update_obj(election).hash_as_b64();
|
||||
|
||||
if (should_do_fingerprint) {
|
||||
// String.prototype.join confuses fingerprintjs2
|
||||
var strjoin = String.prototype.join;
|
||||
String.prototype.join = undefined;
|
||||
try {
|
||||
new Fingerprint2().get(function(result, components) {
|
||||
String.prototype.join = strjoin;
|
||||
booth.fingerprint = components;
|
||||
if (should_do_fingerprint) {
|
||||
// String.prototype.join confuses fingerprintjs2
|
||||
var strjoin = String.prototype.join;
|
||||
String.prototype.join = undefined;
|
||||
try {
|
||||
new Fingerprint2().get(function(result, components) {
|
||||
String.prototype.join = strjoin;
|
||||
booth.fingerprint = components;
|
||||
nextTemplate();
|
||||
});
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
nextTemplate();
|
||||
});
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
}
|
||||
} else {
|
||||
nextTemplate();
|
||||
}
|
||||
} else {
|
||||
nextTemplate();
|
||||
} catch (err) {
|
||||
boothError(err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
boothWorker.onerror = function(err) {
|
||||
boothError(err);
|
||||
throw err;
|
||||
}
|
||||
try {
|
||||
boothWorker.postMessage({
|
||||
"action": "generateEncryptedVote",
|
||||
"static_base_url": "{{ static_base_url }}",
|
||||
"election": eosjs.eos.core.objects.__all__.EosObject.serialise_and_wrap(election, null),
|
||||
"answers": booth.answers
|
||||
});
|
||||
} catch (err) {
|
||||
boothError(err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
boothWorker.onerror = function(err) {
|
||||
boothError(err);
|
||||
throw err;
|
||||
}
|
||||
try {
|
||||
boothWorker.postMessage({
|
||||
"action": "generateEncryptedVote",
|
||||
"static_base_url": "{{ static_base_url }}",
|
||||
"election": eosjs.eos.core.objects.__all__.EosObject.serialise_and_wrap(election, null),
|
||||
"answers": booth.answers
|
||||
});
|
||||
} catch (err) {
|
||||
boothError(err);
|
||||
throw err;
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{#
|
||||
Eos - Verifiable elections
|
||||
Copyright © 2017 RunasSudo (Yingtong Li)
|
||||
Copyright © 2017-18 RunasSudo (Yingtong Li)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
@ -23,6 +23,7 @@
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='bower_components/dragula.js/dist/dragula.min.css') }}" type="text/css">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='bower_components/progress-tracker/app/styles/progress-tracker.css') }}" type="text/css">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
Loading…
Reference in New Issue
Block a user