58 lines
No EOL
1.3 KiB
JavaScript
58 lines
No EOL
1.3 KiB
JavaScript
function parseUser(user) {
|
|
const html = `
|
|
<a class="person" href="/profile?id=${user.id}">
|
|
<div class="profile">
|
|
|
|
</div>
|
|
<div class="info">
|
|
<span class="bold ltext">${user.firstname + ' ' + user.lastname}</span>
|
|
<span class="gtext">Joined ${parseDate(new Date(user.date))}</span>
|
|
<span class="gtext">Gender: ${user.gender}</span>
|
|
<span class="gtext">Birthday: ${parseMonth(user.month) + ' ' + user.day + ', ' + user.year}</span>
|
|
<span class="gtext" style="margin-bottom: -100px;">User ID: ${user.user_id}</span>
|
|
</div>
|
|
</a>
|
|
`
|
|
return html
|
|
}
|
|
|
|
function render() {
|
|
const html = `
|
|
<div id="users">
|
|
${data.users.map(u => parseUser(u)).join('')}
|
|
</div>
|
|
`
|
|
|
|
add(html, 'users')
|
|
|
|
const load = `
|
|
<div id="load">
|
|
<a class="bold gtext" onclick="load()">Load more users</a>
|
|
</div>
|
|
`
|
|
|
|
if (page !== -1) {
|
|
add(load, 'load')
|
|
} else {
|
|
remove('load')
|
|
}
|
|
}
|
|
|
|
var page = 0
|
|
var data = {
|
|
users: []
|
|
}
|
|
|
|
async function load() {
|
|
const users = (await loaduserspage(page)).json
|
|
if (users.length === 0) {
|
|
page = -1
|
|
} else {
|
|
page++
|
|
}
|
|
data.users.push(... users)
|
|
render()
|
|
}
|
|
|
|
header(false, true)
|
|
load() |