-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f2ff6b
commit 5736f17
Showing
9 changed files
with
91 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
define(['App', 'jquery', 'backbone', 'marionette', 'views/PersonView', 'views/PeopleView', 'views/DesktopHeaderView', 'models/Person', 'collections/People', 'seedrandom'], | ||
function (App, $, Backbone, Marionette, PersonView, PeopleView, DesktopHeaderView, Person, People) { | ||
define(['App', 'jquery', 'backbone', 'marionette', 'views/GameStartView', 'views/GoalView', 'views/PeopleView', 'views/DesktopHeaderView', 'models/Person', 'collections/People', 'seedrandom'], | ||
function (App, $, Backbone, Marionette, GameStartView, GoalView, PeopleView, DesktopHeaderView, Person, People) { | ||
return Backbone.Marionette.Controller.extend({ | ||
initialize:function (options) { | ||
App.headerRegion.show(new DesktopHeaderView()); | ||
}, | ||
//gets mapped to in AppRouter's appRoutes | ||
index: function (hash) { | ||
// Seed randomness with current hash. | ||
Math.seedrandom(hash); | ||
$.getJSON('data.json', function(data, jqXHR, code) { | ||
// Pseudo-randomize and pick 24. | ||
data = data.sort( | ||
function(){ return 0.5 - Math.random(); } | ||
).slice(-24); | ||
// Populate. | ||
App.people = new People(data); | ||
// Pick a slightly more random goal. | ||
Math.seedrandom(hash, true); | ||
var pick = new Person(data[Math.floor(Math.random()*data.length)]); | ||
// Draw :) | ||
App.goalRegion.show(new PersonView({ model: pick })); | ||
start: function() { | ||
App.mainRegion.show(new GameStartView({ | ||
})); | ||
}, | ||
goal: function() { | ||
}, | ||
game: function (hash) { | ||
if (App.hasOwnProperty('people')) { | ||
$('.active').removeClass('active'); | ||
$('#game-link').parent().addClass('active'); | ||
App.mainRegion.show(new PeopleView({ | ||
collection: App.people | ||
})); | ||
}); | ||
} else { | ||
// Seed randomness with current hash. | ||
Math.seedrandom(hash); | ||
$.getJSON('data.json', function(data, jqXHR, code) { | ||
// Pseudo-randomize and pick 24. | ||
data = data.sort( | ||
function(){ return 0.5 - Math.random(); } | ||
).slice(-24); | ||
// Populate. | ||
App.people = new People(data); | ||
// Draw :) | ||
// App.goalRegion.show(new GoalView({hash: hash})); | ||
App.mainRegion.show(new PeopleView({ | ||
collection: App.people | ||
})); | ||
$('.active').removeClass('active'); | ||
$('#game-link').attr('href', '#game/' + hash).parent().addClass('active'); | ||
}); | ||
} | ||
}, | ||
dismissed: function() { | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
<div class="navbar nav"> | ||
<div class="navbar-inner"> | ||
<a class="brand" href="#">Marionette-Require-Boilerplate (MRB)</a> | ||
<a class="brand" href="#">Cara a Cara</a> | ||
<ul class="nav"> | ||
<li class="active"><a href="#">Home</a></li> | ||
<li><a href="#">Elsewhere</a></li> | ||
<li class="active"><a href="#game/new">Novo Jogo</a></li> | ||
<li><a href="#game/" id="game-link">Jogo Atual</a></li> | ||
<li><a href="#game/dismissed">Eliminadas</a></li> | ||
</ul> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="hero-unit"> | ||
<h1>Cara a Cara</h1> | ||
<p>Combine uma nova partida com outro jogador e divirta-se.</p> | ||
<div class="input-append"> | ||
<input type="text" class="form-control" placeholder="Dê um nome para partida."> | ||
<span class="input-group-btn"> | ||
<button class="btn btn-default" type="button">Jogar!</button> | ||
</span> | ||
</div><!-- /input-group --> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="goal {{tagger this}}"> | ||
<div class="img"> <img src="pictures/{{ key }}.jpg"> </div> | ||
<h4>{{ nome }}</h4> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
define( ['App', 'backbone', 'marionette', 'jquery', 'underscore.string', 'models/Model', 'hbs!templates/gamestart'], | ||
function(App, Backbone, Marionette, $, _str, Model, template) { | ||
//ItemView provides some default rendering logic | ||
return Backbone.Marionette.ItemView.extend( { | ||
template: template, | ||
model: new Model({ | ||
mobile: App.mobile | ||
}), | ||
newgame: function(e) { | ||
var hash = _str.slugify(this.$el.find('input').val()); | ||
App.appRouter.navigate('game/' + hash, {trigger: true}); | ||
}, | ||
// View Event Handlers | ||
events: { | ||
"click button": 'newgame' | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
define( ['App', 'backbone', 'marionette', 'jquery', 'models/Person', 'hbs!templates/goal'], | ||
function(App, Backbone, Marionette, $, Person, template) { | ||
//ItemView provides some default rendering logic | ||
return Backbone.Marionette.ItemView.extend({ | ||
template: template, | ||
tagName: 'div', | ||
initialize:function (options) { | ||
// Pick a slightly more random goal. | ||
Math.seedrandom(options.hash, true); | ||
var people = App.people.models; | ||
this.model = new Person(people[Math.floor(Math.random()*people.length)].attributes); | ||
}, | ||
// View Event Handlers | ||
events: { | ||
} | ||
}); | ||
}); |