VersiĆ³ funcional al localhost
diff --git a/index.php b/index.php
index 9f363ab..9c018c3 100644
--- a/index.php
+++ b/index.php
@@ -24,6 +24,7 @@
<script>
$.post("./php/getusers.php", function(data, status){
$("#list").html(data);
+ console.log(data);
});
</script>
</body>
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);
+ }
});
}
diff --git a/main.php b/main.php
index 31b4ae7..4d34a59 100644
--- a/main.php
+++ b/main.php
@@ -6,28 +6,20 @@
<link rel="stylesheet" href="./css/main.css" />
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
+ <script src="https://rawgit.com/notifyjs/notifyjs/master/dist/notify.js"></script>
<script src="./js/utils.js"></script>
- <?php require './php/login.php'; ?>
+ <? require './php/login.php'; ?>
+
<script>
- if (<?=$user->mort?>) {
- // User is dead
- document.write("Venga niño, pitjor que el Condom, MORT.");
- } else {
- let dead = false;
- let killed = false;
-
- // Check for requests
- if(<?=$user->requested?> == 1) dead = confirm("El teu assassí ha dit que t'ha matat, és veritat?");
- if(<?=$user->requested?> == 2) killed = confirm("En/na <?=$victim->nom()?> ha dit que l'has matat, és veritat?");
-
- // Confirm/deny request
- if (dead) send_request(<?=$user->id?>, 3); // confirm death
- else send_request(<?=$user->id?>, 4); // deny death
- if (killed) send_request(<?=$victim->id?>, 3); // confirm kill
- else send_request(<?=$user->id?>, 4); // deny kill
- }
+ let mort = <?=$user->mort?>;
+ let requested = <?=$user->requested?>;
+ let userid = <?=$user->id?>;
+ let victimid = <?=$victim->id?>;
+ let victimnom = "<?=$victim->nom()?>";
</script>
+
+ <script src="./js/confirmation.js"></script>
</head>
<body>
<div id="outter-container">
diff --git a/php/getusers.php b/php/getusers.php
index f3f79e9..b23c8c0 100644
--- a/php/getusers.php
+++ b/php/getusers.php
@@ -1,11 +1,11 @@
<?php
// Define MySQL login variables
- $servername = "fdb22.awardspace.net";
- $username = "3155560_users";
- $password = "btechnoro@fox4news.info";
+ $servername = "localhost"; // "fdb22.awardspace.net";
+ $username = "root"; // "3155560_users";
+ $password = ""; // "btechnoro@fox4news.info";
// Create connection
- $conn = new mysqli($servername, $username, $password, "3155560_users");
+ $conn = new mysqli($servername, $username, $password, "pastanaga");
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
$conn->set_charset("utf8");
diff --git a/php/login.php b/php/login.php
index ee64f27..286919f 100644
--- a/php/login.php
+++ b/php/login.php
@@ -16,12 +16,12 @@
$user = new User();
// Define MySQL login variables
- $servername = "fdb22.awardspace.net";
- $username = "3155560_users";
- $password = "btechnoro@fox4news.info";
+ $servername = "localhost"; // "fdb22.awardspace.net";
+ $username = "root"; // "3155560_users";
+ $password = ""; // "btechnoro@fox4news.info";
// Create connection
- $conn = new mysqli($servername, $username, $password, "3155560_users");
+ $conn = new mysqli($servername, $username, $password, "pastanaga");
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
$conn->set_charset("utf8");
diff --git a/php/request.php b/php/request.php
index cc16327..3ff9b5a 100644
--- a/php/request.php
+++ b/php/request.php
@@ -1,11 +1,11 @@
<?php
// Define MySQL login variables
- $servername = "fdb22.awardspace.net";
- $username = "3155560_users";
- $password = "btechnoro@fox4news.info";
+ $servername = "localhost"; // "fdb22.awardspace.net";
+ $username = "root"; // "3155560_users";
+ $password = ""; // "btechnoro@fox4news.info";
// Create connection
- $conn = new mysqli($servername, $username, $password, "3155560_users");
+ $conn = new mysqli($servername, $username, $password, "pastanaga");
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
$conn->set_charset("utf8");