blog.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. function managePost(id){
  2. window.location.href = "/blog/edit.php?p=" + id;
  3. }
  4. function deletePost(id, title){
  5. dialog("confirm", "Delete post", "Do you really want to delete the post '" + title + "'?<br/><br/>There is no way to undo this action. You can also unpublish the post instead of deleting it.", function (confirmed) {
  6. if (confirmed) {
  7. var xmlhttp;
  8. if (window.XMLHttpRequest){
  9. xmlhttp = new XMLHttpRequest();
  10. }
  11. xmlhttp.onreadystatechange=function(){
  12. if (xmlhttp.readyState == 4){
  13. if (xmlhttp.status == 200){
  14. location.reload();
  15. }
  16. else{
  17. dialog("alert", "ERROR", "Error deleting the post '" + title + "'.", null);
  18. }
  19. }
  20. }
  21. xmlhttp.open("GET","/blog/delete.php?p=" + id, true);
  22. xmlhttp.send();
  23. }
  24. });
  25. }
  26. function deleteComment(id){
  27. dialog("confirm", "Delete version", "Do you really want to delete this comment?<br/><br/>There is no way to undo this action. You can also disapprove the comment instead of deleting it.", function (confirmed) {
  28. if (confirmed) {
  29. var xmlhttp;
  30. if (window.XMLHttpRequest){
  31. xmlhttp = new XMLHttpRequest();
  32. }
  33. xmlhttp.onreadystatechange=function(){
  34. if (xmlhttp.readyState == 4){
  35. if (xmlhttp.status == 200){
  36. location.reload();
  37. }
  38. else{
  39. dialog("alert", "ERROR", "Error deleting the comment.", null);
  40. }
  41. }
  42. }
  43. xmlhttp.open("GET","/blog/deletecomment.php?i=" + id, true);
  44. xmlhttp.send();
  45. }
  46. });
  47. }
  48. function visiblePost(id, title, visible){
  49. var xmlhttp;
  50. if (window.XMLHttpRequest){
  51. xmlhttp = new XMLHttpRequest();
  52. }
  53. xmlhttp.onreadystatechange=function(){
  54. if (xmlhttp.readyState == 4){
  55. if (xmlhttp.status == 200){
  56. location.reload();
  57. }
  58. else{
  59. dialog("alert", "ERROR", "Error changing visibility of the post '" + title + "'.", null);
  60. }
  61. }
  62. }
  63. xmlhttp.open("GET","/post/visible.php?p=" + id + "&v=" + visible, true);
  64. xmlhttp.send();
  65. }
  66. function addImage(){
  67. }