Browse Source

Setting up web interface

iam 11 months ago
parent
commit
2a39624064
5 changed files with 46 additions and 29 deletions
  1. 1 1
      info
  2. 2 1
      webserver/app.js
  3. 32 0
      webserver/html/findGame.html
  4. 0 14
      webserver/html/selectGame.html
  5. 11 13
      webserver/routes/findGames.js

File diff suppressed because it is too large
+ 1 - 1
info


+ 2 - 1
webserver/app.js

@@ -23,10 +23,11 @@ app.set('view engine', 'ejs');
23 23
 app.set('views', path.join(__dirname, 'html'));
24 24
 
25 25
 app.use('/', misc);
26
+app.use('/', findGames);
27
+
26 28
 app.use('/contact', misc);
27 29
 app.use('/about', misc);
28 30
 
29
-app.use('/', findGames);
30 31
 /// catch 404 and forward to error handler
31 32
 app.use(function(req, res, next) {
32 33
     var err = new Error('Not Found');

File diff suppressed because it is too large
+ 32 - 0
webserver/html/findGame.html


+ 0 - 14
webserver/html/selectGame.html

@@ -1,14 +0,0 @@
1
-<!DOCTYPE html>
2
-<html lang="en">
3
-    <head>
4
-        <%- include ./headings/header.ejs %>
5
-        <title>Find Game</title>
6
-    </head>
7
-    <body>
8
-        <%- include ./headings/navbar.ejs %>
9
-        <div class="container">
10
-            Games here
11
-        </div>
12
-    </body>
13
-    <%- include ./headings/footer.ejs %>
14
-</html>

+ 11 - 13
webserver/routes/findGames.js

@@ -5,26 +5,24 @@ var fs = require('fs');
5 5
 
6 6
 var baseFilePath = '/../html/'
7 7
 
8
-function findGames()
8
+function findGames(callback_)
9 9
 {
10 10
     fs.readFile('../info', function (err, data) {
11 11
         if (err) throw err;
12
-            console.log(JSON.parse(data));
12
+            callback_(JSON.parse(data));
13 13
     });
14
-    
15
-    return "MOO"
16 14
 }
17 15
 
18 16
 router.get('/findgame', function(req, res) {
19
-    games = findGames();
20
-    
21
-    ejs.renderFile(__dirname + baseFilePath + 'selectGame.html', {active:"Find"}, function(err, result) {
22
-        if (!err) {
23
-            res.end(result);
24
-        } else {
25
-            res.end(err.toString());
26
-            console.log(err);
27
-        }
17
+    findGames(function(games) {
18
+        ejs.renderFile(__dirname + baseFilePath + 'findGame.html', {active:"Find", games:games}, function(err, result) {
19
+            if (!err) {
20
+                res.end(result);
21
+            } else {
22
+                res.end(err.toString());
23
+                console.log(err);
24
+            }
25
+        });
28 26
     });
29 27
 });
30 28