Skip to content

Commit

Permalink
updated framework app with new phonegap.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Willoughby committed Dec 16, 2009
1 parent 73900fc commit 4861974
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions framework/www/phonegap.js
Expand Up @@ -941,9 +941,11 @@ function Contacts() {

function Contact() {
this.id = null;
this.givenName = "";
this.familyName = "";
this.name = { formatted: "" };
this.name = {
formatted: "",
givenName: "",
familyName: ""
};
this.phones = [];
this.emails = [];
}
Expand All @@ -954,13 +956,6 @@ Contact.prototype.displayName = function()
return this.givenName + " " + this.familyName;
}

function ContactsFilter(name) {
if (name)
this.name = name;
else
this.name = "";
}

/*
* @param {ContactsFilter} filter Object with filter properties. filter.name only for now.
* @param {function} successCallback Callback function on success
Expand Down Expand Up @@ -1015,12 +1010,13 @@ Contacts.prototype.success_callback = function(contacts_iterator) {
try {
if (i >= start) {
var gapContact = new Contact();
gapContact.givenName = Contacts.GetValue(contact, "FirstName");
gapContact.familyName = Contacts.GetValue(contact, "LastName");
gapContact.name = gapContact.firstName + " " + gapContact.lastName;
gapContact.name.givenName = Contacts.GetValue(contact, "FirstName");
gapContact.name.familyName = Contacts.GetValue(contact, "LastName");
gapContact.name.formatted = gapContact.firstName + " " + gapContact.lastName;
gapContact.emails = Contacts.getEmailsList(contact);
gapContact.phones = Contacts.getPhonesList(contact);
gapContact.address = Contacts.getAddress(contact);
gapContact.id = Contacts.GetValue(contact, "id");
gapContacts.push(gapContact);
}
i++;
Expand Down Expand Up @@ -1179,9 +1175,8 @@ Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallba
var delay = 0;
var timer = setInterval(function() {
delay += interval;

//if we have a new position, call success and cancel the timer
if (typeof(dis.lastPosition) == 'object' && dis.lastPosition.timestamp > referenceTime) {
if (dis.lastPosition && dis.lastPosition.timestamp > referenceTime) {
successCallback(dis.lastPosition);
clearInterval(timer);
} else if (delay >= timeout) { //else if timeout has occured then call error and cancel the timer
Expand All @@ -1204,12 +1199,10 @@ Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallba
Geolocation.prototype.watchPosition = function(successCallback, errorCallback, options) {
// Invoke the appropriate callback with a new Position object every time the implementation
// determines that the position of the hosting device has changed.

this.getCurrentPosition(successCallback, errorCallback, options);
var frequency = 10000;
if (typeof options == 'object' && options.frequency)
frequency = options.frequency;

var that = this;
return setInterval(function() {
that.getCurrentPosition(successCallback, errorCallback, options);
Expand Down Expand Up @@ -1256,12 +1249,12 @@ Geolocation.prototype.start = function(options) {

if (result.ErrorCode != 0 || isNaN(retVal.Latitude))
return;

// heading options: retVal.TrueCourse, retVal.MagneticHeading, retVal.Heading, retVal.MagneticCourse
// but retVal.Heading was the only field being returned with data on the test device (Nokia 5800)
// WRT does not provide accuracy
var coords = new Coordinates(retVal.Latitude, retVal.Longitude, retVal.Altitude, null, retVal.Heading, retVal.HorizontalSpeed);
var positionObj = new Position(coords, new Date().getTime());
var newCoords = new Coordinates(retVal.Latitude, retVal.Longitude, retVal.Altitude, null, retVal.Heading, retVal.HorizontalSpeed);
var positionObj = { coords: newCoords, timestamp: (new Date()).getTime() };

dis.lastPosition = positionObj;
});
Expand Down

0 comments on commit 4861974

Please sign in to comment.