Skip to content

Commit

Permalink
Cleaning & correcting comment style
Browse files Browse the repository at this point in the history
  • Loading branch information
Grunkhead committed Apr 30, 2019
1 parent eef306a commit deeb2e0
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 66 deletions.
9 changes: 6 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ const port = 8080

app.set('view engine', 'hbs')

app.use(bodyParser.json()) // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
// To support JSON-encoded bodies.
app.use(bodyParser.json())

// To support URL-encoded bodies.
app.use(bodyParser.urlencoded({
extended: true
}))

app.use(express.static('public'))
app.use(express.static('games'))

// use routes defined in routes file
// Use routes defined in routes file.
app.use('/', router)

app.listen(port, () => console.log(`Arcade server listening on port ${port}!`))
36 changes: 2 additions & 34 deletions controllers/MainController.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,7 @@
let request = require('request')
let fs = require('fs');
let http = require('http');
// let fs = require('fs');
// let http = require('http');

let controller = {}

/* index: function (req, res) {
res.render('index', {})
},
howToPlay: function (req, res) {
// get game title from url params
let gameTitle = req.param('game')
let response = res
// make get request to manifest.json
// Todo: make url less hardcoded
request('http://localhost:8080/' + gameTitle + '/manifest.json', { json: true }, (err, res, body) => {
let errors = ''
if (err) {
errors += err
return console.log(err)
}
let manifest = body
if (!typeof manifest == "object") {
errors += "Manifest is empty or not found"
}
// render template with data from manifest
response.render('buttons', { manifest, errors })
})
}
} */
module.exports = controller
8 changes: 3 additions & 5 deletions controllers/MenuController.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ let controller = {

// Resolve promise when we have result from our fetch.
resolve(body)

}
})
})
Expand All @@ -48,7 +47,6 @@ let controller = {
res.render('index', {
games: games
})

},

gameInstructions: function (req, res) {
Expand All @@ -57,7 +55,7 @@ let controller = {

controller.loadGames().some(game => {

// look if url game title is found in our game list
// Look if url game title is found in our game list.
if (req.params.encodedGameTitle == controller.encodeGameTitle(game.title)) {

selectedGame = game
Expand All @@ -70,10 +68,10 @@ let controller = {
res.render('instructions', { game: selectedGame })
})

// Break the loop, we have found our game
// Break the loop, we have found our game.
return true
} else {
// Continue the loop
// Continue the loop.
return false
}
})
Expand Down
Empty file removed data/filters.json
Empty file.
4 changes: 2 additions & 2 deletions public/css/instructions.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
color: white;
font-family: sans-serif;
}
body{
body {
margin: 0;
}

header{
header {
margin: 0;
background: #673ab7;
box-shadow: 0px 2px 2px 0px black;
Expand Down
12 changes: 5 additions & 7 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ html, body {
box-sizing: border-box;
}

header{
header {
padding: 30px 0px 10px 0px;
text-align: center;
}
header h1{
header h1 {
font-size: 3em;

}
Expand All @@ -22,11 +22,11 @@ header h1{
border: 4px solid rgb(93, 138, 168);
}

.first-menu span{
.first-menu span {
padding: 30px;
}

.second-menu span{
.second-menu span {
padding: 10px;
}

Expand Down Expand Up @@ -85,7 +85,7 @@ header h1{
font-family: 'Press Start 2P', cursive;
}

.selection{
.selection {
border: 4px solid #FFF!important;
}

Expand All @@ -101,8 +101,6 @@ header h1{
animation: AnimationName 10s ease infinite;
}



@-webkit-keyframes AnimationName {
0%{background-position:0% 50%}
50%{background-position:100% 50%}
Expand Down
18 changes: 4 additions & 14 deletions public/js/menu.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
// Get menu selectables of first menu.
firstMenu = document.querySelector('.first-menu');
playerTypes = firstMenu.children;

// Get menu selectables of second menu.
secondMenu = document.querySelector('.second-menu');
gameTypes = secondMenu.children;

// Get menu selectables of thirth menu.
thirthMenu = document.querySelector('.thirth-menu');
games = thirthMenu.children;

// Used for changing the position of the selector between menu's and in-menu.
var menuCounter = 0;
var menuIndex = [playerTypes, gameTypes, games];

// Generate for each menu a cache.
// Generate a cache for each menu.
var menuCache = menuIndex.map(x => {
return 0;
})
Expand All @@ -24,7 +27,6 @@ var upCounterCache = 0;

function initSelector() {
addColorToSelection(counter)
//activeMenu[counter].style.backgroundColor = 'cyan';
}

function cacheDownCounter() {
Expand Down Expand Up @@ -76,7 +78,6 @@ function resetCounter() {
initSelector(playerTypes);

function unselectElement() {
//activeMenu[counter].style.backgroundColor = '';
removeColorFromSelection(counter)
}

Expand All @@ -85,7 +86,6 @@ function selectPreviousElement() {
unselectElement();
counter--;
addColorToSelection(counter)
//activeMenu[counter].style.backgroundColor = 'cyan';
}
}

Expand All @@ -94,7 +94,6 @@ function selectNextElement() {
unselectElement();
counter++
addColorToSelection(counter)
//activeMenu[counter].style.backgroundColor = 'cyan';
}
}

Expand Down Expand Up @@ -125,18 +124,13 @@ function getSelectedGame() {
}

function addColorToSelection(selection){
//activeMenu[selection].style.backgroundColor = 'cyan';
activeMenu[selection].classList.add("selection")
}

function removeColorFromSelection(selection){
//activeMenu[selection].style.backgroundColor = '';
activeMenu[selection].classList.remove("selection")
}




// Listening to the browser which key is pressed.
document.onkeypress = function (evt) {
evt = evt || window.event;
Expand Down Expand Up @@ -171,8 +165,4 @@ document.onkeypress = function (evt) {
window.location.href = url;
}
}

// console.log('CachedCounters: ' + menuCache);
// console.log('Current menuCounter: ' + menuCounter);
// console.log('Current counter: ' + counter);
};
2 changes: 1 addition & 1 deletion views/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
Multiplayer
</span>
</div>

<div class="second-menu">
<span id="0">Action</span>
<span id="1">Strategy</span>
Expand All @@ -52,7 +53,6 @@
<a target="_blank" href="{{ this.instruction_url }}"><span>{{ this.title }}</span></a>
{{/each }}
</div>

</body>

<script src="js/menu.js"></script>
Expand Down

0 comments on commit deeb2e0

Please sign in to comment.