xssbook/public/js/chat.js

38 lines
683 B
JavaScript
Raw Normal View History

2023-07-26 05:04:39 +00:00
import { div, pfp, p, parse, button, body, a, textarea, span, crawl } from './main.js'
import { loadself, loadpostspage, createpost, loadusers } from './api.js'
import { parsePost, header } from './components.js'
function render() {
let new_body =
body({},
...header(false, false, true, data.self.user_id),
)
document.body.replaceWith(new_body)
}
const data = {
self: {},
users: []
}
async function init() {
let request = (await loadself());
data.self = request.json
if (request.json == undefined) {
location.href = '/login'
return
}
data.users[data.self.user_id] = data.self
render()
}
init()