diff options
-rw-r--r-- | src/html/admin.html | 37 | ||||
-rw-r--r-- | src/html/index.html | 1 | ||||
-rw-r--r-- | src/html/misc.html | 32 | ||||
-rw-r--r-- | src/html/snake.html | 216 | ||||
-rw-r--r-- | src/server.js | 8 |
5 files changed, 66 insertions, 228 deletions
diff --git a/src/html/admin.html b/src/html/admin.html index a97af06..363f5c0 100644 --- a/src/html/admin.html +++ b/src/html/admin.html @@ -14,13 +14,17 @@ el: '#stats', data: { stats: { session: [], url: [] }, + emails: [], showSessionTable: false, showUrlTable: false, showLogData: false, + showEmailData: false, }, created() { fetch(new Request('/admin/stats')).then(response => response.json()) .then(response => this.stats = response); + fetch(new Request('/admin/emails')).then(response => response.json()) + .then(response => this.emails = response); } }); } @@ -57,12 +61,27 @@ </form> </div> </div> + <div> + <a href="/admin/chess" class="btn btn-primary">Chess</a> + </div> <div id="stats"> <h1>Stats</h1> <div> <input type="checkbox" id="showSession" v-model="showSessionTable"> <label for="showSession">Show Session Stats</label> </div> + <div> + <input type="checkbox" id="showUrl" v-model="showUrlTable"> + <label for="showUrl">Show URL Stats</label> + </div> + <div> + <input type="checkbox" id="showLog" v-model="showLogData"> + <label for="showLog">Show Log</label> + </div> + <div> + <input type="checkbox" id="showEmail" v-model="showEmailData"> + <label for="showEmail">Show Emails</label> + </div> <div v-if="showSessionTable"> {{stats.total}} total sessions <table class="table session-table"> @@ -76,10 +95,6 @@ </tr> </table> </div> - <div> - <input type="checkbox" id="showUrl" v-model="showUrlTable"> - <label for="showUrl">Show URL Stats</label> - </div> <table class="table url-table" v-if="showUrlTable"> <tr> <th>Method</th> @@ -92,10 +107,6 @@ <td>{{item.c}}</td> </tr> </table> - <div> - <input type="checkbox" id="showLog" v-model="showLogData"> - <label for="showLog">Show Log</label> - </div> <table class="table log-table" v-if="showLogData"> <tr> <th>Date</th> @@ -111,6 +122,16 @@ <td>{{item.c}}</td> </tr> </table> + <table class="table" v-if="showEmailData"> + <tr> + <th>Name</th> + <th>Address</th> + </tr> + <tr v-for="item in emails"> + <td>{{item.name}}</td> + <td>{{item.address}}</td> + </tr> + </table> </div> </body> diff --git a/src/html/index.html b/src/html/index.html index 1d57609..ce67842 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -33,6 +33,7 @@ <a href="blog" class="btn btn-primary">Blog</a> <!-- <a href="essay" class="btn btn-primary">Essays</a> (Hello inspector, this page exists, but just isn't very interesting, so I'm removing the link) --> <a href="email" class="btn btn-primary">Email</a> + <a href="misc" class="btn btn-primary">Misc</a> </nav> <div id="feed"></div> diff --git a/src/html/misc.html b/src/html/misc.html new file mode 100644 index 0000000..60455c5 --- /dev/null +++ b/src/html/misc.html @@ -0,0 +1,32 @@ +<!doctype html> +<html lang="en"> + +<head> + <title>Mark's Kitchen</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + <link rel="stylesheet" type="text/css" href="/css/styles.css"> + <link rel="shortcut icon" href="/favicon.ico"> + <script src="/js/feed.js"></script> + <script src="https://cdn.jsdelivr.net/npm/vue"></script> + <!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> --> +</head> + +<body> + + <h1> + <a class="navigation" href="/" title="marks.kitchen"><</a> + Miscellany + </h1> + <div> + <a href="projects" class="btn btn-primary">Projects</a> + </div> + <div> + <a href="chess" class="btn btn-primary">Chess</a> + </div> + <div> + <a href="word-square" class="btn btn-primary">Word Play</a> + </nav> +</body> + +</html>
\ No newline at end of file diff --git a/src/html/snake.html b/src/html/snake.html deleted file mode 100644 index e2158e5..0000000 --- a/src/html/snake.html +++ /dev/null @@ -1,216 +0,0 @@ -<!doctype html> -<html lang="en"> - -<head> - <title>Snake</title> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> - <link rel="stylesheet" type="text/css" href="/css/styles.css"> -</head> - -<body style="padding:0; margin:0; overflow:hidden;"> - <canvas id="canvas"></canvas> - <script> - var gameInterval, canvas, ctx; - var tileCountWidth,tileCountHeight, tileWidth, tileHeight, vx, vy; - var score, t, apple, isGameOver, mouseX, mouseY, length, scaleX, scaleY, selected; - - function init() { - tileCountWidth = 40 - tileCountHeight = 40 - tileWidth = 10; - tileHeight = 10; - snake = { body: [] }; - length = 5; - setRandomCoords(snake); - apple = {}; - setRandomCoords(apple); - vx = 1; - vy = 0; - score = 0; - isGameOver = false; - mouseX = 0; - mouseY = 0; - t = 0; - selected = -1; - gameInterval = setInterval(game, 1000 / 10); - } - - window.onload = function () { - canvas = document.getElementById("canvas"); - ctx = canvas.getContext("2d"); - - document.addEventListener("keydown", keyPush); - document.addEventListener("mousedown", mousePush); - - window.addEventListener('resize', resizeCanvas, false); - window.addEventListener('orientationchange', resizeCanvas, false); - resizeCanvas(); - - init(); - } - - function resizeCanvas() { - canvas.width = window.innerWidth; - canvas.height = window.innerHeight; - scaleX = window.innerWidth/400; - scaleY = window.innerHeight/600; - - if(scaleX/scaleY > 1.3){ - scaleX = scaleY = 1; - } - ctx.scale(scaleX, scaleY); - } - function game() { - update(); - draw(); - } - function draw() { - color("black"); -// ctx.fillRect(0, 0, canvas.width, canvas.height); - ctx.fillRect(0, 0, 400,400); - color("white"); - ctx.fillRect(0, 400, 400, 410); - for (var i = 0; i < snake.body.length; i++) { - ctx.fillRect(snake.body[i].x * tileWidth, snake.body[i].y * tileHeight, tileWidth, tileHeight); - } - color("red"); - ctx.fillRect(apple.x * tileWidth, apple.y * tileHeight, tileWidth, tileHeight); - - font(20); - color("black"); - ctx.fillText("Score: " + score, 20, 450); - - for(var i = 0; i < 4; i++){ - color("#ff9900"); - if(selected == i){ - color("#cc9900") - } - ctx.beginPath(); - ctx.moveTo(300, 500); - ctx.arc(300, 500, 100, (i+1/2)*(Math.PI/2), (i+3/2)*(Math.PI/2)); - ctx.fill(); - color("black"); - ctx.beginPath(); - ctx.moveTo(300, 500); - ctx.arc(300, 500, 100, (i+1/2)*(Math.PI/2), (i+3/2)*(Math.PI/2)); - ctx.stroke(); - } - selected = -1; - - if (isGameOver) { - color("red"); - font(20); - ctx.fillText("Game over!", 160, 200); - font(14); - ctx.fillText("(tap to restart)", 152, 220); - } - } - - function update() { - t++; - snake.x += vx; - snake.y += vy; - if (snake.x < 0 || snake.x >= tileCountWidth || snake.y < 0 || snake.y >= tileCountHeight) - gameOver(); - - // if(snake.some((piece) => {return piece.x = x && piece.y == y;})){ - // gameOver(); - // } - - snake.body.push({ "x": snake.x, "y": snake.y }); - if (snake.x == apple.x && snake.y == apple.y) { - length++; - setRandomCoords(apple); - score += 10 + max(50 - t, 0) - t = 0; - } - - while (snake.body.length > length) { - snake.body.shift(); - } - } - function max(a, b) { - return a > b ? a : b; - } - function keyPush(e) { - if(isGameOver){ - init(); - return; - } - switch (e.keyCode) { - case 37: - if (vx == 1) return; - vx = -1; - vy = 0; - break; - case 38: - if (vy == 1) return; - vx = 0; - vy = -1; - break; - case 39: - if (vx == -1) return; - vx = 1; - vy = 0; - break; - case 40: - if (vy == -1) return; - vx = 0; - vy = 1; - break; - } - } - function mousePush(e) { - mouseX = e.clientX/scaleX - 300; - mouseY = e.clientY/scaleY - 500; - if (Math.sqrt(mouseX * mouseX + mouseY * mouseY) > 100) { - return; - } - - if (Math.abs(mouseX) > Math.abs(mouseY)) { - if (mouseX < 0) { - keyPush({keyCode: 37}) - selected = 1; - } else { - keyPush({keyCode: 39}) - selected = 3; - } - } else { - if (mouseY < 0) { - keyPush({keyCode: 38}) - selected = 2; - } else { - keyPush({keyCode: 40}) - selected = 0; - } - } - } - function setRandomCoords(item) { - item.x = randomInt(tileCountWidth); - item.y = randomInt(tileCountHeight); - } - function randomInt(max) { - return Math.floor(Math.random() * max); - } - function font(size) { - ctx.font = size + "px Courier"; - } - function color(c) { - ctx.fillStyle = c; - } - function gameOver() { - isGameOver = true; - clearInterval(gameInterval); - - const urlParams = new URLSearchParams(window.location.search); - const uid = urlParams.get('uid'); - const mid = urlParams.get('mid'); - - const request = new Request(`/setScore?uid=${uid}&mid=${mid}&score=${score}`); - fetch(request).then(response => console.log("response")); - } - </script> -</body> - -</html>
\ No newline at end of file diff --git a/src/server.js b/src/server.js index b3a39bd..72cc417 100644 --- a/src/server.js +++ b/src/server.js @@ -97,7 +97,7 @@ function setUpRoutes(models, jwtFunctions, database) { server.get('/tags', (req, res) => res.sendFile(__dirname + "/html/tags.html")); server.get('/feed', (req, res) => res.sendFile(__dirname + "/html/feed.html")); server.get('/essay', (req, res) => res.sendFile(__dirname + "/html/essay.html")); - server.get('/snake', (req, res) => res.sendFile(__dirname + "/html/snake.html")); + server.get('/misc', (req, res) => res.sendFile(__dirname + "/html/misc.html")); server.get('/word-square', (req, res) => res.sendFile(__dirname + "/html/word-square.html")); server.get('/chess', (req, res) => res.sendFile(__dirname + "/html/chess.html")); server.get('/admin/chess', async (req, res, next) => res.sendFile(__dirname + "/html/chess.html")); @@ -127,9 +127,9 @@ function setUpRoutes(models, jwtFunctions, database) { //var game = await database.query("select * from chessgames where name = '"+name+"'", { type: database.QueryTypes.SELECT }) res.status(200).send({game:game}); }) - server.get('/setScore', (req, res) => { - request(`http://localhost:8000?${req.url.split("?")[1]}`, function (error, response, body) { - }); + server.get('/admin/emails', async (req, res, next) => { + var emails = await models.emails.findAll(); + res.status(200).send(emails); }) server.get('/admin/stats', async (req, res, next) => { try { |