summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/admin.html15
-rw-r--r--public/home.html8
-rw-r--r--public/js/admin.js29
-rw-r--r--public/js/api.js50
-rw-r--r--public/js/components.js249
-rw-r--r--public/js/header.js24
-rw-r--r--public/js/home.js294
-rw-r--r--public/js/login.js8
-rw-r--r--public/js/main.js139
-rw-r--r--public/js/people.js100
-rw-r--r--public/js/profile.js265
-rw-r--r--public/login.html7
-rw-r--r--public/people.html10
-rw-r--r--public/profile.html9
14 files changed, 753 insertions, 454 deletions
diff --git a/public/admin.html b/public/admin.html
index cd79337..2d2bcd6 100644
--- a/public/admin.html
+++ b/public/admin.html
@@ -5,17 +5,16 @@
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/css/header.css">
<link rel="stylesheet" href="/css/admin.css">
+ <script src="/js/admin.js" type="module"></script>
<title>XSSBook - Admin Panel</title>
</head>
<body>
- <script src="/js/api.js"></script>
- <script src="/js/admin.js"></script>
<div id="header">
<span class="logo"><a href="/">xssbook</a></span>
<span class="gtext desc" style="margin-left: 6em; font-size: 2em; color: #606770">Admin Panel</span>
</div>
<div id="login" class="hidden">
- <form autocomplete="off" onsubmit="auth(event)">
+ <form autocomplete="off" onsubmit="window.auth(event)">
<input autocomplete="new-password" type="password" name="adminpassword" id="adminpassword" placeholder="Login Secret">
</form>
</div>
@@ -23,10 +22,12 @@
<div id="queryinput">
<input type="text" name="query" id="query" placeholder="SQL Query">
<div id="buttons">
- <button class="submit" onclick="submit()">Submit</button>
- <button class="view" onclick="posts()">View Posts</button>
- <button class="view" onclick="users()">View Users</button>
- <button class="view" onclick="sessions()">View Sessions</button>
+ <button class="submit" onclick="window.submit()">Submit</button>
+ <button class="view" onclick="window.posts()">View Posts</button>
+ <button class="view" onclick="window.users()">View Users</button>
+ <button class="view" onclick="window.sessions()">View Sessions</button>
+ <button class="view" onclick="window.comments()">View Comments</button>
+ <button class="view" onclick="window.likes()">View Likes</button>
</div>
</div>
<table id="table"></table>
diff --git a/public/home.html b/public/home.html
index 865e53a..5cc7776 100644
--- a/public/home.html
+++ b/public/home.html
@@ -2,16 +2,12 @@
<html lang="en">
<head>
<meta charset="UTF-8">
- <link rel="stylesheet" href="/css/header.css">
<link rel="stylesheet" href="/css/main.css">
+ <link rel="stylesheet" href="/css/header.css">
<link rel="stylesheet" href="/css/home.css">
<title>XSSBook - Home</title>
+ <script type="module" src="/js/home.js"></script>
</head>
<body>
- <script src="/js/main.js"></script>
- <script src="/js/header.js"></script>
- <script src="/js/api.js"></script>
- <script src="/js/home.js"></script>
- <script>init()</script>
</body>
</html> \ No newline at end of file
diff --git a/public/js/admin.js b/public/js/admin.js
index e4364ec..18799b7 100644
--- a/public/js/admin.js
+++ b/public/js/admin.js
@@ -1,3 +1,5 @@
+import { adminauth, admincheck, admincomments, adminposts, adminquery, adminsessions, adminusers, adminlikes } from './api.js'
+
async function auth(event) {
event.preventDefault();
const text = event.target.elements.adminpassword.value;
@@ -10,12 +12,14 @@ async function auth(event) {
}
return false;
}
+window.auth = auth
async function submit() {
let text = document.getElementById("query").value
let response = await adminquery(text)
alert(response.msg)
}
+window.submit = submit
async function posts() {
let response = await adminposts();
@@ -26,6 +30,7 @@ async function posts() {
let table = document.getElementById("table")
table.innerHTML = response.msg
}
+window.posts = posts
async function users() {
let response = await adminusers();
@@ -36,6 +41,7 @@ async function users() {
let table = document.getElementById("table")
table.innerHTML = response.msg
}
+window.users = users
async function sessions() {
let response = await adminsessions();
@@ -46,6 +52,29 @@ async function sessions() {
let table = document.getElementById("table")
table.innerHTML = response.msg
}
+window.sessions = sessions
+
+async function comments() {
+ let response = await admincomments();
+ if (response.status !== 200) {
+ alert(response.msg)
+ return
+ }
+ let table = document.getElementById("table")
+ table.innerHTML = response.msg
+}
+window.comments = comments
+
+async function likes() {
+ let response = await adminlikes();
+ if (response.status !== 200) {
+ alert(response.msg)
+ return
+ }
+ let table = document.getElementById("table")
+ table.innerHTML = response.msg
+}
+window.likes = likes
async function load() {
let check = await admincheck();
diff --git a/public/js/api.js b/public/js/api.js
index 886a017..7d9598d 100644
--- a/public/js/api.js
+++ b/public/js/api.js
@@ -43,78 +43,90 @@ const request = async (url, body, method) => {
}
}
-const login = async (email, password) => {
+export const login = async (email, password) => {
return await request('/auth/login', {email, password})
}
-const register = async (firstname, lastname, email, password, gender, day, month, year) => {
+export const register = async (firstname, lastname, email, password, gender, day, month, year) => {
return await request('/auth/register', {firstname, lastname, email, password, gender, day, month, year})
}
-const logout = async () => {
+export const logout = async () => {
return await request('/auth/logout', {})
}
-const loadpostspage = async (page) => {
+export const loadpostspage = async (page) => {
return await request('/posts/page', {page})
}
-const loadusersposts = async (user_id, page) => {
+export const loadcommentspage = async (page, post_id) => {
+ return await request('/posts/comments', {page, post_id})
+}
+
+export const loadusersposts = async (user_id, page) => {
return await request('/posts/user', {user_id, page})
}
-const loadusers = async (ids) => {
+export const loadusers = async (ids) => {
return await request('/users/load', {ids})
}
-const loaduserspage = async (page) => {
+export const loaduserspage = async (page) => {
return await request('/users/page', {page})
}
-const loadself = async () => {
+export const loadself = async () => {
return await request("/users/self", {})
}
-const postcomment = async (post_id, content) => {
+export const postcomment = async (post_id, content) => {
return await request('/posts/comment', {post_id, content}, 'PATCH')
}
-const postlike = async (post_id, state) => {
+export const postlike = async (post_id, state) => {
return await request('/posts/like', {post_id, state}, 'PATCH')
}
-const createpost = async (content) => {
+export const createpost = async (content) => {
return await request('/posts/create', {content})
}
-const adminauth = async (secret) => {
+export const adminauth = async (secret) => {
return await request('/admin/auth', {secret})
}
-const admincheck = async () => {
+export const admincheck = async () => {
return await request('/admin/check', {})
}
-const adminquery = async (query) => {
+export const adminquery = async (query) => {
return await request('/admin/query', {query})
}
-const adminposts = async () => {
+export const adminposts = async () => {
return await request('/admin/posts', {})
}
-const adminusers = async () => {
+export const adminusers = async () => {
return await request('/admin/users', {})
}
-const adminsessions = async () => {
+export const adminsessions = async () => {
return await request('/admin/sessions', {})
}
-const updateavatar = async (file) => {
+export const admincomments = async () => {
+ return await request('/admin/comments', {})
+}
+
+export const adminlikes = async () => {
+ return await request('/admin/likes', {})
+}
+
+export const updateavatar = async (file) => {
return await fileRequest('/users/avatar', file, 'PUT')
}
-const updatebanner = async (file) => {
+export const updatebanner = async (file) => {
return await fileRequest('/users/banner', file, 'PUT')
} \ No newline at end of file
diff --git a/public/js/components.js b/public/js/components.js
new file mode 100644
index 0000000..9816457
--- /dev/null
+++ b/public/js/components.js
@@ -0,0 +1,249 @@
+import { div, a, pfp, span, i, parse, parseDate, p, form, input, svg, path, parseMonth } from './main.js'
+import { postlike, postcomment, loadcommentspage } from './api.js';
+
+window.parse = parse;
+
+export function header(home, people, user_id) {
+ return [
+ div({id: 'header'},
+ span({class: 'logo'},
+ a({href: '/'},
+ parse('xssbook')
+ )
+ ),
+ div({class: 'buttons'},
+ a({id: 'home', class: home ? 'selected' : '', href: 'home'},
+ svg({viewBox: '0 0 28 28', fill: 'currentColor', height: '28', width: '28'},
+ path({d: "M25.825 12.29C25.824 12.289 25.823 12.288 25.821 12.286L15.027 2.937C14.752 2.675 14.392 2.527 13.989 2.521 13.608 2.527 13.248 2.675 13.001 2.912L2.175 12.29C1.756 12.658 1.629 13.245 1.868 13.759 2.079 14.215 2.567 14.479 3.069 14.479L5 14.479 5 23.729C5 24.695 5.784 25.479 6.75 25.479L11 25.479C11.552 25.479 12 25.031 12 24.479L12 18.309C12 18.126 12.148 17.979 12.33 17.979L15.67 17.979C15.852 17.979 16 18.126 16 18.309L16 24.479C16 25.031 16.448 25.479 17 25.479L21.25 25.479C22.217 25.479 23 24.695 23 23.729L23 14.479 24.931 14.479C25.433 14.479 25.921 14.215 26.132 13.759 26.371 13.245 26.244 12.658 25.825 12.29"})
+ )
+ ),
+ a({id: 'people', class: people ? 'selected' : '', href: 'people'},
+ svg({viewBox: '0 0 28 28', fill: 'currentColor', height: '28', width: '28'},
+ path({d: "M10.5 4.5c-2.272 0-2.75 1.768-2.75 3.25C7.75 9.542 8.983 11 10.5 11s2.75-1.458 2.75-3.25c0-1.482-.478-3.25-2.75-3.25zm0 8c-2.344 0-4.25-2.131-4.25-4.75C6.25 4.776 7.839 3 10.5 3s4.25 1.776 4.25 4.75c0 2.619-1.906 4.75-4.25 4.75zm9.5-6c-1.41 0-2.125.841-2.125 2.5 0 1.378.953 2.5 2.125 2.5 1.172 0 2.125-1.122 2.125-2.5 0-1.659-.715-2.5-2.125-2.5zm0 6.5c-1.999 0-3.625-1.794-3.625-4 0-2.467 1.389-4 3.625-4 2.236 0 3.625 1.533 3.625 4 0 2.206-1.626 4-3.625 4zm4.622 8a.887.887 0 00.878-.894c0-2.54-2.043-4.606-4.555-4.606h-1.86c-.643 0-1.265.148-1.844.413a6.226 6.226 0 011.76 4.336V21h5.621zm-7.122.562v-1.313a4.755 4.755 0 00-4.749-4.749H8.25A4.755 4.755 0 003.5 20.249v1.313c0 .518.421.938.937.938h12.125c.517 0 .938-.42.938-.938zM20.945 14C24.285 14 27 16.739 27 20.106a2.388 2.388 0 01-2.378 2.394h-5.81a2.44 2.44 0 01-2.25 1.5H4.437A2.44 2.44 0 012 21.562v-1.313A6.256 6.256 0 018.25 14h4.501a6.2 6.2 0 013.218.902A5.932 5.932 0 0119.084 14h1.861z"})
+ )
+ )
+ ),
+ a({class: 'pfp', id: 'profile', href: 'profile'},
+ user_id === undefined ? parse('') : pfp(user_id)
+ )
+ ),
+ div({class: 'spacer'})
+ ]
+}
+
+export function parsePost(post, users, self) {
+ let content = post.content
+ let date = post.date
+ let likes = post.likes
+ let author = users[post.user_id]
+
+ let comments = []
+ for (const comment of post.comments) {
+ comments.push(parseComment(comment, users))
+ }
+
+ let liked = post.liked;
+
+ var page = 0
+
+ return (
+ div({class: 'post', postid: post.post_id},
+ div({class: 'postheader'},
+ a({class: 'pfp', href: `/profile?id=${author.user_id}`},
+ pfp(author.user_id)
+ ),
+ div({class: 'postname'},
+ span({class: 'bold'},
+ parse(author.firstname + ' ' + author.lastname)
+ ),
+ span({class: 'gtext mtext'},
+ parse(parseDate(new Date(date)))
+ )
+ )
+ ),
+ p({class: 'mtext', style: "color: var(--text);"},
+ parse(content.replace(/\n/g,'<br>'))
+ ),
+ span({class: 'gtext mtext likes'},
+ parse(`${likes} Likes`)
+ ),
+ div({class: 'fullline nb'}),
+ div({class: 'postbuttons'},
+ span({class: 'likeclicky', onclick: async (event) => {
+
+ var post = event.target;
+ while(post.parentElement) {
+ post = post.parentElement
+ if (post.getAttribute('postid')) {
+ break;
+ }
+ }
+
+ let likes = post.getElementsByClassName('likes')[0]
+ let post_id = parseInt(post.getAttribute('postid'))
+
+ let like_text = likes.textContent;
+ let like_count = parseInt(like_text.substring(0, like_text.indexOf(" Likes")))
+
+ const response = await postlike(post_id, !liked)
+
+ if (response.status !== 200) { return }
+
+ liked = !liked
+
+ let el = post.getElementsByClassName('liketoggle')
+
+ if (liked) {
+ el[0].classList.add('blue')
+ el[1].classList.add('blue')
+ like_count++
+ } else {
+ el[0].classList.remove('blue')
+ el[1].classList.remove('blue')
+ like_count--
+ }
+
+ likes.textContent = like_count + " Likes"
+ }},
+ i({class: `liketoggle icons like ${liked ? 'blue' : ''}`}),
+ span({class: `liketoggle bold ${liked ? 'blue' : ''}`},
+ parse('Like')
+ )
+ ),
+ span({onclick: () => this.parentElement.parentElement.getElementsByClassName('newcomment')[0].focus()},
+ i({class: 'icons comm'}),
+ span({class: 'bold'},
+ parse('Comment')
+ )
+ )
+ ),
+ div({class: 'fullline nb', style: 'margin-top: 0'}),
+ div({class: 'comments'},
+ div({class: 'comment commentsubmit', style: 'margin-top: 0'}),
+ ...comments,
+ comments.length > 0 ?
+ div({id: 'load', class: 'load', style: 'justify-content: inherit; margin-left: 3.5em; font-size: .9em; margin-bottom: -.5em;'},
+ a({class: 'blod gtext', onclick: async (event) => {
+
+ page++;
+
+ const response = await loadcommentspage(page, post.post_id)
+ if (response.status != 200) { return };
+
+ let comments = response.json
+
+ for (const comment of comments) {
+ event.target.parentElement.parentElement.insertBefore(
+ parseComment(comment, users),
+ event.target.parentElement
+ )
+ }
+
+ if (comments.length < 5) {
+ event.target.parentElement.remove()
+ }
+ }},
+ parse('Load more comments')
+ )
+ )
+ : parse(''),
+ div({class: 'comment commentsubmit'},
+ a({class: 'pfp', href: 'profile'},
+ pfp(self.user_id)
+ ),
+ form({onsubmit: async (event) => {
+ event.preventDefault()
+
+ let text = event.target.elements.text.value.trim();
+ if (text.length < 1) {
+ return
+ }
+
+ let post = event.target.parentElement.parentElement.parentElement
+ let post_id = parseInt(post.getAttribute('postid'))
+
+ const response = await postcomment(post_id, text)
+ if (response.status != 200) { return };
+
+ let comment = {
+ user_id: self.user_id,
+ content: text,
+ date: Date.now()
+ }
+
+ let comments = post.getElementsByClassName('comments')[0]
+
+ let load = comments.getElementsByClassName('load')[0];
+ if (load == undefined) {
+ load = comments.lastChild
+ }
+
+ comments.insertBefore(
+ parseComment(comment, users),
+ load
+ )
+
+ event.target.elements.text.value = ''
+
+ }},
+ input({type: 'text', name: 'text', placeholder: 'Write a comment', id: 'newcomment', class: 'newcomment'})
+ )
+ )
+ )
+ )
+ )
+
+
+}
+
+export function parseComment(comment, users) {
+
+ let author = users[comment.user_id]
+
+ return (
+ div({class: 'comment'},
+ a({class: 'pfp'},
+ pfp(comment.user_id)
+ ),
+ span({},
+ span({class: 'bold mtext'},
+ parse(author.firstname + ' ' + author.lastname),
+ span({class: 'gtext mtext', style: 'margin-left: 1em'},
+ parse(parseDate(new Date(comment.date)))
+ )
+ ),
+ p({class: 'mtext'},
+ parse(comment.content)
+ )
+ )
+ )
+ )
+}
+
+export function parseUser(user) {
+
+ return (
+ a({class: 'person', href: `/profile?id=${user.user_id}`},
+ div({class: 'profile'},
+ pfp(user.user_id)
+ ),
+ div({class: 'info'},
+ span({class: 'bold ltext'},
+ parse(user.firstname + ' ' + user.lastname)
+ ),
+ span({class: 'gtext'},
+ parse('Joined ' + parseDate(new Date(user.date)))
+ ),
+ span({class: 'gtext'},
+ parse('Gender :' + user.gender)
+ ),
+ span({class: 'gtext'},
+ parse('Birthday: ' + parseMonth(user.month) + ' ' + user.day + ', ' + user.year)
+ ),
+ span({class: 'gtext', style: 'margin-bottom: -100px'},
+ parse('User ID: ' + user.user_id)
+ )
+ )
+ )
+ )
+} \ No newline at end of file
diff --git a/public/js/header.js b/public/js/header.js
deleted file mode 100644
index f296567..0000000
--- a/public/js/header.js
+++ /dev/null
@@ -1,24 +0,0 @@
-function header(home, people, user_id) {
- const html = `
- <div id="header">
- <span class="logo"><a href="/">xssbook</a></span>
- <div class="buttons">
- <a id="home" ${home ? 'class="selected"' : ''} href="home">
- <svg viewBox="0 0 28 28" fill="currentColor" height="28" width="28">
- <path d="M25.825 12.29C25.824 12.289 25.823 12.288 25.821 12.286L15.027 2.937C14.752 2.675 14.392 2.527 13.989 2.521 13.608 2.527 13.248 2.675 13.001 2.912L2.175 12.29C1.756 12.658 1.629 13.245 1.868 13.759 2.079 14.215 2.567 14.479 3.069 14.479L5 14.479 5 23.729C5 24.695 5.784 25.479 6.75 25.479L11 25.479C11.552 25.479 12 25.031 12 24.479L12 18.309C12 18.126 12.148 17.979 12.33 17.979L15.67 17.979C15.852 17.979 16 18.126 16 18.309L16 24.479C16 25.031 16.448 25.479 17 25.479L21.25 25.479C22.217 25.479 23 24.695 23 23.729L23 14.479 24.931 14.479C25.433 14.479 25.921 14.215 26.132 13.759 26.371 13.245 26.244 12.658 25.825 12.29"></path>
- </svg>
- </a>
- <a id="people" ${people ? 'class="selected"' : ''} href="people">
- <svg viewBox="0 0 28 28" fill="currentColor" height="28" width="28">
- <path d="M10.5 4.5c-2.272 0-2.75 1.768-2.75 3.25C7.75 9.542 8.983 11 10.5 11s2.75-1.458 2.75-3.25c0-1.482-.478-3.25-2.75-3.25zm0 8c-2.344 0-4.25-2.131-4.25-4.75C6.25 4.776 7.839 3 10.5 3s4.25 1.776 4.25 4.75c0 2.619-1.906 4.75-4.25 4.75zm9.5-6c-1.41 0-2.125.841-2.125 2.5 0 1.378.953 2.5 2.125 2.5 1.172 0 2.125-1.122 2.125-2.5 0-1.659-.715-2.5-2.125-2.5zm0 6.5c-1.999 0-3.625-1.794-3.625-4 0-2.467 1.389-4 3.625-4 2.236 0 3.625 1.533 3.625 4 0 2.206-1.626 4-3.625 4zm4.622 8a.887.887 0 00.878-.894c0-2.54-2.043-4.606-4.555-4.606h-1.86c-.643 0-1.265.148-1.844.413a6.226 6.226 0 011.76 4.336V21h5.621zm-7.122.562v-1.313a4.755 4.755 0 00-4.749-4.749H8.25A4.755 4.755 0 003.5 20.249v1.313c0 .518.421.938.937.938h12.125c.517 0 .938-.42.938-.938zM20.945 14C24.285 14 27 16.739 27 20.106a2.388 2.388 0 01-2.378 2.394h-5.81a2.44 2.44 0 01-2.25 1.5H4.437A2.44 2.44 0 012 21.562v-1.313A6.256 6.256 0 018.25 14h4.501a6.2 6.2 0 013.218.902A5.932 5.932 0 0119.084 14h1.861z"></path>
- </svg>
- </a>
- </div>
- <a class="pfp" id="profile" hreF="profile">
- ${user_id === undefined ? '' : pfp(user_id)}
- </a>
- </div>
- <div class="spacer"></div>
- `
- append(html)
-} \ No newline at end of file
diff --git a/public/js/home.js b/public/js/home.js
index 2e5818a..25fe0e9 100644
--- a/public/js/home.js
+++ b/public/js/home.js
@@ -1,124 +1,6 @@
-function parseComment(comment) {
- let author = data.users[comment[0]]
- if (author === undefined) {
- author = {}
- }
- const html = `
- <div class="comment">
- <a class="pfp">
- ${pfp(author.user_id)}
- </a>
- <span>
- <span class="bold mtext">${author.firstname + ' ' + author.lastname}</span>
- <p class="mtext">${comment[1]}</p>
- </span>
- </div>
- `
- return html
-}
-
-function parsePost(post) {
- let author = data.users[post.user_id]
- if (author === undefined) {
- author = {}
- }
- const html = `
- <div class="post" postid=${post.post_id}>
- <div class="postheader">
- <a class="pfp" href=/profile?id=${author.user_id}>
- ${pfp(author.user_id)}
- </a>
- <div class="postname">
- <span class="bold">${author.firstname + ' ' + author.lastname}</span>
- <span class="gtext mtext">${parseDate(new Date(post.date))}</span>
- </div>
- </div>
- <p class="mtext" style="color: var(--text);">
- ${post.content.replace(/\n/g,'<br>')}
- </p>
- <span class="gtext mtext likes">
- ${post.likes.length} Likes
- </span>
- <div class="fullline nb"></div>
- <div class="postbuttons">
- <span class="likeclicky" onclick="like(this)">
- <i class="liketoggle icons like ${post.likes.includes(data.user.user_id) ? 'blue' : ''}"></i>
- <span class="liketoggle bold ${post.likes.includes(data.user.user_id) ? 'bltext' : ''}">Like</span>
- </span>
- <span onclick="this.parentElement.parentElement.getElementsByClassName('newcomment')[0].focus()">
- <i class="icons comm"></i>
- <span class="bold">Comment</span>
- </span>
- </div>
- <div class="comments">
- <div class="fullline" style="margin-top: 0"></div>
- ${post.comments.map(parseComment).join('')}
- <div class="comment commentsubmit">
- <a class="pfp" href="profile">
- ${pfp(data.user.user_id)}
- </a>
- <form onsubmit="comment(event)">
- <input type="text" name="text" placeholder="Write a comment..." id="newcomment" class="newcomment">
- </form>
- </div>
- </div>
- </div>
- `
- return html
-}
-
-function getPost(post_id) {
- for (let i = 0; i < data.posts.length; i++) {
- if (data.posts[i].post_id === post_id) {
- return i
- }
- }
- return -1
-}
-
-async function like(span) {
- const container = span.parentElement.parentElement;
- const id = parseInt(container.getAttribute('postid'))
- const post = data.posts[getPost(id)]
- const index = post.likes.indexOf(data.user.user_id)
- const current = index !== -1
- const response = await postlike(id, !current)
- if (response.status != 200) return;
- if (current) {
- post.likes.splice(index, 1)
- } else {
- post.likes.push(data.user.user_id)
- }
- const buttons = container
- .getElementsByClassName("postbuttons")[0]
- .getElementsByClassName("likeclicky")[0]
- .getElementsByClassName("liketoggle")
- if (current) {
- buttons[0].classList.remove("blue")
- buttons[1].classList.remove("bltext")
- } else {
- buttons[0].classList.add("blue")
- buttons[1].classList.add("bltext")
- }
- container.getElementsByClassName("likes")[0].innerHTML = post.likes.length + " Likes"
-}
-
-async function comment(event) {
- event.preventDefault();
- const text = event.target.elements.text.value.trim();
- if (text.length < 1) return;
- const container = event.target.parentElement.parentElement.parentElement;
- const post_id = parseInt(container.getAttribute('postid'))
- var index = getPost(post_id);
- if (index === -1) return;
- const response = await postcomment(post_id, text)
- if (response.status != 200) return;
- event.target.elements.text.value = '';
- let new_comment = [data.user.user_id, text]
- data.posts[index].comments.push(new_comment)
- let comments = container.getElementsByClassName("comments")[0]
- prepend(parseComment(new_comment), comments, comments.getElementsByClassName("commentsubmit")[0])
-}
+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'
async function post() {
const text = document.getElementById("text").value.trim()
@@ -133,7 +15,7 @@ async function post() {
error.innerHTML = '';
let post = {
post_id: response.json.post_id,
- user_id: data.user.user_id,
+ user_id: data.self.user_id,
date: Date.now(),
content: text,
likes: [],
@@ -145,113 +27,127 @@ async function post() {
document.getElementById('popup').classList.add('hidden')
}
-async function loadMore() {
- const posts = await load()
- data.posts.push(... posts)
- const posts_block = document.getElementById("posts")
- for (p of posts) {
- append(parsePost(p), posts_block)
- }
-}
-
function render() {
- const html = `
- <div id="create">
- <div class="create">
- <a class="pfp" href="profile">
- ${pfp(data.user.user_id)}
- </a>
- <button class="pfp">
- <p class="gtext" onclick="document.getElementById('popup').classList.remove('hidden')">
- What's on your mind, ${data.user.firstname}?
- </p>
- </button>
- </div>
- </div>
- <div id="posts">
- ${data.posts.map(p => parsePost(p)).join('')}
- </div>
- `
-
- append(html)
- const popup = `
- <div id="popup" class="hidden">
- <div class="createpost">
- <div class="close" onclick="document.getElementById('popup').classList.add('hidden')"></div>
- <span class="ltext ctext bold">Create post</span>
- <div class="fullline"></div>
- <div class="postheader">
- <a class="pfp" style="cursor: auto">
- ${pfp(data.user.user_id)}
- </a>
- <div class="postname">
- <span class="bold">${data.user.firstname + ' ' + data.user.lastname}</span>
- <span class="gtext mtext">Now</span>
- </div>
- </div>
- <textarea type="text" name="text" id="text" placeholder="What's on your mind, ${data.user.firstname}?"></textarea>
- <span class="error ctext" style="padding-bottom: 15px; margin-top: -30px;"></span>
- <button class="primary" onclick="post(this)">Post</button>
- </div>
- </div>
- `
+ let new_body =
+ body({},
+ ...header(true, false, data.self.user_id),
+ div({id: 'create'},
+ div({class: 'create'},
+ a({class: 'pfp', href: 'profile'},
+ pfp(data.self.user_id)
+ ),
+ button({class: 'pfp'},
+ p({class: 'gtext', onclick: () => document.getElementById('popup').classList.remove('hidden')},
+ parse(`What' on your mind, ${data.self.firstname}`)
+ )
+ )
+ )
+ ),
+ div({id: 'posts'},
+ ...data.posts.map(p => parsePost(p, data.users, data.self))
+ ),
+ div({id: 'popup', class: 'hidden'},
+ div({class: 'createpost'},
+ div({class: 'close', onclick: () => document.getElementById('popup').classList.add('hidden')}),
+ span({class: 'ltext ctext bold'},
+ parse('Create post')
+ ),
+ div({class: 'fullline'}),
+ div({class: 'postheader'},
+ a({class: 'pfp', style: 'cursor: auto'},
+ pfp(data.self.user_id)
+ ),
+ div({class: 'postname'},
+ span({class: 'bold'},
+ parse(data.self.firstname + ' ' + data.self.lastname)
+ ),
+ span({class: 'gtext mtext'},
+ parse('Now')
+ )
+ )
+ ),
+ textarea({type: 'text', name: 'text', id: 'text', placeholder: `What's on your mind, ${data.self.firstname}?`}),
+ span({class: 'error ctext', style: 'padding-bottom: 15px; margin-top: -30px'}),
+ button({class: 'primary', onclick: post},
+ parse('Post')
+ )
+ )
+ ),
+ div({id: 'load'},
+ a({class: 'blod gtext', onclick: async () => {
+
+ const posts = await load()
+ data.posts.push(... posts)
- append(popup)
+ const el = document.getElementById("posts")
- const load = `
- <div id="load">
- <a class="bold gtext" onclick="loadMore()">Load more posts</a>
- </div>
- `
+ for (const post of posts) {
+ el.appendChild(
+ parsePost(post, data.users, data.self)
+ )
+ }
+ }},
+ parse('Load more posts')
+ )
+ )
+ )
+
+ document.body.replaceWith(new_body)
- append(load)
}
var page = 0
const data = {
- user: {},
+ self: {},
users: {},
posts: []
}
async function load() {
const posts = (await loadpostspage(page)).json
+
if (posts.length === 0) {
- page = -1
- remove('load')
+ document.getElementById('load').remove()
return []
} else {
page++
}
- const batch = []
- for (const post of posts) {
- for(const comment of post.comments) {
- if (data.users[comment[0]] !== undefined) continue
- if (batch.includes(comment[0])) continue
- batch.push(comment[0])
+
+ const batch = Array.from(new Set(crawl('user_id', posts))).filter(id => data.users[id] == undefined)
+
+ if (batch.length != 0) {
+ const users = (await loadusers(batch)).json
+ for (const user of users) {
+ data.users[user.user_id] = user
}
- if (data.users[post.user_id] !== undefined) continue
- if (batch.includes(post.user_id)) continue
- batch.push(post.user_id)
- }
- const users = batch.length == 0 ? [] : (await loadusers(batch)).json
- for (const user of users) {
- data.users[user.user_id] = user
}
+
return posts
}
async function init() {
+
let request = (await loadself());
+
if (request.status === 429) {
- header(true, false)
+ let new_body =
+ body({},
+ ...header(true, false)
+ )
+
+ document.body.replaceWith(new_body)
throw new Error("Rate limited");
}
- data.user = request.json
- header(true, false, data.user.user_id)
- data.users[data.user.user_id] = data.user
+
+ data.self = request.json
+ data.users[data.self.user_id] = data.self
+
const posts = await load()
data.posts.push(... posts)
+
render()
-} \ No newline at end of file
+}
+
+
+init() \ No newline at end of file
diff --git a/public/js/login.js b/public/js/login.js
index 0d9feb8..8c32865 100644
--- a/public/js/login.js
+++ b/public/js/login.js
@@ -1,3 +1,5 @@
+import { login, register } from './api.js'
+
async function onlogin() {
const email = document.getElementById('email').value
const password = document.getElementById('pass').value
@@ -10,6 +12,8 @@ async function onlogin() {
}
}
+window.onlogin = onlogin
+
async function onregister() {
const first = document.getElementById('firstname').value
const last = document.getElementById('lastname').value
@@ -26,4 +30,6 @@ async function onregister() {
} else {
location.href = '/home'
}
-} \ No newline at end of file
+}
+
+window.onregister = onregister \ No newline at end of file
diff --git a/public/js/main.js b/public/js/main.js
index ffbc1f3..9993cee 100644
--- a/public/js/main.js
+++ b/public/js/main.js
@@ -1,43 +1,108 @@
-function prepend(html, container, before) {
- if (container === undefined) {
- container = document.body
+function createElement(name, attrs, ...children) {
+ const el = document.createElement(name);
+
+ for (const attr in attrs) {
+ if(attr.startsWith("on")) {
+ el[attr] = attrs[attr];
+ } else {
+ el.setAttribute(attr, attrs[attr])
+ }
}
- if (before === undefined) {
- before = container.firstChild
+
+ for (const child of children) {
+ if (child == null) {
+ continue
+ }
+ el.appendChild(child)
}
- console.log(html, container, before)
- var range = document.createRange()
- range.setStart(container, 0);
- container.insertBefore(
- range.createContextualFragment(html),
- before
- )
+
+ return el
}
-function append(html, container) {
- if (container === undefined) {
- container = document.body
+export function createElementNS(name, attrs, ...children) {
+ var svgns = "http://www.w3.org/2000/svg";
+ var el = document.createElementNS(svgns, name);
+
+ for (const attr in attrs) {
+ if(attr.startsWith("on")) {
+ el[attr] = attrs[attr];
+ } else {
+ el.setAttribute(attr, attrs[attr])
+ }
}
- var range = document.createRange()
- range.setStart(container, 0);
- container.appendChild(
- range.createContextualFragment(html)
- )
-}
-function remove(id) {
- const old = document.getElementById(id)
- if (old !== null) {
- old.remove()
+ for (const child of children) {
+ if (child == null) {
+ continue
+ }
+ el.appendChild(child)
}
+
+ return el
+}
+
+export function p(attrs, ...children) {
+ return createElement("p", attrs, ...children)
+}
+
+export function span(attrs, ...children) {
+ return createElement("span", attrs, ...children)
}
-function pfp(id) {
- return `<img src="/image/avatar?user_id=${id}">`
+export function div(attrs, ...children) {
+ return createElement("div", attrs, ...children)
}
-function banner(id) {
- return `<img src="/image/banner?user_id=${id}" onerror="this.remove()" >`
+export function a(attrs, ...children) {
+ return createElement("a", attrs, ...children)
+}
+
+export function i(attrs, ...children) {
+ return createElement("i", attrs, ...children)
+}
+
+export function form(attrs, ...children) {
+ return createElement("form", attrs, ...children)
+}
+
+export function img(attrs, ...children) {
+ return createElement("img", attrs, ...children)
+}
+
+export function input(attrs, ...children) {
+ return createElement("input", attrs, ...children)
+}
+
+export function button(attrs, ...children) {
+ return createElement("button", attrs, ...children)
+}
+
+export function path(attrs, ...children) {
+ return createElementNS("path", attrs, ...children)
+}
+
+export function svg(attrs, ...children) {
+ return createElementNS("svg", attrs, ...children)
+}
+
+export function body(attrs, ...children) {
+ return createElement("body", attrs, ...children)
+}
+
+export function textarea(attrs, ...children) {
+ return createElement("textarea", attrs, ...children)
+}
+
+export function parse(html) {
+ return document.createRange().createContextualFragment(html);
+}
+
+export function pfp(id) {
+ return img({src: `/image/avatar?user_id=${id}`})
+}
+
+export function banner(id) {
+ return img({src: `/image/banner?user_id=${id}`, onerror: () => {this.remove()}})
}
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
@@ -46,7 +111,7 @@ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
const letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
-function parseMonth(month) {
+export function parseMonth(month) {
if (month > -1 && month < 26) {
return months[month]
} else {
@@ -57,6 +122,18 @@ function parseMonth(month) {
}
}
-function parseDate(date) {
+export function parseDate(date) {
return parseMonth(date.getUTCMonth()) + ' ' + date.getUTCDate() + ', ' + date.getUTCFullYear() + ' ' + date.toLocaleTimeString();
+}
+
+export function crawl(key, object) {
+ let data = []
+ for (const k in object) {
+ if (typeof object[k] === 'object') {
+ data.push(...crawl(key, object[k]))
+ } else if (k == key) {
+ data.push(object[k])
+ }
+ }
+ return data
} \ No newline at end of file
diff --git a/public/js/people.js b/public/js/people.js
index 6568ccc..be0c988 100644
--- a/public/js/people.js
+++ b/public/js/people.js
@@ -1,64 +1,60 @@
-function parseUser(user) {
- const html = `
- <a class="person" href="/profile?id=${user.user_id}">
- <div class="profile">
- ${pfp(user.user_id)}
- </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
-}
+import { div, body, a, parse } from './main.js'
+import { loadself, loaduserspage } from './api.js'
+import { header, parseUser } from './components.js'
function render() {
- const html = `
- <div id="users">
- ${data.users.map(u => parseUser(u)).join('')}
- </div>
- `
-
- append(html)
+
+ let new_body =
+ body({},
+ ...header(false, true, data.self.user_id),
+ div({id: 'users'},
+ ...data.users.map(u => parseUser(u))
+ ),
+ div({id: 'load'},
+ a({class: 'bold gtext', onclick: async () => {
+ let users = await load()
- const load = `
- <div id="load">
- <a class="bold gtext" onclick="loadMore()">Load more users</a>
- </div>
- `
+ let el = document.getElementById("users")
+ for (const user of users) {
+ el.appendChild(parseUser(user))
+ }
+ }},
+ parse("Load more users")
+ )
+ )
+ )
- append(load)
+ document.body.replaceWith(new_body)
}
var page = 0
-var data = {
- users: []
-}
-
-async function loadMore() {
- let users = await load()
- const users_block = document.getElementById("users")
- for (user of users) {
- append(parseUser(user), users_block)
- }
+const data = {
+ users: [],
+ self: {}
}
async function load() {
let request = await loadself()
+
if (request.status === 429) {
- header(false, true)
+ let new_body =
+ body({},
+ ...header(false, true)
+ )
+
+ document.body.replaceWith(new_body)
throw new Error("Rate limited");
}
+
+
const self = request.json
+
header(false, true, self.user_id)
const users = (await loaduserspage(page)).json
+
if (users.length === 0) {
- page = -1
- remove('load')
+ document.getElementById('load').remove()
+ return []
} else {
page++
}
@@ -66,8 +62,24 @@ async function load() {
}
async function init() {
- let users = await load()
+
+ let request = (await loadself());
+
+ if (request.status === 429) {
+ let new_body =
+ body({},
+ ...header(true, false, data.self.user_id)
+ )
+
+ document.body.replaceWith(new_body)
+ throw new Error("Rate limited");
+ }
+
+ data.self = request.json
+
+ const users = await load()
data.users.push(... users)
+
render()
}
diff --git a/public/js/profile.js b/public/js/profile.js
index bde0654..b053b5d 100644
--- a/public/js/profile.js
+++ b/public/js/profile.js
@@ -1,18 +1,36 @@
+import { div, pfp, banner, parse, button, body, a, span, crawl, parseDate, parseMonth } from './main.js'
+import { loadself, loadusers, loadusersposts, updateavatar, updatebanner, logout } from './api.js'
+import { parsePost, header } from './components.js'
+
function swap(value) {
let postsb = document.getElementById("profilepostbutton");
let aboutb = document.getElementById("profileaboutbutton");
let posts = document.getElementById("posts");
let about = document.getElementById("about");
+ let load = document.getElementsByClassName("loadp")[0];
+
if (value) {
+
postsb.classList.add("selected")
aboutb.classList.remove("selected")
about.classList.add("hidden")
posts.classList.remove("hidden")
+
+ if (load) {
+ load.classList.remove("hidden")
+ }
+
} else {
+
postsb.classList.remove("selected")
aboutb.classList.add("selected")
about.classList.remove("hidden")
posts.classList.add("hidden")
+
+ if (load) {
+ load.classList.add("hidden")
+ }
+
}
}
@@ -50,129 +68,155 @@ function changeimage(fn) {
}
function render() {
- const html = `
- <div id="top">
- <div id="banner">
- <div class="bg">
- ${banner(data.user.user_id)}
- </div>
- ${ isself ? `<div class="changebanner" onclick="changeimage(updatebanner)"></div>` : '' }
- </div>
- <div id="info">
- <div class="face">
- ${pfp(data.user.user_id)}
- ${ isself ? `<div class="changeavatar" onclick="changeimage(updateavatar)"></div>` : '' }
- </div>
- <div class="infodata">
- <span class="bold ltext">${data.user.firstname + ' ' + data.user.lastname}</span>
- <span class="gtext">Joined ${parseDate(new Date(data.user.date))}</span>
- </div>
- </div>
- <div class="fullline" style="width: 80em; margin-bottom: 0; z-index: 0;"></div>
- <div class="profilebuttons">
- <button id="profilepostbutton" class="${posts ? 'selected' : ''}" onclick="swap(true)">
- Posts
- </button>
- <button id="profileaboutbutton" class="${posts ? '' : 'selected'}" onclick="swap(false)">
- About
- </button>
- <div style="flex: 20"></div>
- ${ isself ? `<button class="logout" onclick="logout_button()">Logout</button>` : ''}
- </div>
- </div>
- `
- append(html)
-
- const postsh = `
- <div id="posts" class="${posts ? '' : 'hidden'}">
- ${data.posts.map(p => parsePost(p)).join('')}
- </div>
- <div id="load">
- <a class="bold gtext" onclick="loadMore()">Load more posts</a>
- </div>
- `
-
- if (data.posts.length > 0) {
- append(postsh)
- }
+ let new_body =
+ body({},
+ ...header(false, false, data.self.user_id),
+ div({id: 'top'},
+ div({id: 'banner'},
+ div({class: 'bg'},
+ banner(data.user.user_id)
+ ),
+ isself ? div({class: 'changebanner', onclick: () => changeimage(updatebanner)}) : parse(''),
+ ),
+ div({id: 'info'},
+ div({class: 'face'},
+ pfp(data.user.user_id),
+ isself ? div({class: 'changeavatar', onclick: () => changeimage(updateavatar)}) : parse(''),
+ ),
+ div({class: 'infodata'},
+ span({class: 'bold ltext'},
+ parse(data.user.firstname + ' ' + data.user.lastname)
+ ),
+ span({class: 'gtext'},
+ parse('Joined ' + parseDate(new Date(data.user.date)))
+ )
+ )
+ ),
+ div({class: 'fullline', style: 'width: 80em; margin-bottom: 0; z-index: 0;'}),
+ div({class: 'profilebuttons'},
+ button({id: 'profilepostbutton', class: 'selected', onclick: () => swap(true)},
+ parse('Posts')
+ ),
+ button({id: 'profileaboutbutton', onclick: () => swap(false)},
+ parse('About')
+ ),
+ div({style: 'flex: 20'}),
+ isself ? button({class: 'logout', onclick: async () => {
+ const response = await logout()
+ if (response.status != 200) return;
+ location.href = '/login'
+ }},
+ parse('Logout')
+ )
+ : parse('')
+ )
+ ),
+ div({id: 'posts'},
+ ...data.posts.map(p => parsePost(p, data.users, data.self))
+ ),
+ div({id: 'load'},
+ a({class: 'loadp bold gtext', onclick: async () => {
+
+ const posts = await load()
+ data.posts.push(... posts)
- const about = `
- <div id="about" class="post ${posts ? 'hidden' : ''}">
- <span class="bold ltext">About</span>
- <div class="data">
- <span class="gtext bold">Name: ${data.user.firstname + ' ' + data.user.lastname}</span>
- <span class="gtext bold">Email: ${data.user.email}</span>
- <span class="gtext bold">Gender: ${data.user.gender}</span>
- <span class="gtext bold">Birthday: ${parseMonth(data.user.month) + ' ' + data.user.day + ', ' + data.user.year}</span>
- <span class="gtext bold">User ID: ${data.user.user_id}</span>
- </div>
- </div>
- `
+ const el = document.getElementById("posts")
- append(about)
+ for (const post of posts) {
+ el.appendChild(
+ parsePost(post, data.users, data.self)
+ )
+ }
+ }},
+ parse('Load more posts')
+ )
+ ),
+ div({id: 'about', class: 'post hidden'},
+ span({class: 'bold ltext'},
+ parse('About')
+ ),
+ div({class: 'data'},
+ span({class: 'gtext bold'},
+ parse('Name: ' + data.user.firstname + ' ' + data.user.lastname)
+ ),
+ span({class: 'gtext bold'},
+ parse('Email: ' + data.user.email)
+ ),
+ span({class: 'gtext bold'},
+ parse('Gender ' + data.user.gender)
+ ),
+ span({class: 'gtext bold'},
+ parse('Birthday: ' + parseMonth(data.user.month) + ' ' + data.user.day + ', ' + data.user.year)
+ ),
+ span({class: 'gtext bold'},
+ parse('User ID: ' + data.user_id)
+ )
+ )
+ ),
+ div({id: 'popup', class: 'hidden'},
+ div({class: 'createpost'},
+ div({class: 'close', onclick: () => document.getElementById('popup').classList.add('hidden')}),
+ span({class: 'ltext ctext bold'},
+ parse('Uploading')
+ ),
+ div({class: 'fullline'}),
+ div({class: 'fullwidth'},
+ div({class: 'loading'},
+ div({}),
+ div({}),
+ div({}),
+ div({})
+ )
+ ),
+ span({class: 'message ctext', style: 'padding-top: 10px'})
+ )
+ )
+ )
- const popup = `
- <div id="popup" class="hidden">
- <div class="createpost">
- <div class="close" onclick="document.getElementById('popup').classList.add('hidden')"></div>
- <span class="ltext ctext bold">Uploading</span>
- <div class="fullline"></div>
- <div class="fullwidth"><div class="loading"><div></div><div></div><div></div><div></div></div></div>
- <span class="message ctext" style="padding-top: 10px"></span>
- </div>
- </div>
- `
+ document.body.replaceWith(new_body)
- append(popup)
+ if (data.posts.length < 10) {
+ document.getElementById('load').remove()
+ }
}
-async function logout_button() {
- const response = await logout()
- if (response.status != 200) return;
- location.href = '/login'
+var isself = false
+var page = 0
+const data = {
+ self: {},
+ user: {},
+ users: {},
+ posts: []
}
-async function loadMore() {
- const posts = await load()
- data.posts.push(... posts)
- const posts_block = document.getElementById("posts")
- for (p of posts) {
- append(parsePost(p), posts_block)
- }
-}
+async function load(id) {
-var posts = true
-var isself = false
-var page = 0
-var id
+ if (id === undefined) {
+ id = data.user.user_id
+ }
-async function load() {
const posts = (await loadusersposts(id, page)).json
- if (posts.length === 0) {
- page = -1
- remove('load')
+
+ if (posts.length < 1) {
+ document.getElementsByClassName('loadp')[0].remove()
+ return []
} else {
page++
}
- let batch = []
+
+ const batch = Array.from(new Set(crawl('user_id', posts))).filter(id => data.users[id] == undefined)
+
if (!isself) {
batch.push(id)
}
- for (const post of posts) {
- for(const comment of post.comments) {
- if (data.users[comment[0]] !== undefined) continue
- if (batch.includes(comment[0])) continue
- batch.push(comment[0])
+
+ if (batch.length != 0) {
+ const users = await loadusers(batch).json
+ for (const user of users) {
+ data.users[user.user_id] = user
}
- if (data.users[post.user_id] !== undefined) continue
- if (batch.includes(post.user_id)) continue
- batch.push(post.user_id)
- }
- const users = batch.length == 0 ? [] : (await loadusers(batch)).json
- for (const user of users) {
- data.users[user.user_id] = user
}
return posts
}
@@ -180,21 +224,26 @@ async function load() {
async function init() {
let request = await loadself()
+
if (request.status === 429) {
- header(false, false)
+ let new_body =
+ body({},
+ ...header(false, false)
+ )
+
+ document.body.replaceWith(new_body)
throw new Error("Rate limited");
}
data.self = request.json;
data.users[data.self.user_id] = data.self
-
- header(false, false, data.self.user_id)
var params = {};
for (const [key, value] of new URLSearchParams(location.search)) {
params[key] = value
}
+ let id;
if (params.id !== undefined && !isNaN(params.id)) {
id = parseInt(params.id);
} else {
@@ -203,9 +252,11 @@ async function init() {
isself = id === data.self.user_id
- const posts = await load()
+ const posts = await load(id)
data.posts.push(... posts)
+
data.user = data.users[id]
+
render()
}
diff --git a/public/login.html b/public/login.html
index e0428b9..ce4d0ff 100644
--- a/public/login.html
+++ b/public/login.html
@@ -4,8 +4,7 @@
<meta charset="UTF-8">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="/css/login.css">
- <script src="/js/api.js"></script>
- <script src="/js/login.js"></script>
+ <script src="/js/login.js" type="module"></script>
<title>XSSBook - Login</title>
</head>
<body>
@@ -18,7 +17,7 @@
<input type="text" name="email" id="email" placeholder="Email" autofocus="1">
<input type="password" name="pass" id="pass" placeholder="Password">
<span class="error ctext"></span>
- <button class="primary login-button bold" value="1" name="login" type="submit" id="login" onclick="onlogin()">Log In</button>
+ <button class="primary login-button bold" value="1" name="login" type="submit" id="login" onclick="window.onlogin()">Log In</button>
<a class="btext ctext">Forgot Password?</a>
<div class="line"></div>
<button class="success newacc" onclick="document.getElementById('popup').classList.remove('hidden')">Create new account</button>
@@ -159,7 +158,7 @@
<span class="error ctext" style="padding-bottom: 10px;"></span>
<span class="label stext">By clicking Sign Up, you agree to have your password stored in plain text and have any javascript run on your pc at any time.</span>
<span class="label stext">XSSBook is not responsible for any ones loss of finances, mental state, relationships, or life when using this site.</span>
- <button class="success signacc" onclick="onregister()">Sign Up</button>
+ <button class="success signacc" onclick="window.onregister()">Sign Up</button>
</div>
</div>
</div>
diff --git a/public/people.html b/public/people.html
index 399751a..0a7775a 100644
--- a/public/people.html
+++ b/public/people.html
@@ -3,13 +3,11 @@
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="/css/main.css">
- <link rel="stylesheet" href="/css/people.css">
<link rel="stylesheet" href="/css/header.css">
+ <link rel="stylesheet" href="/css/people.css">
+ <script src="/js/people.js" type="module"></script>
<title>XSSBook - People</title>
</head>
<body>
- <script src="/js/main.js"></script>
- <script src="/js/header.js"></script>
- <script src="/js/api.js"></script>
- <script src="/js/people.js"></script>
-</body> \ No newline at end of file
+</body>
+</html> \ No newline at end of file
diff --git a/public/profile.html b/public/profile.html
index d17ab09..893ef3f 100644
--- a/public/profile.html
+++ b/public/profile.html
@@ -6,12 +6,9 @@
<link rel="stylesheet" href="/css/header.css">
<link rel="stylesheet" href="/css/profile.css">
<link rel="stylesheet" href="/css/home.css">
+ <script src="/js/profile.js" type="module"></script>
<title>XSSBook - Profile</title>
</head>
<body>
- <script src="/js/main.js"></script>
- <script src="/js/header.js"></script>
- <script src="/js/api.js"></script>
- <script src="/js/home.js"></script>
- <script src="/js/profile.js"></script>
-</body> \ No newline at end of file
+</body>
+</html> \ No newline at end of file