New loading system, local font!

This commit is contained in:
Bingus_Violet 2023-11-16 22:00:16 -06:00
parent 6800930ea0
commit 8632516c6e
7 changed files with 64 additions and 44 deletions

View file

@ -22,51 +22,65 @@ app.listen(PORT, () => {
})
app.get("/", (req, res) => {
var html = fs.readFileSync(mainpage).toString()
var addedHTML = ""
res.setHeader("X-Content-Type-Options", "")
var statuses = {
"online": {
"text": "Online",
"color": "rgb(100, 255, 100)"
},
"dnd": {
"text": "DND",
"color": "rgb(255, 100, 100)"
},
"idle": {
"text": "Idle",
"color": "rgb(255, 255, 75)"
},
"offline": {
"text": "Offline",
"color": "rgb(125, 125, 125)"
}
}
var html = fs.readFileSync(mainpage).toString()
var checkpoint = ["{LANYARD_STATUS}", "{LANYARD}"]
function io(numb, end=false) {
if (end) {
return html.indexOf(checkpoint[numb]) + checkpoint[numb].length
}
return html.indexOf(checkpoint[numb])
}
res.write(html.substring(0, io(0)))
var statusData = statuses[lanyardData.discord_status]
res.write(`<p style="color: ${statusData.color}">${statusData.text}</p>`)
res.write(`<style>.pfp { border-color: ${statusData.color} !important }</style>`)
res.write(html.substring(io(0, true), io(1)))
if (lanyardData) {
for (let index = 0; index < lanyardData.activities.length; index++) {
const activity = lanyardData.activities[index];
console.log(activity)
if (activity.type == 2) {
addedHTML += `<p class="chip">Listening to on <span style="color: limegreen">${activity.name}</span>: ${activity.details} (by ${activity.state})</p>`
res.write(`<p class="chip">Listening on <a style="color: limegreen">${activity.name}</a>: ${activity.details} (by ${activity.state})</p>`)
} else if (activity.type == 4) {
addedHTML += `<p><em><span style="color: lightgray">"${lanyardData.activities[0].state}"</span> - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}</em></p>`
res.write(`<p><em><span style="color: lightgray">"${lanyardData.activities[0].state}"</span> - ${lanyardData.discord_user.display_name} ${new Date(Date.now()).getFullYear()}</em></p>`)
}
}
var statuses = {
"online": {
"text": "Online",
"color": "rgb(100, 255, 100)"
},
"dnd": {
"text": "DND",
"color": "rgb(255, 100, 100)"
},
"idle": {
"text": "Idle",
"color": "rgb(255, 255, 75)"
},
"offline": {
"text": "Offline",
"color": "rgb(125, 125, 125)"
}
}
var statusData = statuses[lanyardData.discord_status]
addedHTML += `<style>.pfp { border-color: ${statusData.color} !important }</style>`
console.log(lanyardData.activities)
}
html = html.replace("{LANYARD_STATUS}", `<p style="color: ${statusData.color}">${statusData.text}</p>`)
html = html.replace("{LANYARD}", addedHTML)
res.send(html)
console.log(io(checkpoint.length - 1, true))
res.write(html.substring(io(checkpoint.length - 1, true), html.length) + "<p>Thank you for checking out my website <3</p>", () => {
res.end()
})
})
// Lanyard Stuffs