VersiĆ³ funcional al localhost
diff --git a/js/confirmation.js b/js/confirmation.js
new file mode 100644
index 0000000..9f74bfb
--- /dev/null
+++ b/js/confirmation.js
@@ -0,0 +1,18 @@
+if (mort) {
+ // User is dead
+ document.write("Venga niño, pitjor que el Condom, MORT.");
+} else {
+ let dead = false;
+ let killed = false;
+
+ if (requested != 0) {
+ // Check for requests
+ if(requested == 1) dead = confirm("El teu assassí ha dit que t'ha matat, és veritat?");
+ if(requested == 2) killed = confirm("En/na " + victimnom + " ha dit que l'has matat, és veritat?");
+
+ // Confirm/deny request
+ if (dead) send_request(userid, 3); // confirm death
+ else if (killed) send_request(victimid, 3); // confirm kill
+ else send_request(userid, 4); // deny kill/death
+ }
+}
diff --git a/js/utils.js b/js/utils.js
index 92185d7..c0d538a 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -6,12 +6,21 @@
};
function send_request(id, msg) {
+ console.log(id, msg);
+
$.ajax({
- 'url': '../php/request.php',
+ 'url': './php/request.php',
'type': 'GET',
- 'dataType': 'json',
+ 'contentType': 'application/json; charset=utf-8',
'data': { 'id': id, 'msg': msg },
- 'success': function(data) { console.log('Success'); },
- 'error': function(xhr, status, error) { alert('Error! Torna-ho a intentar o contacta amb l\'Andreu: +34681236024'); console.log(xhr); }
+ 'success': function(data) {
+ console.log('Success');
+ if (msg <= 2) $.notify('Confirmació enviada', 'success');
+ else $.notify('Resposta guardada', 'success');
+ },
+ 'error': function(xhr, status, error) {
+ console.log('Error! Torna-ho a intentar o contacta amb l\'Andreu: +34681236024');
+ console.log(xhr.responseText);
+ }
});
}