|
@@ -1,6 +1,11 @@
|
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
|
|
pageEncoding="UTF-8"%>
|
|
|
<%@ taglib prefix="tag" tagdir="/WEB-INF/tags" %>
|
|
|
+<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
|
|
+<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
|
|
+<c:set var="req" value="${pageContext.request}" />
|
|
|
+<c:set var="url">${req.requestURL}</c:set>
|
|
|
+<c:set var="base" value="${fn:substring(url, 0, fn:length(url) - fn:length(req.requestURI))}${req.contextPath}/" />
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
<html>
|
|
@@ -45,11 +50,6 @@
|
|
|
<video id="qr-preview"></video>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="row">
|
|
|
- <div class="col s12 center-align">
|
|
|
- <p id="result"></p>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
</main>
|
|
|
|
|
|
<!-- Popup -->
|
|
@@ -60,7 +60,7 @@
|
|
|
<i class="material-icons green-text" style="font-size: 8em;">check_circle</i>
|
|
|
</div>
|
|
|
<div class="col m7 s12 mtop-3">
|
|
|
- <h4>Votre code a bien été scanné</h4>
|
|
|
+ <h4 id="ok-text">Success message</h4>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -92,18 +92,39 @@
|
|
|
const errPopup = M.Modal.getInstance($('#err-popup'));
|
|
|
const loader = M.Modal.getInstance($('#loader'));
|
|
|
|
|
|
+
|
|
|
// Lecteur cookie espace
|
|
|
const espace = getCookie("microfolies.lens.espace");
|
|
|
- // Changement nom titre
|
|
|
- if (espace !== undefined) {
|
|
|
- $('#title').html(espace.capitalize());
|
|
|
+ // Si pas de cookie retour sur la page d'accueil
|
|
|
+ if (espace === undefined) {
|
|
|
+ window.location.href = "${base}";
|
|
|
}
|
|
|
+ // Changement nom titre
|
|
|
+ $('#title').html(espace.capitalize());
|
|
|
//Scanner QRcode
|
|
|
const scanner = new Instascan.Scanner({ video: document.getElementById('qr-preview') });
|
|
|
scanner.addListener('scan', function (content) {
|
|
|
- const result = espace ? content + "/" + espace : content;
|
|
|
- $('#result').html(result);
|
|
|
- okPopup.open();
|
|
|
+ loader.open();
|
|
|
+ const result = espace ? espace + "/" + content : content;
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ url: "${base}api/badge/" + result,
|
|
|
+ error: () => {
|
|
|
+ $("#error-text").html('Une erreur est survenue');
|
|
|
+ loader.close();
|
|
|
+ errPopup.open();
|
|
|
+ },
|
|
|
+ success: (result) => {
|
|
|
+ loader.close();
|
|
|
+ if (result.success) {
|
|
|
+ $("#ok-text").html(result.data.msg);
|
|
|
+ okPopup.open();
|
|
|
+ } else {
|
|
|
+ $("#error-text").html(result.data);
|
|
|
+ errPopup.open();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
});
|
|
|
Instascan.Camera.getCameras().then(function (cameras) {
|
|
|
if (cameras.length > 0) {
|