Applied restruturation with the AJAX code
diff --git a/admin/insert.php b/admin/insert.php
new file mode 100644
index 0000000..8cb6f2a
--- /dev/null
+++ b/admin/insert.php
@@ -0,0 +1,24 @@
+<?php
+ require '../credentials.php';
+ require '../php/utils.php';
+
+ $inscrits = [
+ ['Joan Hernanz Segarra', 3, 1],
+ ['Olga Almudena Martínez', 1, 1],
+ ['Jordi Ganso Rodríguez', 2, 0],
+ ['Júlia Montserrat Puig', 3, 0],
+ ['Berta Galofré Mestres', 4, 0],
+ ['Laia Pomar Raventós', 3, 1],
+ ['Irene Cusiné Baltà', 1, 0]
+ ];
+
+ $start = 6;
+ $i = $start;
+ foreach ($inscrits as $user) {
+ $i = ($i + 1) % ($start + count($inscrits));
+ if ($i == 0) $i = $i + 1;
+ $template = "INSERT INTO `users` (`id`, `nom`, `curs`, `grau`, `quimata`, `requested`, `mort`, `password`)" .
+ " VALUES (NULL, '".$user[0]."', '".$user[1]."', '".$user[2]."', ".$i.", '0', '0', '')";
+ if (query($template)) echo $template . "\n";
+ }
+?>
diff --git a/ajax/victiminfo.php b/ajax/victiminfo.php
index 2396bb8..518e26a 100644
--- a/ajax/victiminfo.php
+++ b/ajax/victiminfo.php
@@ -1,9 +1,19 @@
<?php
+ require '../credentials.php';
require '../php/utils.php';
$user = get_users($_GET['userid']);
$victim = get_users($user->quimata);
?>
-<img width="300px" src="./imgs/<?=$victim->id?>.png" />
-<h2 id="victim_name"><?=$victim->nomcomplet?></h2>
-<h3><span id="victim_curs"><?=$victim->curs?></span>-<span id="victim_grau"><?=$victim->grau?></span></h3>
+<table class="victima">
+ <tr>
+ <td><img id="victim_img" src="./imgs/<?=$victim->id?>.png" /></td>
+ <td>
+ <div id="victim_name"><?=$victim->nomcomplet?></div>
+ <div id="victim_curs_i_grau"><span id="victim_curs"><?=$victim->curs?></span>-<span id="victim_grau"><?=$victim->grau?></span></div>
+ <div id="butons" class="options">
+ <button id="win" onclick="js: send_request(user, 'REQ KILL');">L'he matat</button>
+ </div>
+ </td>
+ </tr>
+</table>
diff --git a/js/animations.js b/js/animations.js
index 2681a88..fb04a9a 100644
--- a/js/animations.js
+++ b/js/animations.js
@@ -1,6 +1,6 @@
function change_victim(user) {
$(".victima").fadeOut(400, function() {
- $(".victima").load('./ajax/victiminfo.php?userid=' + user.id);
+ $(".victima").load('./ajax/victiminfo.php?userid=' + user.id + " #victima");
$(".victima").fadeIn(400);
});
}