Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkmeelak committed Apr 26, 2012
1 parent f0434bd commit 1dc2b84
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 56 deletions.
43 changes: 1 addition & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1 @@
## Engine.IO app boilerplate

A lightweight boilerplate application for creating real-time application on top of Engine.IO. Fast and easy.


## Easy install

```
git clone git://github.com/martintajur/Engine.IO-app-boilerplate.git
cd Engine.IO-app-boilerplate
make build
node .
```

or, if you'd prefer a one-liner:

```
git clone git://github.com/martintajur/Engine.IO-app-boilerplate.git && cd Engine.IO-app-boilerplate && make build && node .
```


## What does it do?

It lets you kick-start real-time application development with Engine.IO very easily by providing a simple command+data messaging. Basically this boilerplate includes very little in itself. It only provides you with the bare essentials you need to have in order to communicate between server and client using Engine.IO.


## What features does it have?

* Clients who join receive information about other clients that are connected
* Each client is able to set his/her name
* All client names get distributed to other clients
* Easily extendable with your own custom event handlers


## Why did I do this?

I compiled this for a friend and thought it might be useful to share with others as well.


## Licence

The MIT License (http://www.opensource.org/licenses/MIT), Copyright (c) 2012 Martin Tajur
# uss means snake
18 changes: 12 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ var clientsData = {
/*
253673624562: {
id: 253673624562,
name: 'Mike'
},
74747352234243: {
id: 74747352234243,
name: 'John'
},
name: 'Mike',
locations: [
{
'lat': 59.12113,
'lng': 27.01223,
},
{
'lat': 59.12113,
'lng': 27.01223,
},
]
}
*/
};

Expand Down
19 changes: 11 additions & 8 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ $(function() {

// geo
var gpswatch = null;
var locations = new Array;
var locations = new Array();
var dot_radius = 3;

// temp
Expand All @@ -252,7 +252,7 @@ $(function() {
return false;
}

gpswatch = navigator.geolocation.watchPosition(getpos, geterror, {
gpswatch = navigator.geolocation.watchPosition(gpsNewPosition, gpsError, {
maximumAge: 0,
timeout: 10000,
enableHighAccuracy: true
Expand All @@ -262,12 +262,15 @@ $(function() {

};

var getpos = function(position) {
var gpsNewPosition = function(position) {

var lat = parseFloat(position.coords.latitude.toFixed(5)),
lng = parseFloat(position.coords.longitude.toFixed(5))
lng = parseFloat(position.coords.longitude.toFixed(5));

if (locations.length > 0) {
// var selfId = client.selfId();
// console.log(clientsData);
// var last_location = clientsData[client.selfId()][locations][locations.length - 1];
var last_location = locations[locations.length - 1];
distance = distance(last_location.lat, last_location.lng, lat, lng);

Expand All @@ -285,9 +288,9 @@ $(function() {

console.log("locations: " + locations);
console.log("locations.length: " + locations.length);
}
};

var geterror = function(error) {
var gpsError = function(error) {
if (error.code==1) {
alert("User denied geolocation.");
}
Expand All @@ -298,8 +301,8 @@ $(function() {
alert("Timeout expired.");
}
else {
alert("ERROR:"+ err.message);
alert("ERROR:"+ error.message);
}
}
};

});

0 comments on commit 1dc2b84

Please sign in to comment.