ajax POST: return whole thread
This commit is contained in:
parent
cb7c818996
commit
c94774c9ab
|
@ -2303,6 +2303,8 @@ function buildThread($id, $return = false, $mod = false) {
|
|||
|
||||
$action = generation_strategy('sb_thread', array($board['uri'], $id));
|
||||
|
||||
$rendered_thread = null;
|
||||
|
||||
if ($action == 'rebuild' || $return || $mod) {
|
||||
$query = prepare(sprintf("SELECT *,'%s' as board FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'],$board['uri']));
|
||||
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
|
@ -2323,10 +2325,12 @@ function buildThread($id, $return = false, $mod = false) {
|
|||
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
||||
$antibot = $mod || $return ? false : create_antibot($board['uri'], $id);
|
||||
|
||||
$rendered_thread = $thread->build();
|
||||
|
||||
$body = Element('thread.html', array(
|
||||
'board' => $board,
|
||||
'thread' => $thread,
|
||||
'body' => $thread->build(),
|
||||
'body' => $rendered_thread,
|
||||
'config' => $config,
|
||||
'id' => $id,
|
||||
'mod' => $mod,
|
||||
|
@ -2364,6 +2368,8 @@ function buildThread($id, $return = false, $mod = false) {
|
|||
}
|
||||
|
||||
file_write($board['dir'] . $config['dir']['res'] . link_for($thread), $body);
|
||||
|
||||
return $rendered_thread;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -236,22 +236,18 @@ $().ready(() => {
|
|||
return;
|
||||
}
|
||||
|
||||
const post_dom = parser.parseFromString(
|
||||
post_response['post'],
|
||||
const thread_dom = parser.parseFromString(
|
||||
post_response['thread'],
|
||||
"text/html");
|
||||
|
||||
const post_elem = post_dom.querySelector(".postcontainer");
|
||||
console.log(post_elem);
|
||||
const post_container = LCNPostContainer.assign(post_elem);
|
||||
console.log("lcn_post_container:", post_container);
|
||||
|
||||
const thread_id_sel = "#thread_" + post_response['thread_id'];
|
||||
const thread = document.querySelector(thread_id_sel);
|
||||
console.log("thread:", thread);
|
||||
const lcn_thread = new LCNThread(thread);
|
||||
console.log("lcn_thread: ", lcn_thread);
|
||||
const post_containers = [...thread_dom.querySelectorAll(`${thread_id_sel} > .postcontainer`)]
|
||||
.map(elem => LCNPostContainer.assign(elem));
|
||||
|
||||
updateThreadFn(lcn_thread, [ post_container ]);
|
||||
const thread_elem = document.querySelector(thread_id_sel);
|
||||
const lcn_thread = new LCNThread(thread_elem);
|
||||
|
||||
updateThreadFn(lcn_thread, post_containers);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
6
post.php
6
post.php
|
@ -1477,7 +1477,7 @@ function handle_post(){
|
|||
|
||||
$thread_id = $post['op'] ? $id : $post['thread'];
|
||||
|
||||
buildThread($thread_id);
|
||||
$rendered_thread = buildThread($thread_id);
|
||||
|
||||
if ($config['syslog'])
|
||||
_syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] .
|
||||
|
@ -1494,8 +1494,8 @@ function handle_post(){
|
|||
'redirect' => $redirect,
|
||||
'noko' => $noko,
|
||||
'id' => $id,
|
||||
'post' => (new Post($post))->build(),
|
||||
'thread_id' => $thread_id
|
||||
'thread_id' => $thread_id,
|
||||
'thread' => $rendered_thread
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue