-
-
+
+
+
Demandes
+
Ici vous pouvez demandez à un espion aguerri de faire une mission pour vous comme commander des crêpes. Aussi, vous pouvez tentez de valider la chasse au trésor du jour !
+ Pour cela il suffit d'envoyer une photo du ticket avec l'endroit où vous l'avez trouvé.
+
+
+
+
+
+
+
+
Chasse au trésor
+
+
+
+
+
Vos demandes en cours
+
diff --git a/static/js/main.js b/static/js/main.js
index 4e34ab8..c8a5b34 100644
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -514,6 +514,85 @@ function refreshListener() {
})
}
+$('#demande-button').click(function () {
+
+ $.ajax({
+ type: "POST",
+ url: base_url + "addPrank",
+ data: JSON.stringify({
+ uid: localStorage.getItem('user'),
+ token: localStorage.getItem('token'),
+ type: "crêpe",
+ amount: $('#demande-amount').val(),
+ where: $('#demande-where').val(),
+ supplement: $('#demande-supplement').val(),
+ note: $('#demande-note').val()
+ }),
+ contentType: "application/json; charset=utf-8",
+ dataType: "json",
+
+ success: function(data) {
+ if(data.success) {
+ $('#demande-form input').val("");
+ } else {
+ alert(data.why);
+ }
+ }
+ });
+});
+
+function updateNextActivity() {
+ $.ajax({
+ type: "POST",
+ url: base_url + "get",
+ data: JSON.stringify({
+ token: "",
+ uid: "",
+ type: "activity",
+ }),
+ contentType: "application/json; charset=utf-8",
+ dataType: "json",
+ success: (data) => {
+ if(data.success) {
+ let curr_date = new Date();
+ let ad = data.activityData;
+ var candidate = [];
+ var next_acti = {title: "Pas encore d'activité", desc: "Encore aucune activité n'a été renseigné, faite le vite !"};
+ for(const uid in ad) {
+ if(ad[uid].type == "event" && curr_date < new Date( ad[uid].start )) {
+ candidate.push(ad[uid]);
+ }
+ }
+
+ next_acti = candidate.reduce(function(prev, curr) {
+ return new Date(prev.start) < new Date(curr.Cost) ? prev : curr;
+ });
+
+ var opt = {speed: 100};
+ new TypeIt("#activite-title", opt)
+ .type(next_acti.title)
+ .go();
+ new TypeIt("#activite-desc", opt)
+ .type(next_acti.desc)
+ .go();
+ new TypeIt("#activite-place", opt)
+ .type("Lieu : " + next_acti.where)
+ .go();
+ let diff = Math.ceil( (new Date(next_acti.start) - new Date()) / 1000 )
+ let days = Math.trunc(diff / (3600*24) )
+ let h = Math.trunc(diff / 3600) - days*24
+ let m = Math.trunc(diff / 60) - (h + days*24)*60
+ let s = diff - h*3600 - m*60 - days*24*3600
+ $('#timer').text(days + " jours " + (new Date('December 17, 1995 ' + [h, m, s].join(':'))).toLocaleTimeString('default', {
+ hour: '2-digit',
+ minute: '2-digit',
+ second: '2-digit'
+ }));
+ }
+ }
+ })
+}
+
$(window).on("load", function() {
/* Register the Service Worker */
if ('serviceWorker' in navigator) {
@@ -524,37 +603,15 @@ $(window).on("load", function() {
$(page[i]).css('z-index', page.length - i);
}
- $.ajax({
- type: "GET",
- url: base_url + "lastActivity",
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: (data) => {
- if(data.success) {
- opt = {speed: 100, likeLike: true};
- new TypeIt("#activite-title", opt)
- .type(data.activity.title)
- .go();
- new TypeIt("#activite-desc", opt)
- .type(data.activity.desc)
- .go();
- let diff = Math.ceil( (data.activity.start - new Date()) / 1000 )
- let h = Math.round(diff / 3600)
- let m = Math.round(diff / 60) - h*60
- let s = diff - m*60
- $("#timer").text((new Date('December 17, 1995 ' + [h, m, s].join(':'))).toLocaleTimeString('default', {
- hour: '2-digit',
- minute: '2-digit',
- second: '2-digit'
- }));
- }
- }
- })
+ updateNextActivity();
/* load timer */
window.setInterval(function() {
- var time = $("#timer").text();
+ var b = $("#timer").text().split(' jours ');
+ var time = b[1];
+ var days = b[0];
var t = time.split(":").map(t => parseInt(t));
+
t[2] -= 1;
if (t[2] < 0) {
t[2] = 59;
@@ -565,11 +622,19 @@ $(window).on("load", function() {
t[0] -= 1;
}
if (t[0] < 0) {
+ t[0] = 23;
+ t[1] = 59;
+ t[2] = 59;
+ days -= 1;
+ }
+ if (days < 0) {
t[0] = 0;
t[1] = 0;
t[2] = 0;
+ days = 0;
+ updateNextActivity();
}
- $('#timer').text((new Date('December 17, 1995 ' + t.join(':'))).toLocaleTimeString('default', {
+ $('#timer').text(days + " jours " +(new Date('December 17, 1995 ' + t.join(':'))).toLocaleTimeString('default', {
hour: '2-digit',
minute: '2-digit',
second: '2-digit'