Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. ///////////////////////////
  2. // both/both.js //
  3. ///////////////////////////
  4. Tasks1 = new Mongo.Collection('tasks1');
  5.  
  6.  
  7. ///////////////////////////
  8. // client/client.js //
  9. ///////////////////////////
  10. Template.login.events({
  11. 'click #logMe': function() {
  12. var credentials = [$('#id').val(), $('#pin').val()];
  13. Meteor.call('logMeIn', credentials);
  14. }
  15. });
  16.  
  17. Template.footer.events({
  18. 'click button': function () {
  19. if ( this.text === "SUBMIT" ) {
  20. var inputs = document.getElementsByTagName('input');
  21. for (var i = 0; i < inputs.length; i++) {
  22. var params = {};
  23. params[inputs[i].name] = inputs[i].value;
  24. Meteor.call('addTasks1', params);
  25. }
  26. }
  27. }
  28. });
  29.  
  30.  
  31. ///////////////////////////
  32. // server/server.js //
  33. ///////////////////////////
  34. Meteor.methods({
  35. logMeIn: function (credentials) {
  36. Accounts.createUser({username: credentials[0], password: credentials[1]});
  37. }
  38. });
  39.  
  40. Meteor.publish('tasks1', function(){
  41. return Tasks1.find({userId: this.userId});
  42. });
  43.  
  44. Meteor.methods({
  45. addTasks1: function (doc) {
  46. if (Meteor.userId()) {
  47. Tasks1.insert(doc);
  48. } else {
  49. throw new Meteor.Error("Not Authorized");
  50. }
  51. }
  52. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement