Skip to content
Snippets Groups Projects
Verified Commit 4fe3b832 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

[WIP] Implement barcode scanner for username in checkpoint

parent 3f7e20c4
No related branches found
No related tags found
1 merge request!30Resolve "Checkpoint system"
Pipeline #76046 canceled
...@@ -505,7 +505,7 @@ class PersonGroupFormPerson(forms.Form): ...@@ -505,7 +505,7 @@ class PersonGroupFormPerson(forms.Form):
class EventCheckpointForm(forms.Form): class EventCheckpointForm(forms.Form):
class Media: class Media:
js = ("js/paweljong/checkpoint.js",) js = ("https://unpkg.com/html5-qrcode", "js/paweljong/checkpoint.js")
layout = Layout( layout = Layout(
"username", "comment". "username", "comment".
......
...@@ -11,8 +11,22 @@ function setCheckpointCoords(position) { ...@@ -11,8 +11,22 @@ function setCheckpointCoords(position) {
}, 3000); }, 3000);
} }
function onScanSuccess(decodedText, decodedResult) {
$("[name='username']").val(decodedText);
if ($("[name='username']").is(":focus") && $("[name='comment']").val()) {
$("[name='username']").closest("form").submit();
}
}
function onScanFailure(error) {
alert(`Code scan error: ${error}`);
}
$(document).ready(function($) { $(document).ready(function($) {
if (navigator.geolocation) { if (navigator.geolocation) {
getCheckpointCoords(); getCheckpointCoords();
} }
var scanner = new Html5QrcodeScanner("reader", { fps: 10, qrbox: {width: 250, height: 250} }, false);
scanner.render(onScanSuccess, onScanError);
}); });
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
{% form form=form %}{% form %} {% form form=form %}{% form %}
{% include "core/partials/save_button.html" %} {% include "core/partials/save_button.html" %}
</form> </form>
<div id="reader"></div>
{{ form.media.js }} {{ form.media.js }}
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment