client.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Configure accounts-ui.
  3. */
  4. Accounts.ui.config({
  5. passwordSignupFields: "USERNAME_ONLY"
  6. });
  7. /**
  8. * Template helpers.
  9. */
  10. // helper function that returns all available websites
  11. Template.website_list.helpers({
  12. websites: () => {
  13. return Websites.find({});
  14. }
  15. });
  16. /**
  17. * Template events
  18. */
  19. Template.website_item.events({
  20. "click .js-upvote": function (event) {
  21. // Example of how you can access the id for the website in the database
  22. // (this is the data context for the template)
  23. const websiteId = this._id;
  24. console.log("Up voting website with id " + websiteId);
  25. // Put the code in here to add a vote to a website!
  26. // Prevent the button from reloading the page.
  27. return false;
  28. },
  29. "click .js-downvote": function (event) {
  30. // example of how you can access the id for the website in the database
  31. // (this is the data context for the template)
  32. const websiteId = this._id;
  33. console.log("Down voting website with id " + websiteId);
  34. // Put the code in here to remove a vote from a website!
  35. // Prevent the button from reloading the page
  36. return false;
  37. }
  38. });
  39. Template.website_form.events({
  40. "click .js-toggle-website-form": function () {
  41. $("#website_form").toggle("slow");
  42. },
  43. "submit .js-save-website-form": function (event) {
  44. // here is an example of how to get the url out of the form:
  45. const url = event.target.url.value;
  46. console.log("The url they entered is: " + url);
  47. // put your website saving code in here!
  48. // Stop the form submit from reloading the page
  49. return false;
  50. }
  51. });