added ability to remove words

This commit is contained in:
nilsding 2014-08-18 18:26:47 +02:00
parent e97c011e12
commit 9a283c7f53
4 changed files with 15 additions and 4 deletions

View File

@ -2112,6 +2112,17 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
}) })
}(jQuery); }(jQuery);
function a(b){ function a(b) {
document.getElementById("recent-count").disabled = b; document.getElementById("recent-count").disabled = b;
} }
function b(x) {
x.preventDefault();
$.get("ucp.php?page=ajax&action=delete-word&id=" + x.dataset.wordId,
function (d) {
d = JSON.parse(d);
if (d.success) {
document.getElementById("words-" + x.dataset.wordId).outerHTML="";
}
}
);
}

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,6 @@ include_once 'config.php';
function check_privileges($ajax = false) { function check_privileges($ajax = false) {
if (!$_SESSION['logged_in']) { if (!$_SESSION['logged_in']) {
if ($ajax) { if ($ajax) {
header('Content-Type: application/javascript');
echo json_encode(array("success" => false)); echo json_encode(array("success" => false));
} else { } else {
$_SESSION['flash'] = "Log in to continue."; $_SESSION['flash'] = "Log in to continue.";
@ -36,7 +35,6 @@ function check_privileges($ajax = false) {
switch ($_GET['page']) { switch ($_GET['page']) {
case "ajax": { case "ajax": {
check_privileges(true); check_privileges(true);
header('Content-Type: application/javascript');
$response = array("success" => false); $response = array("success" => false);
switch ($_GET['action']) { switch ($_GET['action']) {
case "delete-word": { case "delete-word": {
@ -52,6 +50,7 @@ switch ($_GET['page']) {
} }
} }
echo json_encode($response); echo json_encode($response);
exit();
break; break;
} }
case "login": { case "login": {

View File

@ -17,7 +17,7 @@
<tbody> <tbody>
{loop="$words"} {loop="$words"}
<tr> <tr>
<td><b>{$value.author}</b> thinks that you are <span class="label label-default">{$value.word1}</span>, <span class="label label-default">{$value.word2}</span> and <span class="label label-default">{$value.word3}</span><a class="float-right" href="#"><i class="glyphicon glyphicon-remove"></i></a></td> <td id="words-{$value.id}"><b>{$value.author}</b> thinks that you are <span class="label label-default">{$value.word1}</span>, <span class="label label-default">{$value.word2}</span> and <span class="label label-default">{$value.word3}</span><a class="float-right" href="#" class="text-danger" onclick="b(this)" data-word-id="{$value.id}"><i class="glyphicon glyphicon-remove"></i></a></td>
</tr> </tr>
{/loop} {/loop}
</tbody> </tbody>