notifications
notifications

file:a/index.html -> file:b/index.html
--- a/index.html
+++ b/index.html
@@ -9,6 +9,10 @@
     We are using node <script>document.write(process.versions.node)</script>,
     Chrome <script>document.write(process.versions.chrome)</script>,
     and Electron <script>document.write(process.versions.electron)</script>.
+
+    <a href="#" id="basic">basic notification</a>
+    <a href="#" id="image">image notification</a>
+
   </body>
 
 <script>
@@ -22,8 +26,8 @@
 menu.append(new MenuItem({ label: 'MenuItem2', type: 'checkbox', checked: true }));
 
 window.addEventListener('contextmenu', function (e) {
-  e.preventDefault();
-  menu.popup(remote.getCurrentWindow());
+    e.preventDefault();
+    menu.popup(remote.getCurrentWindow());
 }, false);
 
 
@@ -72,7 +76,7 @@
     role: 'window',
     submenu: [
       {
-        label: 'Minimize',
+        label: 'Minimize 1',
         accelerator: 'CmdOrCtrl+M',
         role: 'minimize'
       },
@@ -154,6 +158,33 @@
 var menu = Menu.buildFromTemplate(template);
 Menu.setApplicationMenu(menu);
 
+var path = require('path');
+var options = [
+  {
+    title: "Basic Notification",
+    body: "Short message part"
+  },
+  {
+    title: "Content-Image Notification",
+    body: "Short message plus a custom content image",
+    icon: path.join(__dirname, 'app.ico')
+  }
+]
+
+function doNotify(evt) {
+  if (evt.srcElement.id == "basic") {
+    new Notification(options[0].title, options[0]);
+  }
+  else if (evt.srcElement.id == "image") {
+    new Notification(options[1].title, options[1]);
+  }
+}
+
+document.addEventListener('DOMContentLoaded', function() {
+  document.getElementById("basic").addEventListener("click", doNotify);
+  document.getElementById("image").addEventListener("click", doNotify);
+})
+
 </script>
 
 </html>

comments