Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimeiniesta committed Apr 30, 2012
0 parents commit bcb914d
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions .meteor/.gitignore
@@ -0,0 +1 @@
local
6 changes: 6 additions & 0 deletions .meteor/packages
@@ -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
3 changes: 3 additions & 0 deletions README.md
@@ -0,0 +1,3 @@
# Meteor Pizarra

This is just a simple example I'm using to learn about [Meteor](http://meteor.com/).
3 changes: 3 additions & 0 deletions pizarra.css
@@ -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;}
22 changes: 22 additions & 0 deletions pizarra.html
@@ -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>
31 changes: 31 additions & 0 deletions pizarra.js
@@ -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});
}
}
});
}

0 comments on commit bcb914d

Please sign in to comment.