add channel list to posts
This commit is contained in:
parent
ed25dffea3
commit
aa42afe092
@ -87,3 +87,13 @@ button {
|
||||
resize: none;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.channelTab {
|
||||
text-align: left;
|
||||
float: left;
|
||||
padding-right: 20px
|
||||
}
|
||||
|
||||
#scriptonly {
|
||||
margin: auto;
|
||||
}
|
||||
|
28
js/posts.js
28
js/posts.js
@ -220,8 +220,6 @@ function unreply() {
|
||||
reply_id = 0
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
var cansendNoti = false
|
||||
|
||||
async function askNotiPerms() {
|
||||
@ -234,8 +232,6 @@ async function firstAsk() {
|
||||
}
|
||||
}
|
||||
|
||||
firstAsk()
|
||||
|
||||
async function mainNoti(user) {
|
||||
if(Notification.permission === 'denied' || Notification.permission === 'default') {
|
||||
await askNotiPerms()
|
||||
@ -262,3 +258,27 @@ if(window.location.href.includes("mention=")) {
|
||||
if(window.location.href.includes("message=")) {
|
||||
document.getElementById("post-text").innerText = `${decodeURIComponent(window.location.href.split("message=")[1])} `
|
||||
}
|
||||
|
||||
async function loadChannels() {
|
||||
// <!-- <p class="channel">- Channel Name -</p> -->
|
||||
|
||||
let channels = await (await fetch("/api/getChannels")).json()
|
||||
let tab = document.getElementById("channelTab")
|
||||
tab.innerHTML = ""
|
||||
for (let i = 0; i < channels.length; i++) {
|
||||
let channelname = channels[i].post_receiver_name
|
||||
let channelp = document.createElement("p")
|
||||
channelp.classList.add("channel")
|
||||
let textnode = document.createTextNode(channelname)
|
||||
channelp.appendChild(textnode)
|
||||
tab.appendChild(channelp)
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
main()
|
||||
firstAsk()
|
||||
loadChannels()
|
||||
}
|
||||
|
||||
init()
|
||||
|
@ -740,7 +740,7 @@ router.get("/api/getPersonalPosts", async function(req,res) {
|
||||
|
||||
router.get("/api/getChannels", async function(req,res) {
|
||||
res.set("Access-Control-Allow-Origin","*")
|
||||
let sql = `select post_receiver_name from ipost.posts where post_is_private = false group by post_receiver_name order by post_id desc;`
|
||||
let sql = `select post_receiver_name from ipost.posts where post_is_private = '0' group by post_receiver_name;`
|
||||
con.query(sql, [], function (err, result) {
|
||||
if (err) throw err;
|
||||
res.json(result)
|
||||
|
@ -32,6 +32,10 @@
|
||||
<button type="button" name="button" id="post-btn" onclick="postMessage()">Post</button>
|
||||
</div>
|
||||
<div class="posts" id="posts"></div>
|
||||
<div class="channelTab" id="channelTab">
|
||||
<!-- <p class="channel">- Channel Name -</p> -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="/js/posts.js"></script>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user