diff --git a/googletrendsgame/JQueryReWork/html/footer.html b/googletrendsgame/JQueryReWork/html/footer.html new file mode 100644 index 0000000..262667b --- /dev/null +++ b/googletrendsgame/JQueryReWork/html/footer.html @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/googletrendsgame/JQueryReWork/html/game.html b/googletrendsgame/JQueryReWork/html/game.html new file mode 100644 index 0000000..d375e6a --- /dev/null +++ b/googletrendsgame/JQueryReWork/html/game.html @@ -0,0 +1,54 @@ +
+ +
+
+ +
+
+ +
+ + +
+
Round 4/7
+
+
+ +
+
+
car
+
+ +
+ + + +
You're in dave61's room | 12/20 players
+ Leave Game + +
+ + + +
+
60 seconds
+
    +
  1. + John Daniels + 10,000 points + X +
  2. +
  3. + John Daniels + 10,000 points + X +
  4. +
  5. + John Daniels + 10,000 points + X +
  6. +
+
+
+
\ No newline at end of file diff --git a/googletrendsgame/JQueryReWork/html/header.html b/googletrendsgame/JQueryReWork/html/header.html new file mode 100644 index 0000000..57bff15 --- /dev/null +++ b/googletrendsgame/JQueryReWork/html/header.html @@ -0,0 +1,18 @@ + + + + + + + Trend Spotter | Game + + + + + + + + + + + \ No newline at end of file diff --git a/googletrendsgame/JQueryReWork/html/lobby.html b/googletrendsgame/JQueryReWork/html/lobby.html new file mode 100644 index 0000000..e69de29 diff --git a/googletrendsgame/JQueryReWork/html/mainTemplate.html b/googletrendsgame/JQueryReWork/html/mainTemplate.html new file mode 100644 index 0000000..203b1e1 --- /dev/null +++ b/googletrendsgame/JQueryReWork/html/mainTemplate.html @@ -0,0 +1,5 @@ +{>header} + +{>mainContent} + +{>footer} \ No newline at end of file diff --git a/googletrendsgame/JQueryReWork/server.js b/googletrendsgame/JQueryReWork/server.js index 4b6b311..a7cc500 100644 --- a/googletrendsgame/JQueryReWork/server.js +++ b/googletrendsgame/JQueryReWork/server.js @@ -25,19 +25,58 @@ const PORT = 5000; const whiskers = require('whiskers'); -function fetchHTML(templateContext, templateKey, filename) +function fetchHTMLInTemplateContext(templateContext, templateKey, filename) { - templateContext[templateKey] = fs.readFileSync(filename) + templateContext[templateKey] = fetchFile(filename); +} + +function fetchFile(filename) +{ + return fs.readFileSync(filename); +} + + +function fetchLobby(templateContext) +{ + +} + +function fetchGame(templateContext) +{ + +} + + +function processPage(result, pageHTMLFile, templateFillerFunction) +{ + var templateContext = new Object(); + + + var promises = [ + fetchFile("./html/mainTemplate.html"), + templateFillerFunction(templateContext), + fetchHTMLInTemplateContext(templateContext, "header", "./html/header.html"), + fetchHTMLInTemplateContext(templateContext, "footer", "./html/footer.html"), + fetchHTMLInTemplateContext(templateContext, "mainContent", "./html/" + pageHTMLFile) + ]; + + Promise.all(promises).then(function(resultArray) + { + result.write(whiskers.render(resultArray[0], templateContext)); + result.end(); + }); } app.get('/', (requst, result) => { - result.write(fs.readFileSync("./html/home.html")); - result.end(); + processPage(result, "lobby.html", fetchLobby); }); - +app.get('/game', (request, result)=> +{ + processPage(result, "game.html", fetchLobby); +}); app.use(express.static('css')); app.use(express.static('js'));