Skip to content

Commit f53b55a

Browse files
made delete a POST
1 parent dc14311 commit f53b55a

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

README.markdown

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ TODO
2424
====
2525

2626
* Javascript sorting of tables
27-
* Make delete a POST request
2827
* Better error handling
2928
* Move or Copy key to different server
3029
* Importing JSON

delete.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<?php
22

3-
require_once 'common.inc.php';
43

4+
if (!isset($_POST['post'])) {
5+
die('Javascript needs to be enabled for you to delete keys.');
6+
}
7+
8+
9+
require_once 'common.inc.php';
510

611

712
if (isset($_GET['key'])) {
@@ -41,18 +46,7 @@
4146
}
4247

4348

44-
45-
// Refresh the top so the key tree is updated.
46-
require 'header.inc.php';
47-
48-
?>
49-
<script>
50-
top.location.href = top.location.pathname+'?view&s=<?php echo $server['id']?>&key=<?php echo urlencode($_GET['key'])?>';
51-
</script>
52-
<?php
53-
54-
require 'footer.inc.php';
55-
die;
49+
die('?view&s='.$server['id'].'&key='.urlencode($_GET['key']));
5650
}
5751

5852
?>

js/frame.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ $(function() {
1212
}).change();
1313

1414

15-
$('.delkey').click(function(e) {
16-
if (!confirm('Are you sure you want to delete this key and all it\'s values?')) {
17-
e.preventDefault();
18-
}
19-
});
15+
$('.delkey, .delval').click(function(e) {
16+
e.preventDefault();
2017

21-
$('.delval').click(function(e) {
22-
if (!confirm('Are you sure you want to delete this value?')) {
23-
e.preventDefault();
18+
if (confirm($(this).hasClass('delkey') ? 'Are you sure you want to delete this key and all it\'s values?' : 'Are you sure you want to delete this value?')) {
19+
$.ajax({
20+
type: "POST",
21+
url: this.href,
22+
data: 'post=1',
23+
success: function(url) {
24+
top.location.href = top.location.pathname+url;
25+
}
26+
});
2427
}
2528
});
2629
});

0 commit comments

Comments
 (0)