forked from flores/devopsfeud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bigboard.js
70 lines (62 loc) · 1.59 KB
/
bigboard.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Questions = new Meteor.Collection("questions");
if (Meteor.isClient) {
Template.bigboard.answers = function () {
// console.log(Questions.find({}, {answers: {sort: {score: -1, text: 1}}}));
console.log(Questions.find({}, {sort: {score: -1, text: 1}}));
return Questions.find({}, {sort: {score: -1, text: 1}});
};
Template.bigboard.selected_answer = function () {
// var answer = Questions.findOne( {answers: {text: Session.get("selected_answer")}});
var answer = Questions.findOne(Session.get("selected_answer"));
return answer && answer.text;
};
Template.answer.selected = function () {
return Session.equals("selected_answer", this._id) ? "selected" : '';
};
Template.bigboard.events({
'click input.display': function () {
Questions.update(Session.get("selected_answer"), {$set: {display: true}});
}
});
Template.answer.events({
'click': function () {
Session.set("selected_answer", this._id);
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
console.log("i got here");
console.log(Questions.find().count());
if (Questions.find().count() === 0) {
Questions.insert(
// {
// question: "What is an indispensible tool?",
// answers:
[
{
text: "grep",
score: 50,
display: false
},
{
text: "cat",
score: 10,
display: false
},
{
text: "perl",
score: 20,
display: false
},
{
text: "rm -rf /",
score: 100,
display: false
}
]
// }
);
}
});
}