Skip to content

Commit 724e050

Browse files
Jack CarrigJack Carrig
Jack Carrig
authored and
Jack Carrig
committed
validate against search input
1 parent 9a530ea commit 724e050

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

app.js

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ app.get('/', function(req,res) {
7171
else{
7272
res.render('index.jade', {
7373
locals: {
74-
title: 'start a game!',
7574
tags: tags
7675
}
7776
});

public/javascripts/memory-game.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var turn = [];
2-
var socket = io.connect(); // TIP: .connect with no args does auto-discovery
2+
var socket = io.connect();
3+
var allowedSearchKeys = [48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122];
34

45
$(function(){
56

@@ -17,6 +18,13 @@ $(function(){
1718
}
1819
});
1920

21+
// Some search input checking - still need more
22+
$('#search').keypress(function(e) {
23+
if ($.inArray(e.which, allowedSearchKeys) < 0) {
24+
e.preventDefault();
25+
}
26+
});
27+
2028
// Callback for successful AJAX game loading...
2129
var dealCards = function(data) {
2230
var cards = data[0].cards;
@@ -36,7 +44,6 @@ $(function(){
3644
socket.emit('startedGame', {'gameTag': tag});
3745
}
3846

39-
4047
//Start a new game of memory from the start button
4148
$('button#start-btn').click(function(e){
4249

@@ -52,7 +59,7 @@ $(function(){
5259
}
5360
});
5461
});
55-
62+
5663
//Start a new game of memory from Popular search button
5764
$('div#popularGameTags button').live('click', function(e){
5865

public/stylesheets/style.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/stylesheets/style.styl

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ div#search-form.large
5656
label
5757
width 550px
5858
font-size 11px
59-
margin 5px 0 0 5px
59+
margin 5px 0 0 0
60+
text-align center
6061
display inline-block
6162
button
6263
background-color #00ff66

views/index.jade

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ div#container
88
div#search-form.large
99
div.form-input
1010
input(type="text", id="search", placeholder="Popular Photos", tabIndex="1")
11-
label(for="search", tabIndex="2") search your favorite tags to customize your game.
11+
label(for="search", tabIndex="2") search your favorite tags to customize your game (no spaces or symbols)
1212
div.form-button
1313
button#start-btn Play now!
1414
#popularGameTags

views/layout.jade

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
!!!
22
html
33
head
4-
title= 'memory | '+title
4+
title flip me! | Play now
55
link(rel='stylesheet', href='/stylesheets/style.css')
66
script(src='/socket.io/socket.io.js')
77
script(src='/javascripts/jquery-1.7.1.min.js')

0 commit comments

Comments
 (0)