Permalink
Browse files

Restructured files

  • Loading branch information...
1 parent 4eb4896 commit 7d72bcadd6483c1638f557233544998820a837bb @travishorn committed May 10, 2012
View
@@ -0,0 +1,55 @@
+# node-desktop-notifications
+
+## Description
+Send webkit desktop notifications through Node using web sockets.
+
+## Installation
+
+1. Download the zip/tar file or clone the git repository
+2. Extract and place contents into your `node_modules/` directory.
+
+## Dependencies
+The only dependency is [socket.io][1]. You will also have to know the syntax for emitting custom events in socket.io.
+
+## Usage
+### Server (app.js)
+ var app = require('http').createServer(handler)
+ , io = require('socket.io').listen(app)
+ , fs = require('fs')
+ , notifications = require('../desktop-notifications');
+
+ app.listen(3000);
+ notifications.listen(app);
+
+ function handler (req, res) {
+ if (req.url == '/') {
+ fs.readFile(__dirname + '/index.html', function (err, data) {
+ if (err) {
+ res.writeHead(500);
+ return res.end('Error loading page.');
+ }
+
+ res.writeHead(200);
+ res.end(data);
+ });
+ }
+ }
+
+ io.sockets.on('connection', function (socket) {
+ notifications.notify({
+ socket: socket
+ , icon : 'img/info.png'
+ , title : 'Notification Title'
+ , content : 'Notification content...'
+ , timeout : 10000
+ , onclick : function () { console.log('Clicked.'); }
+ })
+ });
+
+### Client (index.html)
+ <script src="/socket.io/socket.io.js"></script>
+ <script src="/desktop-notifications.js"></script>
+
+Please note that the client will have had to previously allow notifications. You can request permission with `window.webkitNotifications.requestPermission()`. The `requestPermission()` function needs to be called from a user action such as clicking a button or link.
+
+A simple demo that utilizes the code above can be found in the `demo/` directory.
File renamed without changes.
View
@@ -1,7 +1,7 @@
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs')
- , notifications = require('desktop-notifications');
+ , notifications = require('../desktop-notifications');
app.listen(3000);
notifications.listen(app);
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -2,7 +2,7 @@
"name": "desktop-notifications",
"description": "Send webkit desktop notifications through Node using web sockets.",
"version": "1.0",
- "author": "Travis Horn <horn.travis@gmail.com>",
+ "author": "Travis Horn",
"dependencies": {
"socket.io": ">= 0.9.6"
},

0 comments on commit 7d72bca

Please sign in to comment.