backup
This commit is contained in:
1 parent
46e9a54a20
commit
04773e50fc
10 files changed
+127
-38
No files matched your search
+27
-3
@@ -1,9 +1,13 @@
|
||||
const express = require("express");
|
||||
const path = require("path");
|
||||
const routes = require("./views/routes");
|
||||
|
||||
const port = 3000;
|
||||
|
||||
// Init App
|
||||
const app = express();
|
||||
|
||||
app.set("view engine", "pug");
|
||||
// Static Files
|
||||
app.use(express.static("public"));
|
||||
app.use("/css", express.static(__dirname + "public/css "));
|
||||
@@ -11,11 +15,31 @@ app.use("/js", express.static(__dirname + "public/js "));
|
||||
app.use("/img", express.static(__dirname + "public/img "));
|
||||
|
||||
// Home Route
|
||||
// for (route of routes) {
|
||||
// // console.log(route);
|
||||
// app.get(route.link, function (req, res) {
|
||||
// console.log(req.url);
|
||||
// console.log(route);
|
||||
// res.render(route.renderFile, routes);
|
||||
// });
|
||||
// }
|
||||
app.get("/", function (req, res) {
|
||||
res.sendFile(__dirname + "/views/index.html");
|
||||
res.render("index", routes);
|
||||
});
|
||||
app.get("/flasher", function (req, res) {
|
||||
res.render("flasher", routes);
|
||||
});
|
||||
app.get("/p_generator", function (req, res) {
|
||||
res.render("p_generator", routes);
|
||||
});
|
||||
app.get("/pcb_panel_bom", function (req, res) {
|
||||
res.render("pcb_panel_bom", routes);
|
||||
});
|
||||
app.get("/invoice_sign", function (req, res) {
|
||||
res.render("invoice_sign", routes);
|
||||
});
|
||||
|
||||
// Start Server
|
||||
app.listen(3001, function () {
|
||||
console.log("Server started on port 3000...");
|
||||
app.listen(port, function () {
|
||||
console.log(`Server started on port ${port}...`);
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
const saltMaster = "xG7t;a$LN=D5";
|
||||
const saltAdmin = "mXA4H_xb$g)c";
|
||||
|
||||
function hash(m, salt) {
|
||||
var result = "";
|
||||
if (m.length != 24) throw "Invalid id";
|
||||
for (var i = 0; i < 12; i++) {
|
||||
//console.log(x.charAt(i));
|
||||
playground = 0;
|
||||
playground += salt.charCodeAt(i);
|
||||
playground ^= m.charCodeAt(i);
|
||||
playground ^= m.charCodeAt(i + 12);
|
||||
playground &= 0xff;
|
||||
playground %= 10;
|
||||
result += playground.toString();
|
||||
}
|
||||
// console.log(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
function getKeys(uid) {
|
||||
var keys;
|
||||
try {
|
||||
keys = {
|
||||
User: hash(uid, saltMaster),
|
||||
Admin: hash(uid, saltAdmin),
|
||||
};
|
||||
} catch (error) {
|
||||
keys = { err: "Invalid id" };
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
extends layout.pug
|
||||
block content
|
||||
h1 flasher
|
||||
@@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Anka Anvil</title>
|
||||
</head>
|
||||
<body>
|
||||
HEllo2
|
||||
<div id="terminal"></div>
|
||||
<script src="js/ss.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,21 +1,8 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title Anka Anvil
|
||||
body
|
||||
h1 #{title}
|
||||
h2 asdasd
|
||||
h2#terminal
|
||||
h1= title
|
||||
div= foo
|
||||
div
|
||||
label Bar
|
||||
input(
|
||||
type='text'
|
||||
name='city'
|
||||
placeholder='start typing...'
|
||||
)
|
||||
input(type='submit' id='submitbtn' value='Submit')
|
||||
script.
|
||||
document.addEventListener('keydown', event => {console.log("Bleep!")})
|
||||
document.getElementById('submitbtn').addEventListener('click', () => doSomething())
|
||||
extends layout.pug
|
||||
block scripts
|
||||
script(src='/jquery.js')
|
||||
script(src='/pets.js')
|
||||
|
||||
block content
|
||||
h1 hello world from index
|
||||
p hi
|
||||
@@ -0,0 +1,3 @@
|
||||
extends layout.pug
|
||||
block content
|
||||
h1 invoice signer
|
||||
@@ -0,0 +1,15 @@
|
||||
html
|
||||
head
|
||||
title My Site - #{title}
|
||||
block scripts
|
||||
script(src='/jquery.js')
|
||||
body
|
||||
ul
|
||||
each route in routes
|
||||
li
|
||||
a(href=route.link)= route.name
|
||||
|
||||
block content
|
||||
block foot
|
||||
#footer
|
||||
p some footer content
|
||||
@@ -0,0 +1,19 @@
|
||||
extends layout.pug
|
||||
block scripts
|
||||
script(src='/js/pGenerator.js')
|
||||
block content
|
||||
h1 p_generator
|
||||
p UID:
|
||||
input(id="in-id" type="text" name="imdb" placeholder="please input your device id")
|
||||
button(onclick='clickme()') get keys
|
||||
p
|
||||
#response
|
||||
script.
|
||||
function clickme() {
|
||||
var id = document.getElementById("in-id");
|
||||
console.log(id.value);
|
||||
var keys = getKeys(id.value);
|
||||
console.log(keys);
|
||||
var resp = document.getElementById("response");
|
||||
resp.innerHTML = JSON.stringify(keys);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
extends layout.pug
|
||||
block content
|
||||
h1 pcb panelizer
|
||||
@@ -0,0 +1,17 @@
|
||||
routes = [
|
||||
{ name: "Homepage", renderFile: "index", link: "/" },
|
||||
{ name: "Flasher", renderFile: "flasher", link: "/flasher" },
|
||||
{
|
||||
name: "Password Generator",
|
||||
renderFile: "p_generator",
|
||||
link: "/p_generator",
|
||||
},
|
||||
{
|
||||
name: "PCB Panel BOM generator",
|
||||
renderFile: "pcb_panel_bom",
|
||||
link: "/pcb_panel_bom",
|
||||
},
|
||||
{ name: "Invoice Signer", renderFile: "invoice_sign", link: "/invoice_sign" },
|
||||
];
|
||||
|
||||
module.exports = routes;
|
||||
Reference in new issue
Block a user