added special text
This commit is contained in:
parent
ca1b8fb324
commit
886178b79d
@ -10,6 +10,9 @@
|
||||
color: lightgreen;
|
||||
}
|
||||
|
||||
.specialtext {
|
||||
color: yellow;
|
||||
}
|
||||
|
||||
#posts > div {
|
||||
background-color: darkgray;
|
||||
|
16
js/posts.js
16
js/posts.js
@ -31,11 +31,17 @@ function filterPost(text) {
|
||||
text = filterMentions(text)
|
||||
return text
|
||||
}
|
||||
function createPost(username,text,time) {
|
||||
function createPost(username,text,time,specialtext) {
|
||||
if(specialtext){
|
||||
specialtext = ` | ${specialtext}`
|
||||
} else {
|
||||
specialtext = ""
|
||||
}
|
||||
const newDiv = document.createElement("div");
|
||||
const newP = document.createElement("p");
|
||||
const newSpan = document.createElement("span");
|
||||
const newSpan2 = document.createElement("span");
|
||||
const newSpan3 = document.createElement("span");
|
||||
|
||||
|
||||
//const newText = document.createTextNode(text);
|
||||
@ -47,12 +53,18 @@ function createPost(username,text,time) {
|
||||
time = time[0] + " " + time[1] + " " + time[2] + " " + time[3] + " " + time[4]
|
||||
if(timedate=="Thu Jan 01 1970 01:00:00 GMT+0100 (Central European Standard Time)")time="unknown time"
|
||||
const newTime = document.createTextNode(` | ${time}`)
|
||||
const newSpecialText = document.createTextNode(specialtext)
|
||||
|
||||
newDiv.classList.add("post");
|
||||
newSpan3.classList.add("specialtext")
|
||||
|
||||
newSpan.appendChild(newUsername)
|
||||
newSpan2.appendChild(newTime)
|
||||
newSpan3.appendChild(newSpecialText)
|
||||
|
||||
newP.appendChild(newSpan)
|
||||
newP.appendChild(newSpan2)
|
||||
newP.appendChild(newSpan3)
|
||||
|
||||
|
||||
newDiv.appendChild(newP)
|
||||
@ -75,7 +87,7 @@ async function main() {
|
||||
document.getElementById("posts").innerHTML = ""
|
||||
last_10_posts.forEach((item, i) => {
|
||||
console.log(item,i);
|
||||
createPost(item.post_user_name,item.post_text,item.post_time)
|
||||
createPost(item.post_user_name,item.post_text,item.post_time,item.post_special_text)
|
||||
});
|
||||
let mentions = document.getElementsByClassName("mention")
|
||||
for (let i = 0; i < mentions.length; i++) {
|
||||
|
@ -265,7 +265,7 @@ router.post("/api/post", async function(req,res) {
|
||||
|
||||
router.get("/api/getPosts/*", async function(req,res) {
|
||||
|
||||
let sql = `select post_user_name,post_text,post_time from zerotwohub.posts where post_id >= ? and post_id <= ? order by post_id desc;`
|
||||
let sql = `select post_user_name,post_text,post_time,post_special_text from zerotwohub.posts where post_id >= ? and post_id <= ? order by post_id desc;`
|
||||
let id = parseInt(req.originalUrl.replace("/api/getPosts/"))
|
||||
if(isNaN(id))id=0
|
||||
let values = [id,id+100]
|
||||
|
Loading…
x
Reference in New Issue
Block a user