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
0 parents
commit bcb914d
Showing
6 changed files
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
local |
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,6 @@ | ||
# Meteor packages used by this project, one per line. | ||
# | ||
# 'meteor add' and 'meteor remove' will edit this file for you, | ||
# but you can also edit it by hand. | ||
|
||
autopublish |
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,3 @@ | ||
# Meteor Pizarra | ||
|
||
This is just a simple example I'm using to learn about [Meteor](http://meteor.com/). |
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,3 @@ | ||
.cell { padding: 6px; margin: 0px; cursor: pointer; text-align: center;} | ||
.cell.true { background-color: black; text-color: black;} | ||
.cell.false { background-color: #eee; text-color: #eee;} |
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,22 @@ | ||
<head> | ||
<title>pizarra</title> | ||
</head> | ||
|
||
<body> | ||
{{> board}} | ||
</body> | ||
|
||
<template name="board"> | ||
<div class="board"> | ||
{{#each cells}} | ||
{{> cell}} | ||
{{/each}} | ||
</div> | ||
</template> | ||
|
||
<template name="cell"> | ||
<span class="cell {{ active }}">·</span> | ||
{{#if at_end_of_row}} | ||
<br /> | ||
{{/if}} | ||
</template> |
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,31 @@ | ||
Cells = new Meteor.Collection("cells"); | ||
|
||
if (Meteor.is_client) { | ||
Template.board.cells = function () { | ||
return Cells.find({}, {sort: {position: 1}}); | ||
}; | ||
|
||
Template.cell.at_end_of_row = function () { | ||
return (((this.position + 1) % 30) == 0) ? true : false; | ||
}; | ||
|
||
Template.cell.events = { | ||
'click': function () { | ||
var cell = Cells.findOne(this._id); | ||
|
||
Cells.update(this._id, {$set: { active: !cell.active}}); | ||
} | ||
}; | ||
} | ||
|
||
// On server startup, create the cells if database is empty | ||
if (Meteor.is_server) { | ||
Meteor.startup(function () { | ||
if (Cells.find().count() === 0) { | ||
Cells.remove({}); | ||
for (var i = 0; i < 900; i++) { | ||
Cells.insert({position: i, active: false}); | ||
} | ||
} | ||
}); | ||
} |