Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: petebarber/Balloon
base: 5d3063db5f
...
head fork: petebarber/Balloon
compare: b453516d3d
  • 5 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
3  .gitignore
@@ -1,3 +1,4 @@
.idea
node_modules
-config.json
+config.json
+foo.txt
View
54 App/Client/balloon.html
@@ -1,28 +1,28 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Map1</title>
- <link rel="stylesheet" href="balloon.css" type="text/css">
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
- <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDGjbM4waAX0OkwiK9YVA3IeVUYFBWrsxM&sensor=false"></script>
- <script type="text/javascript" src="common_types.js"></script>
- <script type="text/javascript" src="balloon.js"></script>
-</head>
-<body>
- <div id="banner">
- <form id="findLocationForm" class="bannerElement">
- Find location: <input type="text" id="findLocation"/>
- <input type="submit" value="Locate"/>
- </form>
- <form id="submitLocationForm" class="bannerElement">
- Email: <input type="text" id="finderEmail"/>
- Number: <input type="text" id="balloonId"/>
- <input type="submit" value="Submit balloon location" id="submitLocationButton"/>
- </form>
- <div class="bannerElement">
- <button type="button"/>See all balloon landings</button>
- </div>
- </div>
- <div id="map_canvas"></div>
-</body>
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Map1</title>
+ <link rel="stylesheet" href="balloon.css" type="text/css">
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
+ <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDGjbM4waAX0OkwiK9YVA3IeVUYFBWrsxM&sensor=false"></script>
+ <script type="text/javascript" src="common_types.js"></script>
+ <script type="text/javascript" src="balloon.js"></script>
+</head>
+<body>
+ <div id="banner">
+ <form id="findLocationForm" class="bannerElement">
+ Find location: <input type="text" id="findLocation"/>
+ <input type="submit" value="Locate"/>
+ </form>
+ <form id="submitLocationForm" class="bannerElement">
+ Your email: <input type="text" id="finderEmail"/>
+ Balloon Number: <input type="text" id="balloonId"/>
+ <input type="submit" value="Submit balloon location" id="submitLocationButton"/>
+ </form>
+ <div class="bannerElement">
+ <button type="button"/>See all balloon landings</button>
+ </div>
+ </div>
+ <div id="map_canvas"></div>
+</body>
</html>
View
15 App/Client/balloon.js
@@ -20,7 +20,7 @@ jQuery(function()
function getBaseUrl()
{
- var baseUrl = location.protocol + "//" + location.hostname + ":" + location.port + "/";
+ var baseUrl = location.protocol + "//" + location.hostname + ":" + location.port;
return baseUrl;
}
@@ -106,10 +106,17 @@ function Init(startingPos)
var y = new BalloonFind(finderEmail, balloonId, x.lat(), x.lng());
- $.post(baseURL + '/balloon', JSON.stringify(y), function(){}, 'json');
+ $.post(baseURL + '/api/balloon', JSON.stringify(y), 'json')
+ .success(function()
+ {
+ alert("Thanks for finding a balloon. Please check your email after the 10th of June.");
+ })
+ .error(function(e)
+ {
+ alert("Whoops! Something went wrong:" + e.statusText + "(" + e.status + "). Please try again.");
+ location.reload();
+ });
- // TODO: Add success & error handlers. Error handler has to deal with multiple submissions
- // and bad balloon id.
return false;
}
View
24 App/Server/balloon_server.js
@@ -26,8 +26,7 @@ function getConfig()
function REST(req, res, next)
{
console.log('method:%s, url:%s', req.method, req.url)
- //if (req.method == 'POST' && req.url == '/balloon')
- if (true)
+ if (req.method == 'POST' && req.url == '/balloon')
{
var body = "";
@@ -54,13 +53,9 @@ function REST(req, res, next)
authWithGoogle.insert(sql, authToken,
function()
{
- res.setHeader('Content-Type', 'application/json');
+ res.statusCode = 204; // Success but no content
res.end();
- });
- },
- function(e)
- {
- next();
+ })
})
});
}
@@ -68,13 +63,24 @@ function REST(req, res, next)
next();
}
+function MakeStop(httpErrorCode)
+{
+ return function(req, res)
+ {
+ res.statusCode = httpErrorCode;
+ res.statusMessage = "Hippos are loose in the computer";
+ res.end();
+ }
+}
+
var config = getConfig();
var app = connect()
.use(connect.logger())
.use(connect.static('App/Client'))
.use(connect.static('App/Common'))
- .use(REST);
+ //.use(MakeStop(204))
+ .use('/api', REST);
// TODO: Add .use(myErrorHandler);
http.createServer(app).listen(process.env.PORT || 3000);
View
2  README
@@ -1 +1 @@
-This file was created by JetBrains WebStorm 4.0 for binding GitHub repository
+Single page JS web app. with node.js and google fusion tables back-end. NOTE: This is a project I'm using to teach myself, JavaScript & Node.js. Please don't consider anything in here correct.

No commit comments for this range

Something went wrong with that request. Please try again.