diff --git a/static/css/main.css b/static/css/main.css index e4b96c8..8e47deb 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -260,10 +260,60 @@ button[type="submit"]:hover { margin-left: 10px; } -#error-message, #error-message-demande { +#error-message, #error-message-demande, #error-message-register { color: red; } +.treasure { + padding: 5px; +} + +.treasure-submitted { + color: rgba(254, 181, 35, 0.471) +} + +.treasure-accepted { + background-color: rgba(0, 255, 0, 0.46); +} + +.overlay { + z-index: 99; + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + background: rgba(0, 0, 0, 0.7); + transition: opacity 500ms; + opacity: 0; + visibility: hidden; + } + +#treasure-popup { + margin: 70px auto; + padding: 20px; + background: #fff; + border-radius: 5px; + width: calc(100% - 10vw); + position: relative; + transition: all 5s ease-in-out; +} + +.close { + position: absolute; + top: 20px; + right: 30px; + transition: all 200ms; + font-size: 30px; + font-weight: bold; + text-decoration: none; + color: #333; +} +.close:hover { + color: #d75b00; + text-decoration: none; +} + @media screen and (max-width: 800px) { .bg-full { display: none; diff --git a/static/index.html b/static/index.html index a76c561..e0b5e42 100644 --- a/static/index.html +++ b/static/index.html @@ -153,7 +153,7 @@
- +
+
+ +
+
+ +
+
+ + + diff --git a/static/js/main.js b/static/js/main.js index b7a3b2f..94cd9bf 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -85,7 +85,7 @@ $("#register-button").click(function (e) { }); if( $("#register-password-confirm").val() != $("#register-password").val()) { t = new TypeIt('#error-message-register', { - speed: 110, + speed: 100, lifeLike: true }) .type("Oups, les 2 mots de passe ne correspondent pas !") @@ -598,8 +598,17 @@ function refreshListener() { }); }); + $(".treasure-btn-submit").click((e) => { + let uid = e.target.parentNode.parentNode.id; + + $('.overlay').css({"opacity": 1, "visibility": "visible"}); + }); } +$('.close').click((e) => { + $('.overlay').css({"opacity": 0, "visibility": "hidden"}); +}); + $('#demande-button').click(function () { $.ajax({ type: "POST", @@ -688,12 +697,85 @@ function updateDemandes() { if (data.why == "Not authentificated") { show_page('#login-page'); } else { - alert(data.why); + console.alert(data.why); } } } }); + $.ajax({ + type: "POST", + url: base_url + "get", + data: JSON.stringify({ + uid: localStorage.getItem('user'), + token: localStorage.getItem('token'), + type: "activity" + + }), + contentType: "application/json; charset=utf-8", + dataType: "json", + + success: function (data) { + if(data.success) { + $('#treasure-list').html(''); + + let ad = data.activityData; + + for(const ad_uid in ad) { + if(ad[ad_uid].type == "treasure") { + $('#treasure-list').append(` + +

${ad[ad_uid].title}

+
Indice: ${ad[ad_uid].desc}
+
Statue: ${ad[ad_uid].treasureState}
+ ${ (ad[ad_uid].treasureState != "Accepted" && ad[ad_uid].treasureState != "Refused" ) ? + ` +
Soumettre sa résolution
+
` + : '' + } +
+ `) + } + } + refreshListener(); + } + else { + console.alert(data.why); + } + } + }); + $.ajax({ + type: "POST", + url: base_url + "get", + data: JSON.stringify({ + uid: localStorage.getItem('user'), + token: localStorage.getItem('token'), + type: "treasure" + + }), + contentType: "application/json; charset=utf-8", + dataType: "json", + + success: function (data) { + if(data.success) { + let td = data.treasureData; + + for(const td_uid in td) { + $elem = $('#' + td_uid); + $elem.addClass('treasure-submitted'); + $elem.children(".treasure-button-submit").text('Editer la soumission'); + $elem.children('.treasure-desc').insertAfter(`
Image: Lien
`) + + } + refreshListener(); + } + else { + console.alert(data.why); + } + } + + }); } } @@ -739,7 +821,7 @@ function updateNextActivity() { 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', { + $('#timer').text((days == 0 ? "" : days + " jours ") + (new Date('December 17, 1995 ' + [h, m, s].join(':'))).toLocaleTimeString('default', { hour: '2-digit', minute: '2-digit', second: '2-digit' @@ -764,8 +846,13 @@ $(window).on("load", function() { /* load timer */ window.setInterval(function() { var b = $("#timer").text().split(' jours '); - var time = b[1]; - var days = b[0]; + if(b.length == 2) { + var time = b[1]; + var days = b[0]; + } else { + var time = b[0]; + var days = 0; + } var t = time.split(":").map(t => parseInt(t)); t[2] -= 1;