diff --git a/share-a-bike/app/assistants/main-assistant.js b/share-a-bike/app/assistants/main-assistant.js
index cd9d3c9..7bf3320 100644
--- a/share-a-bike/app/assistants/main-assistant.js
+++ b/share-a-bike/app/assistants/main-assistant.js
@@ -4,6 +4,8 @@ function MainAssistant(argFromPusher) {
MainAssistant.prototype = {
setup: function() {
Ares.setupSceneAssistant(this);
+
+ this.radius = 0.5;
},
cleanup: function() {
Ares.cleanupSceneAssistant(this);
@@ -14,6 +16,8 @@ MainAssistant.prototype = {
// Start Spinning
this.showSpinner(true);
+ // Clear List
+ this.controller.setWidgetModel("kioskList", {items:[]});
// API URL for BCycle
var url = 'http://api.bcycle.com/services/mobile.svc/ListKiosks';
gpsLatitude = 0;
@@ -95,35 +99,26 @@ MainAssistant.prototype = {
return d;
};
- var closestKiosks = [];
- var nClosest = 5;
+ var sortByDistance = function(kiosk1, kiosk2) {
+ var d1 = calcDistance(latitude, longitude, kiosk1.Location.Latitude, kiosk1.Location.Longitude);
+ var d2 = calcDistance(latitude, longitude, kiosk2.Location.Latitude, kiosk2.Location.Longitude);
+
+ return d1 - d2;
+ };
- // Initialize an empty set of kiosks
- for(var i = 0; i < nClosest; i++) {
- closestKiosks[i] = null;
- }
+ var closestKiosks = [];
// Loop through the kiosks
for(i = 0; i < kioskResult.responseJSON.d.list.length; i++) {
var kiosk = kioskResult.responseJSON.d.list[i];
- for(var j = 0; j < closestKiosks.length; j++) {
- if(closestKiosks[j] === null) {
- closestKiosks[j] = kiosk;
- break;
- } else {
- var d1 = calcDistance(latitude, longitude, closestKiosks[j].Location.Latitude, closestKiosks[j].Location.Longitude);
- var d2 = calcDistance(latitude, longitude, kiosk.Location.Latitude, kiosk.Location.Longitude);
-
- if(d2 < d1) {
- // Swap
- var temp = kiosk;
- kiosk = closestKiosks[j];
- closestKiosks[j] = temp;
- }
- }
+ var d1 = calcDistance(latitude, longitude, kiosk.Location.Latitude, kiosk.Location.Longitude);
+ if(d1 < this.radius) {
+ closestKiosks.push(kiosk);
}
}
+ closestKiosks.sort(sortByDistance);
+
var kiosks = [];
for(i = 0; i < closestKiosks.length; i++) {
d = calcDistance(latitude, longitude, closestKiosks[i].Location.Latitude, closestKiosks[i].Location.Longitude);
@@ -157,5 +152,9 @@ MainAssistant.prototype = {
gps: this.gpsCoord
};
this.controller.stageController.pushScene('mapScene', argToScene);
+ },
+ radiusSelectorChange: function(inSender, event) {
+ this.radius = event.value;
}
+
};
\ No newline at end of file
diff --git a/share-a-bike/app/views/main/main-chrome.js b/share-a-bike/app/views/main/main-chrome.js
index 0acff94..8dd0a85 100644
--- a/share-a-bike/app/views/main/main-chrome.js
+++ b/share-a-bike/app/views/main/main-chrome.js
@@ -23,7 +23,6 @@ opus.Gizmo({
},
{
name: "scroller1",
- mode: "free",
scrollPosition: {
left: 0,
top: 0
@@ -43,7 +42,7 @@ opus.Gizmo({
items: [],
useSampleData: false,
title: undefined,
- itemHtml: "
\n
\n
#{name}
\n
#{address}
\n
\n
\n
#{distance}
\n
#{bikes}B #{docks}D
\n
\n
",
+ itemHtml: "\n
\n
\n #{name}\n
\n
\n #{address}\n
\n
\n #{distance} | #{bikes} bikes | #{docks} docks\n
\n
\n
",
swipeToDelete: false,
rowTapHighlight: false,
rowFocusHighlight: false,
@@ -55,14 +54,87 @@ opus.Gizmo({
]
},
{
- name: "panel1",
- layoutKind: "hbox",
+ name: "panel2",
dropTarget: true,
type: "Palm.Mojo.Panel",
l: 0,
t: 391,
- h: 60,
+ h: "120",
controls: [
+ {
+ name: "panel1",
+ layoutKind: "hbox",
+ dropTarget: true,
+ type: "Palm.Mojo.Panel",
+ l: 0,
+ t: 0,
+ h: 60,
+ controls: [
+ {
+ name: "findButton",
+ ontap: "findButtonTap",
+ disabled: undefined,
+ label: "Find",
+ type: "Palm.Mojo.ActivityButton",
+ l: 0,
+ t: 0,
+ h: "100%"
+ },
+ {
+ name: "group1",
+ dropTarget: true,
+ label: "",
+ type: "Palm.Mojo.Group",
+ l: 320,
+ t: 0,
+ h: "64",
+ styles: {
+ bgColor: ""
+ },
+ controls: [
+ {
+ name: "row1",
+ dropTarget: true,
+ type: "Palm.Mojo.Row",
+ l: 0,
+ t: 0,
+ h: "auto",
+ controls: [
+ {
+ name: "listSelector3",
+ value: 0.5,
+ choices: [
+ {
+ label: "1/4 Mile",
+ value: "0.25"
+ },
+ {
+ label: "1/2 Mile",
+ value: "0.5"
+ },
+ {
+ label: "3/4 Mile",
+ value: "0.75"
+ },
+ {
+ label: "1 Mile",
+ value: "1"
+ }
+ ],
+ label: "",
+ onchange: "radiusSelectorChange",
+ type: "Palm.Mojo.ListSelector",
+ h: "48",
+ styles: {
+ bgColor: ""
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
{
name: "mapButton",
ontap: "mapButtonTap",
@@ -70,16 +142,7 @@ opus.Gizmo({
label: "Map",
type: "Palm.Mojo.Button",
l: 0,
- t: 0
- },
- {
- name: "findButton",
- ontap: "findButtonTap",
- disabled: undefined,
- label: "Find",
- type: "Palm.Mojo.ActivityButton",
- l: 320,
- t: 0
+ t: 60
}
]
}
diff --git a/share-a-bike/app/views/mapScene/mapScene-chrome.js b/share-a-bike/app/views/mapScene/mapScene-chrome.js
index 6e0b3a0..8a38126 100644
--- a/share-a-bike/app/views/mapScene/mapScene-chrome.js
+++ b/share-a-bike/app/views/mapScene/mapScene-chrome.js
@@ -8,11 +8,12 @@ opus.Gizmo({
},
chrome: [
{
- name: "header1",
- label: "Nearby Kiosks",
- type: "Palm.Mojo.Header",
+ name: "pageHeader1",
+ title: "Kiosks Map",
+ subtitle: "",
+ type: "Palm.Mojo.PageHeader",
l: 0,
- t: 0
+ t: 49
},
{
name: "kioskMap",
diff --git a/share-a-bike/appinfo.json b/share-a-bike/appinfo.json
index 3212979..6e91f81 100644
--- a/share-a-bike/appinfo.json
+++ b/share-a-bike/appinfo.json
@@ -1,6 +1,6 @@
{
"id": "com.mikeshoup.share-a-bike",
- "version": "0.1.2",
+ "version": "0.1.3",
"vendor": "Mike Shoup",
"type": "web",
"main": "index.html",
diff --git a/share-a-bike/sources.json b/share-a-bike/sources.json
index 6347a3d..13b616d 100644
--- a/share-a-bike/sources.json
+++ b/share-a-bike/sources.json
@@ -17,5 +17,13 @@
{
"source": "app/views/mapScene/mapScene-chrome.js",
"scenes": "mapScene"
+ },
+ {
+ "source": "app/assistants/preferences-assistant.js",
+ "scenes": "preferences"
+ },
+ {
+ "source": "app/views/preferences/preferences-chrome.js",
+ "scenes": "preferences"
}
]
\ No newline at end of file
diff --git a/share-a-bike/stylesheets/style.css b/share-a-bike/stylesheets/style.css
index fe3fda5..b90f20c 100644
--- a/share-a-bike/stylesheets/style.css
+++ b/share-a-bike/stylesheets/style.css
@@ -1,27 +1,22 @@
-.kiosk_left_col {
- float: left;
- padding-left: 5px;
+.kiosk_container {
+ padding: 5px;
}
-.kiosk_right_col {
- float: right;
- padding-right: 5px;
-}
-
.kiosk_name {
font-weight: bold;
- font-size: 1em;
+ font-size: 22px;
+ width: 100%;
}
-.kiosk_distance {
- font-size: 1em;
+.kiosk_stats {
+ font-size: 16px;
+ font-variant: small-caps
+ text-align: center;
+ width: 100%;
}
.kiosk_address {
- font-size: 0.8em;
-}
-
-.kiosk_availability {
- font-size: 0.8em;
- font-weight: bold;
- text-align: right;
+ font-size: 16px;
+ width: 100%;
+ color: #616161;
+ font-variant: small-caps;
}
\ No newline at end of file