├── README.md ├── .gitignore ├── package.json ├── views ├── index.html └── location.html ├── public └── javascripts │ └── racer.js ├── LICENSE └── app.js /README.md: -------------------------------------------------------------------------------- 1 | SpeedRun 2 | ======== 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | *.swp 11 | 12 | pids 13 | logs 14 | results 15 | 16 | npm-debug.log 17 | node_modules 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SpeedRun", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node app.js" 7 | }, 8 | "dependencies": { 9 | "express": "3.3.8", 10 | "socket.io": "*", 11 | "ejs": "~0.8.4" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Click the button to get your coordinates:

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /public/javascripts/racer.js: -------------------------------------------------------------------------------- 1 | var socket = io.connect('/'); 2 | 3 | function getLocation() 4 | { 5 | if (navigator.geolocation) 6 | { 7 | navigator.geolocation.getCurrentPosition(sendLocation); 8 | } 9 | else{ 10 | x.innerHTML="Geolocation is not supported by this browser."; 11 | } 12 | } 13 | 14 | function showPosition(position) 15 | { 16 | var x=document.getElementById("demo"); 17 | x.innerHTML="Latitude: " + position.coords.latitude + 18 | "
Longitude: " + position.coords.longitude;longitude 19 | } 20 | 21 | function sendLocation(position) { 22 | //socket.emit('location', getLocation); 23 | socket.emit('location', position); 24 | } 25 | 26 | 27 | 28 | socket.emit('join'); 29 | 30 | 31 | setInterval(function() { 32 | getLocation(); 33 | }, 1000); 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Ian Lozinski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Module dependencies. 3 | */ 4 | 5 | var express = require('express'); 6 | var app = express(); 7 | var http = require('http'); 8 | var path = require('path'); 9 | var server = http.createServer(app); 10 | var io = require('socket.io').listen(server); 11 | 12 | 13 | // all environments 14 | app.set('port', 9090 || process.env.PORT || 8080); 15 | app.set('views', __dirname + '/views'); 16 | app.set('view engine', 'ejs'); 17 | app.use(express.favicon()); 18 | app.use(express.logger('dev')); 19 | app.use(express.bodyParser()); 20 | app.use(express.methodOverride()); 21 | app.use(app.router); 22 | app.use(express.static(path.join(__dirname, 'public'))); 23 | 24 | // development only 25 | if ('development' == app.get('env')) { 26 | app.use(express.errorHandler()); 27 | } 28 | 29 | app.get('/', function(req, res){ 30 | res.sendfile(__dirname + '/views/index.html'); 31 | }); 32 | 33 | app.get('/location', function(req,res){ 34 | res.sendfile(__dirname+ '/views/location.html'); 35 | }); 36 | 37 | server.listen(app.get('port'), function() { 38 | console.log('Express server listening on port ' + app.get('port')); 39 | }); 40 | 41 | 42 | io.sockets.on('connection', function(socket) { 43 | console.log('someone connected'); 44 | 45 | socket.on('location', function(loc) { 46 | console.log(loc); 47 | }); 48 | 49 | }); 50 | 51 | -------------------------------------------------------------------------------- /views/location.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | My Fucking Map 5 | 6 | 7 | 16 | 17 | 141 | 142 | 143 |
144 | 145 | --------------------------------------------------------------------------------