mirror of
https://github.com/shouptech/share-a-bike.git
synced 2026-02-03 20:39:43 +00:00
Added radius searching
Updated version number to reflect changes
This commit is contained in:
parent
8b14d149a3
commit
b63b493fab
6 changed files with 125 additions and 59 deletions
|
|
@ -4,6 +4,8 @@ function MainAssistant(argFromPusher) {
|
||||||
MainAssistant.prototype = {
|
MainAssistant.prototype = {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
Ares.setupSceneAssistant(this);
|
Ares.setupSceneAssistant(this);
|
||||||
|
|
||||||
|
this.radius = 0.5;
|
||||||
},
|
},
|
||||||
cleanup: function() {
|
cleanup: function() {
|
||||||
Ares.cleanupSceneAssistant(this);
|
Ares.cleanupSceneAssistant(this);
|
||||||
|
|
@ -14,6 +16,8 @@ MainAssistant.prototype = {
|
||||||
// Start Spinning
|
// Start Spinning
|
||||||
this.showSpinner(true);
|
this.showSpinner(true);
|
||||||
|
|
||||||
|
// Clear List
|
||||||
|
this.controller.setWidgetModel("kioskList", {items:[]});
|
||||||
// API URL for BCycle
|
// API URL for BCycle
|
||||||
var url = 'http://api.bcycle.com/services/mobile.svc/ListKiosks';
|
var url = 'http://api.bcycle.com/services/mobile.svc/ListKiosks';
|
||||||
gpsLatitude = 0;
|
gpsLatitude = 0;
|
||||||
|
|
@ -95,35 +99,26 @@ MainAssistant.prototype = {
|
||||||
return d;
|
return d;
|
||||||
};
|
};
|
||||||
|
|
||||||
var closestKiosks = [];
|
var sortByDistance = function(kiosk1, kiosk2) {
|
||||||
var nClosest = 5;
|
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
|
var closestKiosks = [];
|
||||||
for(var i = 0; i < nClosest; i++) {
|
|
||||||
closestKiosks[i] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop through the kiosks
|
// Loop through the kiosks
|
||||||
for(i = 0; i < kioskResult.responseJSON.d.list.length; i++) {
|
for(i = 0; i < kioskResult.responseJSON.d.list.length; i++) {
|
||||||
var kiosk = kioskResult.responseJSON.d.list[i];
|
var kiosk = kioskResult.responseJSON.d.list[i];
|
||||||
for(var j = 0; j < closestKiosks.length; j++) {
|
var d1 = calcDistance(latitude, longitude, kiosk.Location.Latitude, kiosk.Location.Longitude);
|
||||||
if(closestKiosks[j] === null) {
|
if(d1 < this.radius) {
|
||||||
closestKiosks[j] = kiosk;
|
closestKiosks.push(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closestKiosks.sort(sortByDistance);
|
||||||
|
|
||||||
var kiosks = [];
|
var kiosks = [];
|
||||||
for(i = 0; i < closestKiosks.length; i++) {
|
for(i = 0; i < closestKiosks.length; i++) {
|
||||||
d = calcDistance(latitude, longitude, closestKiosks[i].Location.Latitude, closestKiosks[i].Location.Longitude);
|
d = calcDistance(latitude, longitude, closestKiosks[i].Location.Latitude, closestKiosks[i].Location.Longitude);
|
||||||
|
|
@ -157,5 +152,9 @@ MainAssistant.prototype = {
|
||||||
gps: this.gpsCoord
|
gps: this.gpsCoord
|
||||||
};
|
};
|
||||||
this.controller.stageController.pushScene('mapScene', argToScene);
|
this.controller.stageController.pushScene('mapScene', argToScene);
|
||||||
|
},
|
||||||
|
radiusSelectorChange: function(inSender, event) {
|
||||||
|
this.radius = event.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -23,7 +23,6 @@ opus.Gizmo({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "scroller1",
|
name: "scroller1",
|
||||||
mode: "free",
|
|
||||||
scrollPosition: {
|
scrollPosition: {
|
||||||
left: 0,
|
left: 0,
|
||||||
top: 0
|
top: 0
|
||||||
|
|
@ -43,7 +42,7 @@ opus.Gizmo({
|
||||||
items: [],
|
items: [],
|
||||||
useSampleData: false,
|
useSampleData: false,
|
||||||
title: undefined,
|
title: undefined,
|
||||||
itemHtml: "<div class=\"palm-row\">\n <div class=\"kiosk_left_col\">\n <div class=\"kiosk_name\">#{name}</div>\n <div class=\"kiosk_address\">#{address}</div>\n </div>\n <div class=\"kiosk_right_col\">\n <div class=\"kiosk_distance\">#{distance}</div>\n <div class=\"kiosk_availability\">#{bikes}B #{docks}D</div>\n </div>\n</div>",
|
itemHtml: "<div class=\"palm-row\">\n <div class=\"kiosk_container\">\n <div class=\"kiosk_name\">\n #{name}\n </div>\n <div class=\"kiosk_address\">\n #{address}\n </div>\n <div class=\"kiosk_stats\">\n #{distance} | #{bikes} bikes | #{docks} docks\n </div>\n </div>\n</div>",
|
||||||
swipeToDelete: false,
|
swipeToDelete: false,
|
||||||
rowTapHighlight: false,
|
rowTapHighlight: false,
|
||||||
rowFocusHighlight: false,
|
rowFocusHighlight: false,
|
||||||
|
|
@ -55,14 +54,87 @@ opus.Gizmo({
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "panel1",
|
name: "panel2",
|
||||||
layoutKind: "hbox",
|
|
||||||
dropTarget: true,
|
dropTarget: true,
|
||||||
type: "Palm.Mojo.Panel",
|
type: "Palm.Mojo.Panel",
|
||||||
l: 0,
|
l: 0,
|
||||||
t: 391,
|
t: 391,
|
||||||
h: 60,
|
h: "120",
|
||||||
controls: [
|
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",
|
name: "mapButton",
|
||||||
ontap: "mapButtonTap",
|
ontap: "mapButtonTap",
|
||||||
|
|
@ -70,16 +142,7 @@ opus.Gizmo({
|
||||||
label: "Map",
|
label: "Map",
|
||||||
type: "Palm.Mojo.Button",
|
type: "Palm.Mojo.Button",
|
||||||
l: 0,
|
l: 0,
|
||||||
t: 0
|
t: 60
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "findButton",
|
|
||||||
ontap: "findButtonTap",
|
|
||||||
disabled: undefined,
|
|
||||||
label: "Find",
|
|
||||||
type: "Palm.Mojo.ActivityButton",
|
|
||||||
l: 320,
|
|
||||||
t: 0
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,12 @@ opus.Gizmo({
|
||||||
},
|
},
|
||||||
chrome: [
|
chrome: [
|
||||||
{
|
{
|
||||||
name: "header1",
|
name: "pageHeader1",
|
||||||
label: "Nearby Kiosks",
|
title: "Kiosks Map",
|
||||||
type: "Palm.Mojo.Header",
|
subtitle: "",
|
||||||
|
type: "Palm.Mojo.PageHeader",
|
||||||
l: 0,
|
l: 0,
|
||||||
t: 0
|
t: 49
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "kioskMap",
|
name: "kioskMap",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"id": "com.mikeshoup.share-a-bike",
|
"id": "com.mikeshoup.share-a-bike",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"vendor": "Mike Shoup",
|
"vendor": "Mike Shoup",
|
||||||
"type": "web",
|
"type": "web",
|
||||||
"main": "index.html",
|
"main": "index.html",
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,13 @@
|
||||||
{
|
{
|
||||||
"source": "app/views/mapScene/mapScene-chrome.js",
|
"source": "app/views/mapScene/mapScene-chrome.js",
|
||||||
"scenes": "mapScene"
|
"scenes": "mapScene"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "app/assistants/preferences-assistant.js",
|
||||||
|
"scenes": "preferences"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "app/views/preferences/preferences-chrome.js",
|
||||||
|
"scenes": "preferences"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -1,27 +1,22 @@
|
||||||
.kiosk_left_col {
|
.kiosk_container {
|
||||||
float: left;
|
padding: 5px;
|
||||||
padding-left: 5px;
|
|
||||||
}
|
}
|
||||||
.kiosk_right_col {
|
|
||||||
float: right;
|
|
||||||
padding-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kiosk_name {
|
.kiosk_name {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 1em;
|
font-size: 22px;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kiosk_distance {
|
.kiosk_stats {
|
||||||
font-size: 1em;
|
font-size: 16px;
|
||||||
|
font-variant: small-caps
|
||||||
|
text-align: center;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kiosk_address {
|
.kiosk_address {
|
||||||
font-size: 0.8em;
|
font-size: 16px;
|
||||||
}
|
width: 100%;
|
||||||
|
color: #616161;
|
||||||
.kiosk_availability {
|
font-variant: small-caps;
|
||||||
font-size: 0.8em;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: right;
|
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue