fix a counting bug in main page
This commit is contained in:
parent
4639965403
commit
568d7a49cd
2 changed files with 4 additions and 1 deletions
4
index.js
4
index.js
|
@ -37,7 +37,9 @@ server.use(require('body-parser').urlencoded({extended: false}))
|
|||
server.all('/', function get(req, res) {
|
||||
const fake = req.body.fake === 'yes'
|
||||
let mainPage = {author: webname, title: 'All posts', content: 'These are all the posts on the board:', comments: []}
|
||||
for (let i = 0; i < posts.length && i < 2000; i++) {
|
||||
for (let i = 0; i < posts.length - 2000; i++)
|
||||
mainPage.comments.push(null)
|
||||
for (let i = Math.max(0, posts.length - 2000); i < posts.length; i++) {
|
||||
mainPage.comments.push({timestamp: posts[i].timestamp, author: posts[i].author, title: posts[i].title, content: posts[i].content, comments: []})
|
||||
}
|
||||
if(req.body.name && req.body.title && req.body.content) {
|
||||
|
|
|
@ -159,6 +159,7 @@
|
|||
for(let i = post.comments.length - 1; i >= 0; i--) {
|
||||
const pid = id
|
||||
id += i + '_'
|
||||
if(post.comments[i])
|
||||
recurse(post.comments[i])
|
||||
id = pid
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue