diff --git a/html/js/comment.js b/html/js/comment.js
index c7e93a4..71fd69f 100644
--- a/html/js/comment.js
+++ b/html/js/comment.js
@@ -1,17 +1,87 @@
-function displaycomments() {
- commenting = new metaentry(undefined,"comment:",".content",{"content":
-`Your comment: (no MD)
-
-`})
+class comment {
+ constructor( comment ) {
+ this.selector = ".comments"
+ this.content = comment
+
+ // add
+ // escape body (just to be sure) + newlines | author dosnt has to be escaped cuz its generated by srv (its the ip or later mby reverse dns)
+ comment.body = comment.body.replaceAll("<", "<").replaceAll(">", "<").replaceAll("\n","
")
+
+ // construct time:
+ let date = new Date(this.content.time)
+ let time = String(date.getHours()).padStart(2,"0") + ":"
+ time += String(date.getMinutes()).padStart(2,"0") + ":"
+ time += String(date.getSeconds()).padStart(2,"0") + ":"
+ time += String(date.getMilliseconds()).padStart(3,"0") + " "
+ time += String(date.getDate()).padStart(2,"0") + "-"
+ time += String(date.getMonth()).padStart(2,"0") + "-"
+ time += String(date.getFullYear())
+
+ // construct author hover info
+ let authorinfo = ""
+ try {
+ authorinfo = " (" + this.content.authorinfo.country + ") "
+ } catch {}
+
+ // assemble element
+ let elem = document.createElement("DIV")
+ elem.classList = ["comment"]
+ elem.innerHTML = `
+
+${this.content.author}${authorinfo}
+wrote at ${time}
+
+
+${comment.body}
`
+
+ $( this.selector ).append( elem )
+ }
+
+ reply() {
+ // WIP / planned
+ }
}
-function comment(comment) {
- $.ajax({
- type: "POST",
- url: "/comment",
- data: {
- comment: comment
- },
- dataType: "json"
- })
+function displaycomments() {
+ commenting = new metaentry(undefined, "comment:", ".content",{"content":
+`Your comment: (no MD)
+
+`})
+
+ comments = []
+ comments.push( new metaentry(undefined, "comments:", ".content", {"content":
+`These comments are user generated! they are NOT (actively) moderated!`, "class":"comments"}))
+
+ // load comments:
+ reloadcommenting()
+}
+
+function reloadcommenting() {
+ $(".comments").html("")
+ fetch("/comments?post=" + postDATA.id).then(d=>d.json()).then(data=>{
+ for (i in data.content) {
+ comments.push( new comment( data.content[i] ) )
+ }
+ // not jank boxsizefix:
+ let elem = document.createElement("div")
+ elem.innerHTML = "."
+ elem.classList = ["hidden"]
+ $( ".comments" ).append( elem )
+ })
+}
+
+function sendcomment(comment) {
+ // get ip:
+ let token = Math.floor( Math.random()*10**16 )
+ fetch("//derzombiiie.com/getip.php?settoken=" + token, {mode: "no-cors"}).then(()=>{
+ // comment
+ console.log(postDATA.id, comment, token)
+ $.post("/comments", {
+ post: postDATA.id,
+ body: comment,
+ ip: token
+ }).then(
+ reloadcommenting()
+ )
+ })
}
diff --git a/html/js/entry.js b/html/js/entry.js
index 20c01f5..9df5fae 100644
--- a/html/js/entry.js
+++ b/html/js/entry.js
@@ -46,7 +46,7 @@ class metaentry {
`
${this.title}
-
${this.additional.content}
+
${this.additional.content}
`
element.classList = ["entrybox"]
return element
diff --git a/html/js/posts.js b/html/js/posts.js
index b9b7dec..a85bec6 100644
--- a/html/js/posts.js
+++ b/html/js/posts.js
@@ -6,3 +6,4 @@ $(document).ready(() => {
displayshare()
displaycomments()
})
+
diff --git a/html/posts/index.html b/html/posts/index.html
index dcebf8a..fae8552 100644
--- a/html/posts/index.html
+++ b/html/posts/index.html
@@ -28,4 +28,4 @@