forked from laurion/fill-it
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeteor-hack.js
42 lines (39 loc) · 931 Bytes
/
meteor-hack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Items = new Meteor.Collection("items");
// Items.insert({data: []})
if (Meteor.isClient) {
Template.table.element = function(){
item = Items.findOne();
return item;
}
Template.table.events({
"click td": function(event){
console.log(this);
item = Items.findOne();
if(item && item.value){
item.value[this.i][this.j].color="blue";
Items.update({_id:item._id},{value:item.value});
}
}
});
Meteor.subscribe("items");
}
if(Meteor.isServer){
Meteor.startup(function () {
// code to run on server at startup
});
Meteor.publish("items", function(){
if(!Items.find().count()){
console.log("adding items");
data = [];
for(i=0;i<20;i++){
var row=[];
for(j=0;j<20;j++){
row.push({i:i,j:j, color: ""});
}
data.push(row);
}
Items.insert({value:data});
}
return Items.find();
});
}