diff --git a/main.js b/main.js index 82aea64cc30a09762a84d1522451852b14455c71..8ad40f57b3de955b3d4ed891767a29afbf91da40 100644 --- a/main.js +++ b/main.js @@ -35,6 +35,7 @@ client.on('connect', () => { let doors = { 'ucc-door': new DoorInfo(), 'unisfa-door': new DoorInfo(), + 'uwaes-door': new DoorInfo(), }; const update_door_state = (door, state) => { @@ -146,6 +147,15 @@ const server = http.createServer((req, res) => { return send_file(res, 200, fname, 'text/html'); } + if (req.url === '/uwaes') { + if (doors['uwaes-door'].state === null) { + return send_file(res, 500, './pages/uwaes_door_unavail.html', 'text/html'); + } + + const fname = doors['uwaes-door'].state ? './pages/uwaes_door_open.html' : './pages/uwaes_door_closed.html'; + return send_file(res, 200, fname, 'text/html'); + } + if (req.url === '/state/ucc') { if (doors['ucc-door'].state === null) { return send_json(res, 500, null); @@ -162,6 +172,14 @@ const server = http.createServer((req, res) => { return send_json(res, 200, doors['unisfa-door'].state); } + if (req.url === '/state/uwaes') { + if (doors['uwaes-door'].state === null) { + return send_json(res, 500, null); + } + + return send_json(res, 200, doors['uwaes-door'].state); + } + if (req.url === '/opener/ucc') { if (doors['ucc-door'].opener === null) { return send_json(res, 500, null); @@ -186,6 +204,14 @@ const server = http.createServer((req, res) => { return send_file(res, 200, './static/door_unisfa_closed.jpg', 'image/jpeg'); } + if (req.url === '/static/door_uwaes_open.jpg') { + return send_file(res, 200, './static/door_uwaes_open.jpg', 'image/jpeg'); + } + + if (req.url === '/static/door_uwaes_closed.jpg') { + return send_file(res, 200, './static/door_uwaes_closed.jpg', 'image/jpeg'); + } + if (req.url === '/static/style.css') { return send_file(res, 200, './static/style.css', 'text/css'); } diff --git a/pages/uwaes_door_closed.html b/pages/uwaes_door_closed.html new file mode 100644 index 0000000000000000000000000000000000000000..a4424a64e6ab24a71f3c48a7d7d0c92fef2d4635 --- /dev/null +++ b/pages/uwaes_door_closed.html @@ -0,0 +1,23 @@ +<!doctype html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>UWA Esports Door Status</title> + <link rel="stylesheet" href="/static/style.css"> + </head> + <body> + <p><a href="#light">lightmode</a> <a href="#dark">darkmode</a></p> + <h1>UWA Esports Door Status</h1> + <p>The door is currently closed.</p> + <img + src="/static/door_uwaes_closed.jpg" + width="756" + height="1008" + alt="Who is it that lies in wait behind the door?" + title="Who is it that lies in wait behind the door?" + > + <script src="/static/darkmode.js"></script> + </body> +</html> + +<!-- vim: set ts=2 sts=2 sw=2 et: --> diff --git a/pages/uwaes_door_open.html b/pages/uwaes_door_open.html new file mode 100644 index 0000000000000000000000000000000000000000..0fd400eea8e1990d8406546ad30a07dbd2080ba6 --- /dev/null +++ b/pages/uwaes_door_open.html @@ -0,0 +1,23 @@ +<!doctype html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>UWA Esports Door Status</title> + <link rel="stylesheet" href="/static/style.css"> + </head> + <body> + <p><a href="#light">lightmode</a> <a href="#dark">darkmode</a></p> + <h1>UWA Esports Door Status</h1> + <p>The door is currently open!</p> + <img + src="/static/door_uwaes_open.jpg" + width="756" + height="1008" + alt="It is he, wearer of many hats. Beware!" + title="It is he, wearer of many hats. Beware!" + > + <script src="/static/darkmode.js"></script> + </body> +</html> + +<!-- vim: set ts=2 sts=2 sw=2 et: --> diff --git a/pages/uwaes_door_unavail.html b/pages/uwaes_door_unavail.html new file mode 100644 index 0000000000000000000000000000000000000000..92c30ab9923aa308b68f165bd838b4fbaad40686 --- /dev/null +++ b/pages/uwaes_door_unavail.html @@ -0,0 +1,16 @@ +<!doctype html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <title>UWA Esports Door Status</title> + <link rel="stylesheet" href="/static/style.css"> + </head> + <body> + <p><a href="#light">lightmode</a> <a href="#dark">darkmode</a></p> + <h1>UWA Esports Door Status</h1> + <p>The door sensor is currently unavailable. Sorry :-(</p> + <script src="/static/darkmode.js"></script> + </body> +</html> + +<!-- vim: set ts=2 sts=2 sw=2 et: --> diff --git a/static/door_uwaes_closed.jpg b/static/door_uwaes_closed.jpg new file mode 100644 index 0000000000000000000000000000000000000000..53cf3a7d06980354b2797ae30e2fd71554753ad7 Binary files /dev/null and b/static/door_uwaes_closed.jpg differ diff --git a/static/door_uwaes_open.jpg b/static/door_uwaes_open.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3e6c8b8cbcdcfd302a4cee655d9f309ad18bb088 Binary files /dev/null and b/static/door_uwaes_open.jpg differ