Skip to content

Commit

Permalink
made delete a POST
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdubbelboer committed Jul 27, 2011
1 parent dc14311 commit f53b55a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
1 change: 0 additions & 1 deletion README.markdown
Expand Up @@ -24,7 +24,6 @@ TODO
====

* Javascript sorting of tables
* Make delete a POST request
* Better error handling
* Move or Copy key to different server
* Importing JSON
Expand Down
20 changes: 7 additions & 13 deletions delete.php
@@ -1,7 +1,12 @@
<?php

require_once 'common.inc.php';

if (!isset($_POST['post'])) {
die('Javascript needs to be enabled for you to delete keys.');
}


require_once 'common.inc.php';


if (isset($_GET['key'])) {
Expand Down Expand Up @@ -41,18 +46,7 @@
}



// Refresh the top so the key tree is updated.
require 'header.inc.php';

?>
<script>
top.location.href = top.location.pathname+'?view&s=<?php echo $server['id']?>&key=<?php echo urlencode($_GET['key'])?>';
</script>
<?php

require 'footer.inc.php';
die;
die('?view&s='.$server['id'].'&key='.urlencode($_GET['key']));
}

?>
19 changes: 11 additions & 8 deletions js/frame.js
Expand Up @@ -12,15 +12,18 @@ $(function() {
}).change();


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

$('.delval').click(function(e) {
if (!confirm('Are you sure you want to delete this value?')) {
e.preventDefault();
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?')) {
$.ajax({
type: "POST",
url: this.href,
data: 'post=1',
success: function(url) {
top.location.href = top.location.pathname+url;
}
});
}
});
});
Expand Down

0 comments on commit f53b55a

Please sign in to comment.