Archived
1
0

fix json rendering

This commit is contained in:
Jeff Becker 2017-09-30 08:32:51 -04:00
parent ef024977df
commit 796d3480ba
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
2 changed files with 36 additions and 9 deletions

View File

@ -264,9 +264,10 @@ func (self *post) MarshalJSON() (b []byte, err error) {
if len(self.Key) > 0 { if len(self.Key) > 0 {
self.Tripcode = makeTripcode(self.Key) self.Tripcode = makeTripcode(self.Key)
} }
if len(self.PostMarkup) > 0 { if len(self.PostMessage) > 0 {
self.PostMarkup = self.RenderPost() self.PostMarkup = self.RenderPost()
} }
self.PostPrefix = self.Prefix() self.PostPrefix = self.Prefix()
// for liveui // for liveui
self.Type = "Post" self.Type = "Post"

View File

@ -46,6 +46,26 @@ var reloadImg = function(el) {
return false; 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 // form resubmit
onready(function() { onready(function() {
var submitPost = function(form, elem, cb) { var submitPost = function(form, elem, cb) {
@ -89,15 +109,21 @@ onready(function() {
e.innerHTML = "posting "; e.innerHTML = "posting ";
submitPost(document.forms[0], e, function(err, j) { submitPost(document.forms[0], e, function(err, j) {
var msg = err || "posted"; var msg = err || "posted";
console.log(msg, j); console.log(msg, j.url);
e.innerHTML = msg; e.innerHTML = msg;
setTimeout(function() { if(window.location.pathname == j.url) {
e.disabled = false; setTimeout(function() {
e.innerHTML = origText; e.disabled = false;
}, 1000); e.innerHTML = origText;
var img = document.getElementById("captcha_img"); }, 1000);
if (img) { var img = document.getElementById("captcha_img");
reloadImg(img); if (img) {
reloadImg(img);
}
reloadThreadJSON();
} else {
// do redirect
window.location.pathname = j.url;
} }
}); });
} }