mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-26 05:10:41 +03:00
pages...
This commit is contained in:
parent
e5d4ea92ed
commit
a857e68617
3 changed files with 30 additions and 15 deletions
|
@ -76,7 +76,7 @@ And, you can learn about API in `util/APIDOCS.md`.
|
||||||
| auto-scroll | 🟢 | LOW |
|
| auto-scroll | 🟢 | LOW |
|
||||||
| Multi-theme support | 🔴 | LOW |
|
| Multi-theme support | 🔴 | LOW |
|
||||||
| Search | 🔴 | MEDIUM |
|
| Search | 🔴 | MEDIUM |
|
||||||
| Better view, page support | 🔴 | MEDIUM |
|
| Better view, page support, support message limit correct | 🔴 | MEDIUM |
|
||||||
| Sending message etc. will use fetch API | 🟢 | HIGH |
|
| Sending message etc. will use fetch API | 🟢 | HIGH |
|
||||||
|
|
||||||
## Screenshot
|
## Screenshot
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import request from "./request.js";
|
import request from "./request.js";
|
||||||
|
|
||||||
const messages = document.getElementById("messages");
|
const messages = document.getElementById("messages");
|
||||||
|
let messages_raw = [];
|
||||||
function renderMessage(message) {
|
function renderMessage(message) {
|
||||||
const messageElement = document.createElement("div");
|
const messageElement = document.createElement("div");
|
||||||
messageElement.classList.add("message");
|
messageElement.classList.add("message");
|
||||||
|
@ -16,7 +16,7 @@ function renderMessage(message) {
|
||||||
<a href=${"/users/" + message.author.id}> ${message.author.name}</a>:
|
<a href=${"/users/" + message.author.id}> ${message.author.name}</a>:
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<p>${message.content.replaceAll("\n","<br>")}</p><br>
|
<p>${message.content.replaceAll("\n", "<br>")}</p><br>
|
||||||
<div id="message-delete-${message.id}">
|
<div id="message-delete-${message.id}">
|
||||||
${!message.deleted ?
|
${!message.deleted ?
|
||||||
`<form style="display:inline;">
|
`<form style="display:inline;">
|
||||||
|
@ -40,16 +40,15 @@ function renderMessage(message) {
|
||||||
*/
|
*/
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
||||||
const result = await fetch(`/api/threads/${messages.getAttribute("value")}/messages/`).then(res => res.json());
|
messages_raw = await fetch(`/api/threads/${messages.getAttribute("value")}/messages/`).then(res => res.json());
|
||||||
|
if (messages_raw?.error) {
|
||||||
if (result?.error) {
|
|
||||||
|
|
||||||
document.getElementById("messages").innerHTML
|
document.getElementById("messages").innerHTML
|
||||||
+= '<div class="message"><h1>THIS THREAD HAS NOT GOT ANY MESSAGE</h1></div>';
|
+= '<div class="message"><h1>THIS THREAD HAS NOT GOT ANY MESSAGE</h1></div>';
|
||||||
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
for (const message of result)
|
for (const message of messages_raw)
|
||||||
renderMessage(message);
|
renderMessage(message);
|
||||||
|
|
||||||
window.scrollTo(0, document.body.scrollHeight);
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
|
@ -80,7 +79,8 @@ document.getElementById("send").addEventListener("submit", async e => {
|
||||||
* Button Listener
|
* Button Listener
|
||||||
*/
|
*/
|
||||||
document.addEventListener("click", async e => {
|
document.addEventListener("click", async e => {
|
||||||
// e.preventDefault();
|
let page = 1;
|
||||||
|
// e.preventDefault();
|
||||||
if (e.target.id === "delete_thread") {
|
if (e.target.id === "delete_thread") {
|
||||||
const response = await request("/api/threads/" + e.target.value + "/delete");
|
const response = await request("/api/threads/" + e.target.value + "/delete");
|
||||||
if (response.deleted) {
|
if (response.deleted) {
|
||||||
|
@ -93,9 +93,19 @@ document.addEventListener("click", async e => {
|
||||||
const response = await request(`/api/messages/${e.target.value}/delete`);
|
const response = await request(`/api/messages/${e.target.value}/delete`);
|
||||||
if (response.deleted) {
|
if (response.deleted) {
|
||||||
alert("Message deleted");
|
alert("Message deleted");
|
||||||
document.getElementById("message-delete-" + e.target.value).innerHTML="<h3 style=\"display:inline;\">This message has been deleted</h3>";
|
document.getElementById("message-delete-" + e.target.value).innerHTML = "<h3 style=\"display:inline;\">This message has been deleted</h3>";
|
||||||
}
|
}
|
||||||
} /*else if (e.target.id === "edit_thread") {
|
} else if (e.target.id === "left_page") {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
}else if (e.target.id === "right_page") {
|
||||||
|
e.preventDefault();
|
||||||
|
const response = await request(`/api/messages/${e.target.value}/delete`);
|
||||||
|
if (response.deleted) {
|
||||||
|
alert("Message deleted");
|
||||||
|
document.getElementById("message-delete-" + e.target.value).innerHTML = "<h3 style=\"display:inline;\">This message has been deleted</h3>";
|
||||||
|
}
|
||||||
|
}/*else if (e.target.id === "edit_thread") {
|
||||||
window.location.href = "/threads/<%= thread.id }/edit";
|
window.location.href = "/threads/<%= thread.id }/edit";
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,14 @@
|
||||||
<script>
|
<script>
|
||||||
document.getElementById("message-<%= scroll %>").scrollIntoView();
|
document.getElementById("message-<%= scroll %>").scrollIntoView();
|
||||||
</script>
|
</script>
|
||||||
<!-- <button id="left_page" style=" float: right;" type="submit">PREV</button>
|
|
||||||
|
|
||||||
<button id="right_page" style="display:inline;float: right;" type="submit">NEXT</button>-->
|
<!-- <div style="float: right;">
|
||||||
|
<h3 id="page_count" style="display:inline;">1</h3>
|
||||||
|
<button id="left_page" style=" display:inline;float: right;" type="submit">PREV</button>
|
||||||
|
|
||||||
|
<button id="right_page" style="display:inline;float: right;" type="submit">NEXT</button>
|
||||||
|
</div>-->
|
||||||
|
|
||||||
<%- include("extra/footer") %>
|
<%- include("extra/footer") %>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue