From e72a37f928fcf6845cac6396612b5be3fa40954c Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 26 Oct 2018 07:28:24 -0400 Subject: [PATCH] add js delete function --- contrib/static/overchan.js | 29 +++++++++++++++++++++++++ contrib/templates/placebo/post.mustache | 1 + 2 files changed, 30 insertions(+) diff --git a/contrib/static/overchan.js b/contrib/static/overchan.js index 8b8e425..6dbfd6e 100644 --- a/contrib/static/overchan.js +++ b/contrib/static/overchan.js @@ -9,6 +9,35 @@ var ready = function() { for(var idx = 0; idx < _onreadyfuncs.length; idx++) _onreadyfuncs[idx](); }; +var nntpchan_mod_delete = function(lonhash) { + var elem = document.getElementById(longhash); + var ajax = new XMLHttpRequest(); + ajax.onreadystatechange = function() { + if(ajax.readyState == 4) + { + if(ajax.status == 200) + { + // success (?) + var j = JSON.parse(ajax.responseText); + if(j.deleted) + { + elem.appendChild(document.createTextNode(j.deleted)); + } + else (j.error) + { + elem.innerHTML = "an error occured: " + j.error ; + } + } + else + { + elem.innerHTML = "post not deleted from server: "+ ajax.statusText; + } + } + }; + ajax.open("GET", "/mod/del/"+longhash); + ajax.send(); + elem.innerHTML = ""; +}; var quickreply = function(shorthash, longhash, url) { if (!window.location.pathname.startsWith("/t/")) diff --git a/contrib/templates/placebo/post.mustache b/contrib/templates/placebo/post.mustache index a21891e..a99fefe 100644 --- a/contrib/templates/placebo/post.mustache +++ b/contrib/templates/placebo/post.mustache @@ -30,6 +30,7 @@ {{#post.Attachments}} {{/post.Attachments}} + [Delete] {{post.Subject}} {{post.Name}} {{post.Frontend}} || {{post.Date}} {{{post.Pubkey}}} {{post.ShortHash}}