Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

JavaScript style cleanups.

  • Loading branch information...
commit a1438aa3b349dcdce9c10056f61ceccdd7463c7e 1 parent 5c00b95
@briantrice briantrice authored
Showing with 20 additions and 20 deletions.
  1. +4 −4 app.js
  2. +7 −7 social_services.js
  3. +9 −9 zipcodes.js
View
8 app.js
@@ -2,7 +2,7 @@ var couchapp = require('couchapp')
, path = require('path')
;
-ddoc =
+var ddoc =
{ "_id":"_design/app"
, "rewrites" :
[ {"from":"/", "to":"index.html"}
@@ -18,13 +18,13 @@ ddoc =
}
;
-ddoc.spatial = {
+ddoc.spatial = {
cities: function(doc) {
- if(doc.name && doc.geometry && doc.type == "city") {
+ if(doc.name && doc.geometry && doc.type == "city") {
emit(doc.geometry, doc);
}
}
-}
+};
ddoc.validate_doc_update = function (newDoc, oldDoc, userCtx) {
if (oldDoc && userCtx.roles.indexOf('_admin') === -1) {
View
14 social_services.js
@@ -2,7 +2,7 @@ var couchapp = require('couchapp')
, path = require('path')
;
-ddoc = { _id:'_design/social_services'}
+var ddoc = { _id:'_design/social_services'};
ddoc.views = {
@@ -30,22 +30,22 @@ ddoc.views = {
};
-ddoc.spatial = {
+ddoc.spatial = {
by_name: function(doc) {
- if(doc.name && doc.geometry) {
+ if(doc.name && doc.geometry) {
emit(doc.geometry, doc.name);
}
},
-
+
full: function(doc){
if(doc.geometry){
emit(doc.geometry, doc);
}
}
-}
+};
ddoc.lists = {
-
+
geojson: function(head, req) {
var row, out, sep = '\n';
@@ -58,7 +58,7 @@ ddoc.lists = {
if ('callback' in req.query) send(req.query['callback'] + "(");
send('{"type": "FeatureCollection", "features":[');
- while (row = getRow()) {
+ while ((row = getRow())) {
out = '{"type": "Feature", "geometry": ' + JSON.stringify(row.value.geometry);
delete row.value.geometry;
out += ', "properties": ' + JSON.stringify(row.value) + '}';
View
18 zipcodes.js
@@ -2,7 +2,7 @@ var couchapp = require('couchapp')
, path = require('path')
;
-ddoc = { _id:'_design/zipcodes'};
+var ddoc = { _id:'_design/zipcodes'};
ddoc.views = {
@@ -16,8 +16,8 @@ ddoc.views = {
var p1, p2;
for (var i=0; i < points.length; j = i++) {
- var p1 = {x: points[i][1], y: points[i][0]};
- var p2 = {x: points[j][1], y: points[j][0]};
+ p1 = {x: points[i][1], y: points[i][0]};
+ p2 = {x: points[j][1], y: points[j][0]};
area += p1.x * p2.y;
area -= p1.y * p2.x;
}
@@ -35,8 +35,8 @@ ddoc.views = {
var p1, p2;
for (var i=0; i < points.length; j = i++) {
- var p1 = {x: points[i][1], y: points[i][0]};
- var p2 = {x: points[j][1], y: points[j][0]};
+ p1 = {x: points[i][1], y: points[i][0]};
+ p2 = {x: points[j][1], y: points[j][0]};
f = p1.x * p2.y - p2.x * p1.y;
x += (p1.x + p2.x) * f;
y += (p1.y + p2.y) * f;
@@ -45,14 +45,14 @@ ddoc.views = {
f = area(polygon) * 6;
return { 'type': 'Point', 'coordinates': [y/f, x/f] };
};
-
- if(doc.zipcode && doc.geometry) {
+
+ if(doc.zipcode && doc.geometry) {
var one_mile = 1;
var centroid = centroid(doc.geometry);
var lat = centroid.coordinates[1]
, lon = centroid.coordinates[0];
- bbox = (lon - one_mile) + "," + (lat - one_mile) + "," + (lon + one_mile) + "," + (lat + one_mile)
-
+ var bbox = (lon - one_mile) + "," + (lat - one_mile) + "," + (lon + one_mile) + "," + (lat + one_mile);
+
emit(doc.zipcode, {centroid: centroid, bbox: bbox});
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.