diff --git a/contrib/backends/srndv2/src/srnd/model_mem.go b/contrib/backends/srndv2/src/srnd/model_mem.go index 771d8a7..258e425 100644 --- a/contrib/backends/srndv2/src/srnd/model_mem.go +++ b/contrib/backends/srndv2/src/srnd/model_mem.go @@ -264,9 +264,10 @@ func (self *post) MarshalJSON() (b []byte, err error) { if len(self.Key) > 0 { self.Tripcode = makeTripcode(self.Key) } - if len(self.PostMarkup) > 0 { + if len(self.PostMessage) > 0 { self.PostMarkup = self.RenderPost() } + self.PostPrefix = self.Prefix() // for liveui self.Type = "Post" diff --git a/contrib/static/overchan.js b/contrib/static/overchan.js index 483896a..63bd830 100644 --- a/contrib/static/overchan.js +++ b/contrib/static/overchan.js @@ -46,6 +46,26 @@ var reloadImg = function(el) { return false; }; +var reloadThreadJSON = function() { + var url = window.location.href += "/json"; + var ajax = new XMLHttpRequest(); + ajax.onreadystatechange = function() { + if(ajax.readyState == 4) { + if(ajax.status == 404) { + console.log("thread gone"); + } else if (ajax.status == 200) { + var posts = JSON.parse(ajax.responseText); + for(var idx = 0; idx < posts.length; idx ++ ) + { + + } + } + } + }; + ajax.open("GET", url); + ajax.send(); +} + // form resubmit onready(function() { var submitPost = function(form, elem, cb) { @@ -89,15 +109,21 @@ onready(function() { e.innerHTML = "posting "; submitPost(document.forms[0], e, function(err, j) { var msg = err || "posted"; - console.log(msg, j); + console.log(msg, j.url); e.innerHTML = msg; - setTimeout(function() { - e.disabled = false; - e.innerHTML = origText; - }, 1000); - var img = document.getElementById("captcha_img"); - if (img) { - reloadImg(img); + if(window.location.pathname == j.url) { + setTimeout(function() { + e.disabled = false; + e.innerHTML = origText; + }, 1000); + var img = document.getElementById("captcha_img"); + if (img) { + reloadImg(img); + } + reloadThreadJSON(); + } else { + // do redirect + window.location.pathname = j.url; } }); }