mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-20 11:00:41 +03:00
111 lines
2.9 KiB
Text
111 lines
2.9 KiB
Text
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<%- include("extra/header", { title: thread.title }) %>
|
|
|
|
<body>
|
|
|
|
<%- include("extra/navbar", {user}) %>
|
|
|
|
|
|
<h1 style="font-size: 35px;">
|
|
<%= thread.title %>
|
|
</h1>
|
|
|
|
<h2 style="display:inline;">By <a href=<%="/users/" + thread.author.id %>> <%= thread.author.name %></a>
|
|
<img class="yuvarlak" src=<%= thread.author.avatar %> alt=<%= thread.author.name %>>
|
|
</h2>
|
|
|
|
<% if (user){ %>
|
|
|
|
<form style="display:inline;" action="/threads/<%= thread.id %>/delete/" method="post">
|
|
</a><button type="submit">DELETE</button>
|
|
</form>
|
|
|
|
<% }; %>
|
|
|
|
<hr>
|
|
<div id="messages">
|
|
<% messages.forEach(message=>{ %>
|
|
<% if (message){ %>
|
|
|
|
<div id="message-<%= message.id %>" style="border: 2px solid #444444; padding: 10px;">
|
|
|
|
<h3 style="float:right;">
|
|
<%=new Date(message.time).toLocaleString() %>
|
|
</h3>
|
|
|
|
<h2>
|
|
<img class="yuvarlak" src=<%=message.author.avatar %> alt=<%= message.author.name %>>
|
|
<a href=<%="/users/" + message.author.id %>> <%= message.author.name %></a>:
|
|
</h2>
|
|
|
|
<h2>
|
|
<%= message.content %>
|
|
</h2>
|
|
|
|
<br>
|
|
|
|
<% if (user){ %>
|
|
|
|
<form style="display:inline;" action="/message/<%= message.id %>/delete/" method="post">
|
|
</a><button type="submit">DELETE</button>
|
|
</form>
|
|
<div style="float: right;">
|
|
<h3 id="count<%= message.id %>" style="display:inline;"><%= message.reactCount %></h3>
|
|
<button style="display:inline;" id="like" value="<%= message.id %>">+🔼</button>
|
|
<button style="display:inline;" id="dislike" value="<%= message.id %>" >-🔽</button>
|
|
</div>
|
|
|
|
|
|
<% } %>
|
|
|
|
|
|
</div>
|
|
|
|
<% } else { %>
|
|
<div id="deleted-message" style="border: 2px solid #444444; padding: 10px;">
|
|
<h1>DELETED MESSAGE</h1>
|
|
</div>
|
|
<% } %>
|
|
<br>
|
|
|
|
<% }); %>
|
|
|
|
<script>
|
|
|
|
|
|
document.addEventListener("click", async e=>{
|
|
if (!e.target.id.includes("like"))return;
|
|
const res = await fetch("/api/messages/"+e.target.value+"/react/" + e.target.id, { method: 'POST' })
|
|
.then(res=>res.json());
|
|
document.getElementById("count"+e.target.value).innerHTML = res.result;
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
</div>
|
|
<hr>
|
|
|
|
|
|
<form id= "send">
|
|
<textarea rows="4" cols="133" name="content"></textarea>
|
|
<input name="threadID" type="hidden" value="<%= thread.id %>"></input>
|
|
|
|
<br>
|
|
<% if (user){ %>
|
|
<button type="submit">Send!</button>
|
|
<%} else {%>
|
|
<button disabled>Login for send</button>
|
|
<% }%>
|
|
|
|
</form>
|
|
<% if (user){ %>
|
|
<script src="/js/send.js"></script>
|
|
<% }%>
|
|
|
|
<%- include("extra/footer") %>
|
|
</body>
|
|
|
|
</html>
|