mirror of
https://codeberg.org/ashley/poke.git
synced 2024-12-01 10:27:22 +01:00
convert function
This commit is contained in:
parent
af1efb12d5
commit
4353d1c7d9
1 changed files with 25 additions and 1 deletions
26
server.js
26
server.js
|
@ -81,7 +81,7 @@ const config = {
|
||||||
t_url: "https://t.poketube.fun/", // def matomo url
|
t_url: "https://t.poketube.fun/", // def matomo url
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////// PAGES /////////////
|
///////////// FUNCTIONS /////////////
|
||||||
|
|
||||||
function IsJsonString(str) {
|
function IsJsonString(str) {
|
||||||
try {
|
try {
|
||||||
|
@ -92,6 +92,17 @@ function IsJsonString(str) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function convert(value) {
|
||||||
|
if (value >= 1000000) {
|
||||||
|
value = value / 1000000 + "M";
|
||||||
|
} else if (value >= 1000) {
|
||||||
|
value = value / 1000 + "K";
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
|
|
||||||
|
@ -187,6 +198,17 @@ app.get("/watch", async function (req, res) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nnn = "";
|
||||||
|
|
||||||
|
if (n === "none") {
|
||||||
|
nnn = "";
|
||||||
|
}
|
||||||
|
if (IsJsonString(n)) {
|
||||||
|
if (n !== "none") {
|
||||||
|
nnn = JSON.parse(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var comments = "";
|
var comments = "";
|
||||||
if (n === "none") {
|
if (n === "none") {
|
||||||
comments = "";
|
comments = "";
|
||||||
|
@ -257,12 +279,14 @@ app.get("/watch", async function (req, res) {
|
||||||
r: r,
|
r: r,
|
||||||
qua: q,
|
qua: q,
|
||||||
ip: ip,
|
ip: ip,
|
||||||
|
convert: convert,
|
||||||
wiki: w,
|
wiki: w,
|
||||||
f: f,
|
f: f,
|
||||||
t: config.t_url,
|
t: config.t_url,
|
||||||
optout: t,
|
optout: t,
|
||||||
badges: badges,
|
badges: badges,
|
||||||
comments: comments,
|
comments: comments,
|
||||||
|
n: nnn,
|
||||||
lyrics: "",
|
lyrics: "",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue