mirror of
https://codeberg.org/ashley/poke.git
synced 2024-12-01 07:57:24 +01:00
new trends!
This commit is contained in:
parent
de62a1bc08
commit
29c26bb995
1 changed files with 32 additions and 0 deletions
32
server.js
32
server.js
|
@ -107,6 +107,24 @@ function getFirstLine(text) {
|
|||
return text.substring(0, index);
|
||||
}
|
||||
|
||||
function capitalizeFirstLetter(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
function turntomins(time) {
|
||||
var minutes = Math.floor(time / 60);
|
||||
|
||||
var seconds = time - minutes * 60;
|
||||
|
||||
function str_pad_left(string, pad, length) {
|
||||
return (new Array(length + 1).join(pad) + string).slice(-length);
|
||||
}
|
||||
|
||||
var finalTime =
|
||||
str_pad_left(minutes, "0", 2) + ":" + str_pad_left(seconds, "0", 2);
|
||||
|
||||
return finalTime;
|
||||
}
|
||||
/////////////////////////////////
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
|
@ -633,10 +651,24 @@ app.get("/", async function (req, res) {
|
|||
const trends = await fetch(config.tubeApi + `trending`);
|
||||
const h = await trends.text();
|
||||
const k = JSON.parse(toJson(h));
|
||||
|
||||
if (req.query.tab) var tab = `/?type=${capitalizeFirstLetter(req.query.tab)}`;
|
||||
|
||||
if (!req.query.tab) var tab = "";
|
||||
|
||||
const invtrend = await fetch(
|
||||
`https://inv.vern.cc/api/v1/trending${tab}`
|
||||
).then((res) => res.text());
|
||||
|
||||
const t = JSON.parse(invtrend);
|
||||
|
||||
console.log(invtrend);
|
||||
renderTemplate(res, req, "main.ejs", {
|
||||
k: k,
|
||||
tab: req.query.tab,
|
||||
isMobile: req.useragent.isMobile,
|
||||
inv: t,
|
||||
turntomins,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue