Mercurial > public > sg101
diff media/js/forums.js @ 107:e94398f5e027
Forums: implemented post delete feature.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 22 Sep 2009 03:36:39 +0000 |
parents | 10d6182b9f6e |
children | 80ab249d1adc |
line wrap: on
line diff
--- a/media/js/forums.js Sat Sep 19 21:49:56 2009 +0000 +++ b/media/js/forums.js Tue Sep 22 03:36:39 2009 +0000 @@ -33,7 +33,7 @@ }); $('a.post-flag').click(function () { var id = this.id; - if (id.match(/fp-(\d)/)) { + if (id.match(/fp-(\d+)/)) { id = RegExp.$1; if (confirm('Only flag a post if you feel it is spam, abuse, violates site rules, ' + 'or is not appropriate. ' + @@ -55,5 +55,27 @@ } return false; }); + $('a.post-delete').click(function () { + var id = this.id; + if (id.match(/dp-(\d+)/)) { + id = RegExp.$1; + if (confirm('Are you sure you want to delete this post?')) { + $.ajax({ + url: '/forums/delete-post/', + type: 'POST', + data: {id: id}, + dataType: 'text', + success: function (response, textStatus) { + alert(response); + $('#post-' + id).fadeOut(3000); + }, + error: function (xhr, textStatus, ex) { + alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); + } + }); + } + } + return false; + }); $('#id_body').markItUp(mySettings); });