Browse Source

2.1 Created basic microscope project.

Frederic G. MARAND 8 years ago
commit
440f4fe7cf
4 changed files with 39 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 1 0
      microscope.css
  3. 14 0
      microscope.html
  4. 23 0
      microscope.js

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+.meteor

+ 1 - 0
microscope.css

@@ -0,0 +1 @@
+/* CSS declarations go here */

+ 14 - 0
microscope.html

@@ -0,0 +1,14 @@
+<head>
+  <title>microscope</title>
+</head>
+
+<body>
+  <h1>Welcome to Meteor!</h1>
+
+  {{> hello}}
+</body>
+
+<template name="hello">
+  <button>Click Me</button>
+  <p>You've pressed the button {{counter}} times.</p>
+</template>

+ 23 - 0
microscope.js

@@ -0,0 +1,23 @@
+if (Meteor.isClient) {
+  // counter starts at 0
+  Session.setDefault('counter', 0);
+
+  Template.hello.helpers({
+    counter: function () {
+      return Session.get('counter');
+    }
+  });
+
+  Template.hello.events({
+    'click button': function () {
+      // increment the counter when button is clicked
+      Session.set('counter', Session.get('counter') + 1);
+    }
+  });
+}
+
+if (Meteor.isServer) {
+  Meteor.startup(function () {
+    // code to run on server at startup
+  });
+}