-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplusplus.js
More file actions
82 lines (72 loc) · 1.98 KB
/
Copy pathplusplus.js
File metadata and controls
82 lines (72 loc) · 1.98 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
if (Meteor.isClient) {
Template.router.loggedIn = function(){
return !!Meteor.user();
}
Template.home.plusems = function(){
return Plusems.find();
}
Template.home.events({
'click #temp-create-handle': function () {
var handle = document.getElementById("temp-handle").value;
Meteor.call("add", handle);
},
'click #profile': function () {
Session.set('selected_profile_id', this._id);
Router.go('/profile');
}
})
Template.profile.profile = function () {
return Plusems.findOne({_id: Session.get('selected_profile_id')});
}
Template.profile.events({
'click #plus': function () {
Meteor.call('plus', Session.get('selected_profile_id'), Meteor.userId());
},
'click #minus': function () {
Meteor.call('minus', Session.get('selected_profile_id'), Meteor.userId());
}
})
Template.log.transactions = function () {
return Transactions.find();
}
Accounts.ui.config({
passwordSignupFields: 'USERNAME_ONLY'
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
Meteor.methods({
plus: function (to_id, from_id) {
Plusems.update(to_id, {$inc: {points: 1}});
Transactions.insert(
{
from: from_id,
to: to_id,
time: (new Date()).getTime(),
reason: "placeholder",
plus:true
})
},
minus: function (to_id, from_id) {
Plusems.update(to_id, {$inc: {points: -1}});
Transactions.insert(
{
from: from_id,
to: to_id,
time: (new Date()).getTime(),
reason: "placeholder",
plus:false
})
},
add: function(handle) {
Plusems.upsert({handle:handle}, {$set: {points:0}})
}
});
}
Router.route("", {template:"home"})
Router.route("profile", {template:"profile"})
Router.route("log", {template:"log"})
Plusems = new Mongo.Collection("plusem");
Transactions = new Mongo.Collection("transaction");