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,8 +109,9 @@ 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;
if(window.location.pathname == j.url) {
setTimeout(function() { setTimeout(function() {
e.disabled = false; e.disabled = false;
e.innerHTML = origText; e.innerHTML = origText;
@ -99,6 +120,11 @@ onready(function() {
if (img) { if (img) {
reloadImg(img); reloadImg(img);
} }
reloadThreadJSON();
} else {
// do redirect
window.location.pathname = j.url;
}
}); });
} }
} }