Add card view

master
Kuba Orlik 3 years ago
parent 8270e0c28d
commit e473c4dce3

@ -0,0 +1,53 @@
const { getEmoji } = require("./number-to-emoji");
module.exports = function (id, card) {
return /* HTML */ `<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<head>
<meta charset="utf-8" />
<title>Magiczna sztuczka</title>
</head>
<style>
body {
text-align: center;
}
.card {
border-radius: 4px;
padding: 4px;
}
div {
font-size: 100px;
font-size: 50vh;
height: 50vh;
}
</style>
<script>
window.$ = document.write.bind(document);
</script>
<style>
html {
font-size: 20px;
}
li {
display: none;
}
</style>
<img id="track" style="opacity:0" />
<script>
track.src = \`/track?id=${id}&DNT=\${navigator.doNotTrack}&lang=\${
navigator.language
}&res=\${
window.screen.width + "x" + window.screen.height
}&appCodeName=\${navigator.appCodeName}&appVersion=\${
navigator.appVersion
}&platform=\${navigator.platform}\`;
</script>
<body>
<h1>Twoja karta to:</h1>
<div>${getEmoji(card)}</div>
</body>
</html> `;
};

@ -11,7 +11,6 @@ module.exports = async function getISP(ip_address) {
data += d.toString(); data += d.toString();
}); });
task.on("close", () => { task.on("close", () => {
console.log(data);
resolve( resolve(
data data
.split("\n") .split("\n")

@ -5,6 +5,8 @@ const mount = require("koa-mount");
const { getCard, getEmoji } = require("./number-to-emoji"); const { getCard, getEmoji } = require("./number-to-emoji");
const getISP = require("./get-isp"); const getISP = require("./get-isp");
const mainView = require("./index.html.js");
const cardView = require("./card.html.js");
const router = new Router(); const router = new Router();
@ -15,8 +17,6 @@ static.use(serve("./static"));
app.use(mount("/static", static)); app.use(mount("/static", static));
const mainView = require("./index.html.js");
function* idgen() { function* idgen() {
let i = 1; let i = 1;
while (true) { while (true) {
@ -36,6 +36,15 @@ router.get("/", async (ctx) => {
ctx.body = mainView(_id, _card); ctx.body = mainView(_id, _card);
}); });
router.get("/card", async (ctx) => {
// stream data
ctx.set("content-type", "text/html");
const _id = id.next().value;
const _card = getCard();
id_to_card[_id] = _card;
ctx.body = cardView(_id, _card);
});
const tracks = []; const tracks = [];
router.get("/track", async (ctx) => { router.get("/track", async (ctx) => {

Loading…
Cancel
Save