changes for https://issues.apache.org/jira/browse/CB-231
diff --git a/Makefile b/Makefile
index 77d3b17..4a93f3e 100755
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@
ECHO = echo
ECHO_N = echo -n
JAVA = java
-PGVERSION = 1.0.0
+PGVERSION = 1.6.0
NAME = `$(CAT) framework/appinfo.json | $(GREP) '"id"' | $(CUT) -d \" -f 4`
VERSION = `$(CAT) framework/appinfo.json | $(GREP) '"version"' | $(CUT) -d \" -f 4`
@@ -42,14 +42,14 @@
palm-launch $(NAME)
copy_js:
- cp lib/phonegap.js framework/phonegap-$(PGVERSION).js
+ cp lib/cordova.js framework/cordova-$(PGVERSION).js
-js: lib/phonegap.js
+js: lib/cordova.js
-lib/phonegap.js: js/phonegap-core.js js/acceleration.js js/accelerometer.js js/application.js js/audio.js js/camera.js js/contacts.js js/debugconsole.js js/device.js js/file.js js/geolocation.js js/map.js js/mojo.js js/mouse.js js/network.js js/notification.js js/orientation.js js/position.js js/service.js js/sms.js js/telephony.js js/window.js js/windowproperties.js lib/thumbs.0.5.2.js
+lib/cordova.js: js/cordova-core.js js/acceleration.js js/accelerometer.js js/application.js js/audio.js js/camera.js js/contacts.js js/debugconsole.js js/device.js js/file.js js/geolocation.js js/map.js js/mojo.js js/mouse.js js/network.js js/notification.js js/orientation.js js/position.js js/service.js js/sms.js js/telephony.js js/window.js js/windowproperties.js lib/thumbs.0.5.2.js
$(MKPATH) lib
$(RM_F) $@
- $(CAT) js/phonegap-core.js >> $@
+ $(CAT) js/cordova-core.js >> $@
$(CAT) js/acceleration.js >> $@
$(CAT) js/accelerometer.js >> $@
$(CAT) js/application.js >> $@
diff --git a/VERSION b/VERSION
index 3e1ad72..ce6a70b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.5.0
\ No newline at end of file
+1.6.0
\ No newline at end of file
diff --git a/framework/appinfo.json b/framework/appinfo.json
index 51d9cff..d924011 100644
--- a/framework/appinfo.json
+++ b/framework/appinfo.json
@@ -1,9 +1,9 @@
{
- "id": "com.phonegap.webos",
+ "id": "com.cordova.webos",
"version": "0.0.1",
"vendor": "Palm",
"type": "web",
"main": "index.html",
- "title": "PhoneGap WebOS",
+ "title": "Cordova WebOS",
"uiRevision": 2
}
diff --git a/framework/phonegap-1.5.0.js b/framework/cordova-1.6.0.js
similarity index 84%
rename from framework/phonegap-1.5.0.js
rename to framework/cordova-1.6.0.js
index 1571443..23215f2 100644
--- a/framework/phonegap-1.5.0.js
+++ b/framework/cordova-1.6.0.js
@@ -1,28 +1,29 @@
if (typeof(DeviceInfo) != 'object')
DeviceInfo = {};
-function PhoneGap() {
+function Cordova() {
ready = true;
available = true;
sceneController = null;
};
-PhoneGap.exec = function(win, fail, clazz, action, args) {
+
+Cordova.exec = function(win, fail, clazz, action, args) {
setTimeout(function() {
- PhoneGap.plugins[clazz].execute(action, args, win, fail);
+ Cordova.plugins[clazz].execute(action, args, win, fail);
}, 0);
}
-PhoneGap.checkArgs = function(args, func) {
+Cordova.checkArgs = function(args, func) {
if (typeof args == 'object')
func.apply(null, args);
else
func(args);
}
-PhoneGap.callback = function(success, win, fail) {
+Cordova.callback = function(success, win, fail) {
if (success)
win();
else
@@ -35,28 +36,28 @@
var actionFound = false;
switch(action) {
case 'setFastAccelerometer':
- PhoneGap.checkArgs(args, navigator.accelerometer.setFastAccelerometer);
+ Cordova.checkArgs(args, navigator.accelerometer.setFastAccelerometer);
actionFound = true;
break;
case 'getCurrentAcceleration':
- PhoneGap.checkArgs(args, navigator.accelerometer.getCurrentAcceleration);
+ Cordova.checkArgs(args, navigator.accelerometer.getCurrentAcceleration);
actionFound = true;
break;
case 'watchAcceleration':
- PhoneGap.checkArgs(args, navigator.accelerometer.watchAcceleration);
+ Cordova.checkArgs(args, navigator.accelerometer.watchAcceleration);
actionFound = true;
break;
case 'clearWatch':
- PhoneGap.checkArgs(args, navigator.accelerometer.clearWatch);
+ Cordova.checkArgs(args, navigator.accelerometer.clearWatch);
actionFound = true;
break;
case 'start':
- PhoneGap.checkArgs(args, navigator.accelerometer.start);
+ Cordova.checkArgs(args, navigator.accelerometer.start);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -65,20 +66,20 @@
var actionFound = false;
switch(action) {
case 'activate':
- PhoneGap.checkArgs(args, navigator.application.activate);
+ Cordova.checkArgs(args, navigator.application.activate);
actionFound = true;
break;
case 'deactivate':
- PhoneGap.checkArgs(args, navigator.application.deactivate);
+ Cordova.checkArgs(args, navigator.application.deactivate);
actionFound = true;
break;
case 'getIdentifier':
- PhoneGap.checkArgs(args, navigator.application.getIdentifier);
+ Cordova.checkArgs(args, navigator.application.getIdentifier);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -88,12 +89,39 @@
switch(action) {
case 'getPicture':
console.log("in here");
- PhoneGap.checkArgs(args, navigator.camera.getPicture);
+ Cordova.checkArgs(args, navigator.camera.getPicture);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+// translates the action into an API call
+compassAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'getCurrentHeading':
+ Cordova.checkArgs(args, navigator.compass.getCurrentHeading);
+ actionFound = true;
+ break;
+ case 'watchHeading':
+ Cordova.checkArgs(args, navigator.compass.watchHeading);
+ actionFound = true;
+ break;
+ case 'clearWatch':
+ Cordova.checkArgs(args, navigator.compass.clearWatch);
+ actionFound = true;
+ break;
+ case 'start':
+ Cordova.checkArgs(args, navigator.compass.start);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -102,20 +130,20 @@
var actionFound = false;
switch(action) {
case 'log':
- PhoneGap.checkArgs(args, window.debug.log);
+ Cordova.checkArgs(args, window.debug.log);
actionFound = true;
break;
case 'warn':
- PhoneGap.checkArgs(args, window.debug.warn);
+ Cordova.checkArgs(args, window.debug.warn);
actionFound = true;
break;
case 'error':
- PhoneGap.checkArgs(args, window.debug.error);
+ Cordova.checkArgs(args, window.debug.error);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -124,12 +152,12 @@
var actionFound = false;
switch(action) {
case 'getDeviceInfo':
- PhoneGap.checkArgs(args, navigator.device.getDeviceInfo);
+ Cordova.checkArgs(args, navigator.device.getDeviceInfo);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -138,28 +166,28 @@
var actionFound = false;
switch(action) {
case 'getCurrentPosition':
- PhoneGap.checkArgs(args, navigator.geolocation.getCurrentPosition);
+ Cordova.checkArgs(args, navigator.geolocation.getCurrentPosition);
actionFound = true;
break;
case 'watchPosition':
- PhoneGap.checkArgs(args, navigator.geolocation.watchPosition);
+ Cordova.checkArgs(args, navigator.geolocation.watchPosition);
actionFound = true;
break;
case 'clearWatch':
- PhoneGap.checkArgs(args, navigator.geolocation.clearWatch);
+ Cordova.checkArgs(args, navigator.geolocation.clearWatch);
actionFound = true;
break;
case 'start':
- PhoneGap.checkArgs(args, navigator.geolocation.start);
+ Cordova.checkArgs(args, navigator.geolocation.start);
actionFound = true;
break;
case 'stop':
- PhoneGap.checkArgs(args, navigator.geolocation.stop);
+ Cordova.checkArgs(args, navigator.geolocation.stop);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -168,12 +196,12 @@
var actionFound = false;
switch(action) {
case 'show':
- PhoneGap.checkArgs(args, navigator.map.show);
+ Cordova.checkArgs(args, navigator.map.show);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -182,12 +210,12 @@
var actionFound = false;
switch(action) {
case 'simulateMouseClick':
- PhoneGap.checkArgs(args, navigator.mouse.simulateMouseClick);
+ Cordova.checkArgs(args, navigator.mouse.simulateMouseClick);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -196,12 +224,12 @@
var actionFound = false;
switch(action) {
case 'isReachable':
- PhoneGap.checkArgs(args, navigator.network.isReachable);
+ Cordova.checkArgs(args, navigator.network.isReachable);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -210,36 +238,36 @@
var actionFound = false;
switch(action) {
case 'alert':
- PhoneGap.checkArgs(args, navigator.notification.alert);
+ Cordova.checkArgs(args, navigator.notification.alert);
actionFound = true;
break;
case 'showBanner':
- PhoneGap.checkArgs(args, navigator.notification.showBanner);
+ Cordova.checkArgs(args, navigator.notification.showBanner);
actionFound = true;
break;
case 'newDashboard':
- PhoneGap.checkArgs(args, navigator.notification.newDashboard);
+ Cordova.checkArgs(args, navigator.notification.newDashboard);
actionFound = true;
break;
case 'removeBannerMessage':
- PhoneGap.checkArgs(args, navigator.notification.removeBannerMessage);
+ Cordova.checkArgs(args, navigator.notification.removeBannerMessage);
actionFound = true;
break;
case 'clearBannerMessage':
- PhoneGap.checkArgs(args, navigator.notification.clearBannerMessage);
+ Cordova.checkArgs(args, navigator.notification.clearBannerMessage);
actionFound = true;
break;
case 'vibrate':
- PhoneGap.checkArgs(args, navigator.notification.vibrate);
+ Cordova.checkArgs(args, navigator.notification.vibrate);
actionFound = true;
break;
case 'beep':
- PhoneGap.checkArgs(args, navigator.notification.beep);
+ Cordova.checkArgs(args, navigator.notification.beep);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -248,28 +276,28 @@
var actionFound = false;
switch(action) {
case 'setOrientation':
- PhoneGap.checkArgs(args, navigator.orientation.setOrientation);
+ Cordova.checkArgs(args, navigator.orientation.setOrientation);
actionFound = true;
break;
case 'getOrientation':
- PhoneGap.checkArgs(args, navigator.orientation.getOrientation);
+ Cordova.checkArgs(args, navigator.orientation.getOrientation);
actionFound = true;
break;
case 'start':
- PhoneGap.checkArgs(args, navigator.orientation.start);
+ Cordova.checkArgs(args, navigator.orientation.start);
actionFound = true;
break;
case 'watchOrientation':
- PhoneGap.checkArgs(args, navigator.orientation.watchOrientation);
+ Cordova.checkArgs(args, navigator.orientation.watchOrientation);
actionFound = true;
break;
case 'clearWatch':
- PhoneGap.checkArgs(args, navigator.orientation.clearWatch);
+ Cordova.checkArgs(args, navigator.orientation.clearWatch);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -278,12 +306,12 @@
var actionFound = false;
switch(action) {
case 'send':
- PhoneGap.checkArgs(args, navigator.sms.send);
+ Cordova.checkArgs(args, navigator.sms.send);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -292,12 +320,12 @@
var actionFound = false;
switch(action) {
case 'send':
- PhoneGap.checkArgs(args, navigator.telephony.send);
+ Cordova.checkArgs(args, navigator.telephony.send);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
@@ -306,52 +334,52 @@
var actionFound = false;
switch(action) {
case 'newCard':
- PhoneGap.checkArgs(args, navigator.window.newCard);
+ Cordova.checkArgs(args, navigator.window.newCard);
actionFound = true;
break;
case 'setFullScreen':
- PhoneGap.checkArgs(args, navigator.window.setFullScreen);
+ Cordova.checkArgs(args, navigator.window.setFullScreen);
actionFound = true;
break;
case 'setWindowProperties':
- PhoneGap.checkArgs(args, navigator.window.setWindowProperties);
+ Cordova.checkArgs(args, navigator.window.setWindowProperties);
actionFound = true;
break;
case 'blockScreenTimeout':
- PhoneGap.checkArgs(args, navigator.window.blockScreenTimeout);
+ Cordova.checkArgs(args, navigator.window.blockScreenTimeout);
actionFound = true;
break;
case 'setSubtleLightbar':
- PhoneGap.checkArgs(args, navigator.window.setSubtleLightbar);
+ Cordova.checkArgs(args, navigator.window.setSubtleLightbar);
actionFound = true;
break;
}
- PhoneGap.callback(actionFound, win, fail);
+ Cordova.callback(actionFound, win, fail);
}
}
// this mapping acts as a shim to the webOS APIs
-PhoneGap.plugins = {};
-PhoneGap.plugins['navigator.accelerometer'] = accelerometerAPI;
-PhoneGap.plugins['navigator.application'] = applicationAPI;
-PhoneGap.plugins['navigator.camera'] = cameraAPI;
-PhoneGap.plugins['window.debug'] = debugAPI;
-PhoneGap.plugins['navigator.device'] = deviceAPI;
-PhoneGap.plugins['navigator.geolocation'] = geolocationAPI;
-PhoneGap.plugins['navigator.map'] = mapAPI;
-PhoneGap.plugins['navigator.mouse'] = mouseAPI;
-PhoneGap.plugins['navigator.network'] = networkAPI;
-PhoneGap.plugins['navigator.notification'] = notificationAPI;
-PhoneGap.plugins['navigator.orientation'] = orientationAPI;
-PhoneGap.plugins['navigator.sms'] = smsAPI;
-PhoneGap.plugins['navigator.telephony'] = telephonyAPI;
-PhoneGap.plugins['navigator.window'] = windowAPI;
-
+Cordova.plugins = {};
+Cordova.plugins['navigator.accelerometer'] = accelerometerAPI;
+Cordova.plugins['navigator.application'] = applicationAPI;
+Cordova.plugins['navigator.camera'] = cameraAPI;
+Cordova.plugins['navigator.compass'] = compassAPI;
+Cordova.plugins['window.debug'] = debugAPI;
+Cordova.plugins['navigator.device'] = deviceAPI;
+Cordova.plugins['navigator.geolocation'] = geolocationAPI;
+Cordova.plugins['navigator.map'] = mapAPI;
+Cordova.plugins['navigator.mouse'] = mouseAPI;
+Cordova.plugins['navigator.network'] = networkAPI;
+Cordova.plugins['navigator.notification'] = notificationAPI;
+Cordova.plugins['navigator.orientation'] = orientationAPI;
+Cordova.plugins['navigator.sms'] = smsAPI;
+Cordova.plugins['navigator.telephony'] = telephonyAPI;
+Cordova.plugins['navigator.window'] = windowAPI;
document.addEventListener('DOMContentLoaded', function () {
- window.phonegap = new PhoneGap();
+ window.cordova = new Cordova();
navigator.device.deviceReady();
});
/*
@@ -542,9 +570,9 @@
* @constructor
*/
-PhoneGap.overrideAudio = function() {
+Cordova.overrideAudio = function() {
- PhoneGap.MojoAudio = Audio;
+ Cordova.MojoAudio = Audio;
Audio = function(src) {
this.src = src;
@@ -565,7 +593,7 @@
this.paused = false;
this.playing = true;
this.stopped = false;
- this.audioPlayer = new PhoneGap.MojoAudio();
+ this.audioPlayer = new Cordova.MojoAudio();
var file = Mojo.appPath + this.src;
if (this.audioPlayer.palm) {
this.audioPlayer.mojo.audioClass = "media";
@@ -627,7 +655,7 @@
}
-document.addEventListener("deviceready", PhoneGap.overrideAudio, false);
+document.addEventListener("deviceready", Cordova.overrideAudio, false);
/*
* This class provides access to the device camera.
@@ -709,7 +737,7 @@
*/
Contacts.prototype.find = function(filter, successCallback, errorCallback, options) {
- errorCallback({ name: "ContactsError", message: "PhoneGap Palm contacts not implemented" });
+ errorCallback({ name: "ContactsError", message: "Cordova Palm contacts not implemented" });
};
Contacts.prototype.success_callback = function(contacts_iterator) {
@@ -717,6 +745,108 @@
if (typeof navigator.contacts == "undefined") navigator.contacts = new Contacts();
/*
+ * This class provides access to device compass data.
+ * @constructor
+ */
+function Compass() {
+ /*
+ * The last known heading.
+ */
+ this.lastHeading = null;
+};
+
+/*
+ * Asynchronously aquires the current compass heading.
+ * @param {Function} successCallback The function to call when the compass
+ * data is available
+ * @param {Function} errorCallback The function to call when there is an error
+ * getting the compass data.
+ * @param {CompassOptions} options The options for getting the compass data
+ * such as timeout.
+ */
+
+Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, options) {
+
+ var referenceTime = 0;
+ if (this.lastHeading)
+ referenceTime = this.lastHeading.timestamp;
+ else
+ this.start();
+
+ var timeout = 20000;
+ var interval = 500;
+ if (typeof(options) == 'object' && options.interval)
+ interval = options.interval;
+
+ if (typeof(successCallback) != 'function')
+ successCallback = function() {};
+ if (typeof(errorCallback) != 'function')
+ errorCallback = function() {};
+
+ var dis = this;
+ var delay = 0;
+ var timer = setInterval(function() {
+ delay += interval;
+
+ //if we have a new compass heading, call success and cancel the timer
+ if (typeof(dis.lastHeading) == 'object' && dis.lastHeading != null && dis.lastHeading.timestamp > referenceTime) {
+ successCallback(dis.lastHeading.magHeading);
+ clearInterval(timer);
+ } else if (delay >= timeout) { //else if timeout has occured then call error and cancel the timer
+ errorCallback();
+ clearInterval(timer);
+ }
+ //else the interval gets called again
+ }, interval);
+};
+
+
+/*
+ * Asynchronously aquires the compass heading repeatedly at a given interval.
+ * @param {Function} successCallback The function to call each time the acceleration
+ * data is available
+ * @param {Function} errorCallback The function to call when there is an error
+ * getting the compass data.
+ * @param {CompassOptions} options The options for getting the compass data
+ * such as timeout.
+ */
+
+Compass.prototype.watchHeading = function(successCallback, errorCallback, options) {
+ this.getCurrentHeading(successCallback, errorCallback, options);
+ // TODO: add the interval id to a list so we can clear all watches
+ var frequency = (options != undefined)? options.frequency : 10000;
+ var that = this;
+ return setInterval(function() {
+ that.getCurrentHeading(successCallback, errorCallback, options);
+ }, frequency);
+};
+
+/*
+ * Clears the specified heading watch.
+ * @param {String} watchId The ID of the watch returned from #watchHeading.
+ */
+Compass.prototype.clearWatch = function(watchId) {
+ clearInterval(watchId);
+};
+
+/*
+ * Starts the native compass listener.
+ */
+
+Compass.prototype.start = function() {
+ var that = this;
+ //Mojo.Event.listen(document, "acceleration", function(event) {
+ document.addEventListener("compass", function(event) {
+ var heading={};
+ heading.trueHeading=event.trueHeading;
+ heading.magHeading=event.magHeading;
+ heading.timestamp = new Date().getTime();
+ that.lastHeading = heading;
+ });
+};
+
+if (typeof navigator.compass == "undefined") navigator.compass = new Compass();
+/*
* This class provides access to the debugging console.
* @constructor
*/
diff --git a/framework/index.html b/framework/index.html
index 5d2a0d0..fb62362 100644
--- a/framework/index.html
+++ b/framework/index.html
@@ -14,9 +14,9 @@
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>PhoneGap WebOS</title>
+ <title>cordova WebOS</title>
- <script type="text/javascript" src="phonegap-1.0.0.js"></script>
+ <script type="text/javascript" src="cordova-1.6.0.js"></script>
<script type="text/javascript">
// create global var for sqlite database instance
var db;
@@ -37,7 +37,7 @@
<a onclick="navigator.window.newCard('dashboard.html'); menu(false);">Launch New Card</a>
<a onclick="getPicture();">Launch Camera</a>
<a onclick="storage();">Storage Tests</a>
- <a onclick="callPhoneGapExec();menu(false);">PhoneGap Exec</a>
+ <a onclick="callCordovaExec();menu(false);">cordova Exec</a>
<a onclick="page('touchDemo');">Touch Events Examples</a>
<a onclick="page('compassDemo');">Compass API</a>
<a onclick="menu(false);">Done</a>
@@ -108,7 +108,7 @@
<script>
document.addEventListener('deviceready', function () {
- // PhoneGap is ready, do all your stuf here
+ // cordova is ready, do all your stuf here
}, false);
var watchId = null;
@@ -159,9 +159,12 @@
navigator.notification.alert(event.type);
}
-function callPhoneGapExec() {
+function callCordovaExec() {
+
+ navigator.notification.alert(Cordova.ready);
+
//win, fail, clazz, action, args
- PhoneGap.exec(success, fail, 'navigator.notification', 'alert', 'testing exec');
+ Cordova.exec(success, fail, 'navigator.notification', 'alert', 'testing exec');
function success(msg) {
console.log(msg + ' exec succeeded');
@@ -235,6 +238,7 @@
var r = JSON.stringify(states[response]);
netpage.innerHTML = r.replace(/,/g, ', ');
+ netpage.innerHTML += response.toString();
}
var request = navigator.network.isReachable('palm://com.palm.connectionmanager', successful, {});
diff --git a/js/audio.js b/js/audio.js
index f4a5107..8480d45 100755
--- a/js/audio.js
+++ b/js/audio.js
@@ -3,9 +3,9 @@
* @constructor
*/
-PhoneGap.overrideAudio = function() {
+Cordova.overrideAudio = function() {
- PhoneGap.MojoAudio = Audio;
+ Cordova.MojoAudio = Audio;
Audio = function(src) {
this.src = src;
@@ -26,7 +26,7 @@
this.paused = false;
this.playing = true;
this.stopped = false;
- this.audioPlayer = new PhoneGap.MojoAudio();
+ this.audioPlayer = new Cordova.MojoAudio();
var file = Mojo.appPath + this.src;
if (this.audioPlayer.palm) {
this.audioPlayer.mojo.audioClass = "media";
@@ -88,5 +88,5 @@
}
-document.addEventListener("deviceready", PhoneGap.overrideAudio, false);
+document.addEventListener("deviceready", Cordova.overrideAudio, false);
diff --git a/js/contacts.js b/js/contacts.js
index 4203ed8..a96b492 100755
--- a/js/contacts.js
+++ b/js/contacts.js
@@ -39,7 +39,7 @@
*/
Contacts.prototype.find = function(filter, successCallback, errorCallback, options) {
- errorCallback({ name: "ContactsError", message: "PhoneGap Palm contacts not implemented" });
+ errorCallback({ name: "ContactsError", message: "Cordova Palm contacts not implemented" });
};
Contacts.prototype.success_callback = function(contacts_iterator) {
diff --git a/js/cordova-core.js b/js/cordova-core.js
new file mode 100644
index 0000000..3cc3e1c
--- /dev/null
+++ b/js/cordova-core.js
@@ -0,0 +1,384 @@
+if (typeof(DeviceInfo) != 'object')
+ DeviceInfo = {};
+
+function Cordova() {
+ ready = true;
+ available = true;
+ sceneController = null;
+};
+
+
+Cordova.exec = function(win, fail, clazz, action, args) {
+
+ setTimeout(function() {
+ Cordova.plugins[clazz].execute(action, args, win, fail);
+ }, 0);
+
+}
+
+Cordova.checkArgs = function(args, func) {
+ if (typeof args == 'object')
+ func.apply(null, args);
+ else
+ func(args);
+}
+
+Cordova.callback = function(success, win, fail) {
+ if (success)
+ win();
+ else
+ fail();
+}
+
+// translates the action into an API call
+accelerometerAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'setFastAccelerometer':
+ Cordova.checkArgs(args, navigator.accelerometer.setFastAccelerometer);
+ actionFound = true;
+ break;
+ case 'getCurrentAcceleration':
+ Cordova.checkArgs(args, navigator.accelerometer.getCurrentAcceleration);
+ actionFound = true;
+ break;
+ case 'watchAcceleration':
+ Cordova.checkArgs(args, navigator.accelerometer.watchAcceleration);
+ actionFound = true;
+ break;
+ case 'clearWatch':
+ Cordova.checkArgs(args, navigator.accelerometer.clearWatch);
+ actionFound = true;
+ break;
+ case 'start':
+ Cordova.checkArgs(args, navigator.accelerometer.start);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+applicationAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'activate':
+ Cordova.checkArgs(args, navigator.application.activate);
+ actionFound = true;
+ break;
+ case 'deactivate':
+ Cordova.checkArgs(args, navigator.application.deactivate);
+ actionFound = true;
+ break;
+ case 'getIdentifier':
+ Cordova.checkArgs(args, navigator.application.getIdentifier);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+cameraAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'getPicture':
+ console.log("in here");
+ Cordova.checkArgs(args, navigator.camera.getPicture);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+// translates the action into an API call
+compassAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'getCurrentHeading':
+ Cordova.checkArgs(args, navigator.compass.getCurrentHeading);
+ actionFound = true;
+ break;
+ case 'watchHeading':
+ Cordova.checkArgs(args, navigator.compass.watchHeading);
+ actionFound = true;
+ break;
+ case 'clearWatch':
+ Cordova.checkArgs(args, navigator.compass.clearWatch);
+ actionFound = true;
+ break;
+ case 'start':
+ Cordova.checkArgs(args, navigator.compass.start);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+debugAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'log':
+ Cordova.checkArgs(args, window.debug.log);
+ actionFound = true;
+ break;
+ case 'warn':
+ Cordova.checkArgs(args, window.debug.warn);
+ actionFound = true;
+ break;
+ case 'error':
+ Cordova.checkArgs(args, window.debug.error);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+deviceAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'getDeviceInfo':
+ Cordova.checkArgs(args, navigator.device.getDeviceInfo);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+geolocationAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'getCurrentPosition':
+ Cordova.checkArgs(args, navigator.geolocation.getCurrentPosition);
+ actionFound = true;
+ break;
+ case 'watchPosition':
+ Cordova.checkArgs(args, navigator.geolocation.watchPosition);
+ actionFound = true;
+ break;
+ case 'clearWatch':
+ Cordova.checkArgs(args, navigator.geolocation.clearWatch);
+ actionFound = true;
+ break;
+ case 'start':
+ Cordova.checkArgs(args, navigator.geolocation.start);
+ actionFound = true;
+ break;
+ case 'stop':
+ Cordova.checkArgs(args, navigator.geolocation.stop);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+mapAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'show':
+ Cordova.checkArgs(args, navigator.map.show);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+mouseAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'simulateMouseClick':
+ Cordova.checkArgs(args, navigator.mouse.simulateMouseClick);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+networkAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'isReachable':
+ Cordova.checkArgs(args, navigator.network.isReachable);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+notificationAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'alert':
+ Cordova.checkArgs(args, navigator.notification.alert);
+ actionFound = true;
+ break;
+ case 'showBanner':
+ Cordova.checkArgs(args, navigator.notification.showBanner);
+ actionFound = true;
+ break;
+ case 'newDashboard':
+ Cordova.checkArgs(args, navigator.notification.newDashboard);
+ actionFound = true;
+ break;
+ case 'removeBannerMessage':
+ Cordova.checkArgs(args, navigator.notification.removeBannerMessage);
+ actionFound = true;
+ break;
+ case 'clearBannerMessage':
+ Cordova.checkArgs(args, navigator.notification.clearBannerMessage);
+ actionFound = true;
+ break;
+ case 'vibrate':
+ Cordova.checkArgs(args, navigator.notification.vibrate);
+ actionFound = true;
+ break;
+ case 'beep':
+ Cordova.checkArgs(args, navigator.notification.beep);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+orientationAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'setOrientation':
+ Cordova.checkArgs(args, navigator.orientation.setOrientation);
+ actionFound = true;
+ break;
+ case 'getOrientation':
+ Cordova.checkArgs(args, navigator.orientation.getOrientation);
+ actionFound = true;
+ break;
+ case 'start':
+ Cordova.checkArgs(args, navigator.orientation.start);
+ actionFound = true;
+ break;
+ case 'watchOrientation':
+ Cordova.checkArgs(args, navigator.orientation.watchOrientation);
+ actionFound = true;
+ break;
+ case 'clearWatch':
+ Cordova.checkArgs(args, navigator.orientation.clearWatch);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+smsAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'send':
+ Cordova.checkArgs(args, navigator.sms.send);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+telephonyAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'send':
+ Cordova.checkArgs(args, navigator.telephony.send);
+ actionFound = true;
+ break;
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+windowAPI = {
+ execute: function(action, args, win, fail) {
+ var actionFound = false;
+ switch(action) {
+ case 'newCard':
+ Cordova.checkArgs(args, navigator.window.newCard);
+ actionFound = true;
+ break;
+ case 'setFullScreen':
+ Cordova.checkArgs(args, navigator.window.setFullScreen);
+ actionFound = true;
+ break;
+ case 'setWindowProperties':
+ Cordova.checkArgs(args, navigator.window.setWindowProperties);
+ actionFound = true;
+ break;
+ case 'blockScreenTimeout':
+ Cordova.checkArgs(args, navigator.window.blockScreenTimeout);
+ actionFound = true;
+ break;
+ case 'setSubtleLightbar':
+ Cordova.checkArgs(args, navigator.window.setSubtleLightbar);
+ actionFound = true;
+ break;
+
+ }
+
+ Cordova.callback(actionFound, win, fail);
+ }
+}
+
+// this mapping acts as a shim to the webOS APIs
+Cordova.plugins = {};
+Cordova.plugins['navigator.accelerometer'] = accelerometerAPI;
+Cordova.plugins['navigator.application'] = applicationAPI;
+Cordova.plugins['navigator.camera'] = cameraAPI;
+Cordova.plugins['navigator.compass'] = compassAPI;
+Cordova.plugins['window.debug'] = debugAPI;
+Cordova.plugins['navigator.device'] = deviceAPI;
+Cordova.plugins['navigator.geolocation'] = geolocationAPI;
+Cordova.plugins['navigator.map'] = mapAPI;
+Cordova.plugins['navigator.mouse'] = mouseAPI;
+Cordova.plugins['navigator.network'] = networkAPI;
+Cordova.plugins['navigator.notification'] = notificationAPI;
+Cordova.plugins['navigator.orientation'] = orientationAPI;
+Cordova.plugins['navigator.sms'] = smsAPI;
+Cordova.plugins['navigator.telephony'] = telephonyAPI;
+Cordova.plugins['navigator.window'] = windowAPI;
+
+document.addEventListener('DOMContentLoaded', function () {
+ window.cordova = new Cordova();
+ navigator.device.deviceReady();
+});
diff --git a/js/phonegap-core.js b/js/phonegap-core.js
deleted file mode 100644
index 5efb6bf..0000000
--- a/js/phonegap-core.js
+++ /dev/null
@@ -1,415 +0,0 @@
-if (typeof(DeviceInfo) != 'object')
- DeviceInfo = {};
-
-function PhoneGap() {
- ready = true;
- available = true;
- sceneController = null;
-};
-
-PhoneGap.exec = function(win, fail, clazz, action, args) {
-
- setTimeout(function() {
- PhoneGap.plugins[clazz].execute(action, args, win, fail);
- }, 0);
-
-}
-
-PhoneGap.checkArgs = function(args, func) {
- if (typeof args == 'object')
- func.apply(null, args);
- else
- func(args);
-}
-
-PhoneGap.callback = function(success, win, fail) {
- if (success)
- win();
- else
- fail();
-}
-
-// translates the action into an API call
-accelerometerAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'setFastAccelerometer':
- PhoneGap.checkArgs(args, navigator.accelerometer.setFastAccelerometer);
- actionFound = true;
- break;
- case 'getCurrentAcceleration':
- PhoneGap.checkArgs(args, navigator.accelerometer.getCurrentAcceleration);
- actionFound = true;
- break;
- case 'watchAcceleration':
- PhoneGap.checkArgs(args, navigator.accelerometer.watchAcceleration);
- actionFound = true;
- break;
- case 'clearWatch':
- PhoneGap.checkArgs(args, navigator.accelerometer.clearWatch);
- actionFound = true;
- break;
- case 'start':
- PhoneGap.checkArgs(args, navigator.accelerometer.start);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-applicationAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'activate':
- PhoneGap.checkArgs(args, navigator.application.activate);
- actionFound = true;
- break;
- case 'deactivate':
- PhoneGap.checkArgs(args, navigator.application.deactivate);
- actionFound = true;
- break;
- case 'getIdentifier':
- PhoneGap.checkArgs(args, navigator.application.getIdentifier);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-cameraAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'getPicture':
- console.log("in here");
- PhoneGap.checkArgs(args, navigator.camera.getPicture);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-windowAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'newCard':
- PhoneGap.checkArgs(args, navigator.window.newCard);
- actionFound = true;
- break;
- case 'setFullScreen':
- PhoneGap.checkArgs(args, navigator.window.setFullScreen);
- actionFound = true;
- break;
- case 'setWindowProperties':
- PhoneGap.checkArgs(args, navigator.window.setWindowProperties);
- actionFound = true;
- break;
- case 'blockScreenTimeout':
- PhoneGap.checkArgs(args, navigator.window.blockScreenTimeout);
- actionFound = true;
- break;
- case 'setSubtleLightbar':
- PhoneGap.checkArgs(args, navigator.window.setSubtleLightbar);
- actionFound = true;
- break;
-
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-// translates the action into an API call
-compassAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'getCurrentHeading':
- PhoneGap.checkArgs(args, navigator.compass.getCurrentHeading);
- actionFound = true;
- break;
- case 'watchHeading':
- PhoneGap.checkArgs(args, navigator.compass.watchHeading);
- actionFound = true;
- break;
- case 'clearWatch':
- PhoneGap.checkArgs(args, navigator.compass.clearWatch);
- actionFound = true;
- break;
- case 'start':
- PhoneGap.checkArgs(args, navigator.compass.start);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-debugAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'log':
- PhoneGap.checkArgs(args, window.debug.log);
- actionFound = true;
- break;
- case 'warn':
- PhoneGap.checkArgs(args, window.debug.warn);
- actionFound = true;
- break;
- case 'error':
- PhoneGap.checkArgs(args, window.debug.error);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-deviceAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'getDeviceInfo':
- PhoneGap.checkArgs(args, navigator.device.getDeviceInfo);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-geolocationAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'getCurrentPosition':
- PhoneGap.checkArgs(args, navigator.geolocation.getCurrentPosition);
- actionFound = true;
- break;
- case 'watchPosition':
- PhoneGap.checkArgs(args, navigator.geolocation.watchPosition);
- actionFound = true;
- break;
- case 'clearWatch':
- PhoneGap.checkArgs(args, navigator.geolocation.clearWatch);
- actionFound = true;
- break;
- case 'start':
- PhoneGap.checkArgs(args, navigator.geolocation.start);
- actionFound = true;
- break;
- case 'stop':
- PhoneGap.checkArgs(args, navigator.geolocation.stop);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-mapAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'show':
- PhoneGap.checkArgs(args, navigator.map.show);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-mouseAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'simulateMouseClick':
- PhoneGap.checkArgs(args, navigator.mouse.simulateMouseClick);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-networkAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'isReachable':
- PhoneGap.checkArgs(args, navigator.network.isReachable);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-notificationAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'alert':
- PhoneGap.checkArgs(args, navigator.notification.alert);
- actionFound = true;
- break;
- case 'showBanner':
- PhoneGap.checkArgs(args, navigator.notification.showBanner);
- actionFound = true;
- break;
- case 'newDashboard':
- PhoneGap.checkArgs(args, navigator.notification.newDashboard);
- actionFound = true;
- break;
- case 'removeBannerMessage':
- PhoneGap.checkArgs(args, navigator.notification.removeBannerMessage);
- actionFound = true;
- break;
- case 'clearBannerMessage':
- PhoneGap.checkArgs(args, navigator.notification.clearBannerMessage);
- actionFound = true;
- break;
- case 'vibrate':
- PhoneGap.checkArgs(args, navigator.notification.vibrate);
- actionFound = true;
- break;
- case 'beep':
- PhoneGap.checkArgs(args, navigator.notification.beep);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-orientationAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'setOrientation':
- PhoneGap.checkArgs(args, navigator.orientation.setOrientation);
- actionFound = true;
- break;
- case 'getOrientation':
- PhoneGap.checkArgs(args, navigator.orientation.getOrientation);
- actionFound = true;
- break;
- case 'start':
- PhoneGap.checkArgs(args, navigator.orientation.start);
- actionFound = true;
- break;
- case 'watchOrientation':
- PhoneGap.checkArgs(args, navigator.orientation.watchOrientation);
- actionFound = true;
- break;
- case 'clearWatch':
- PhoneGap.checkArgs(args, navigator.orientation.clearWatch);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-smsAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'send':
- PhoneGap.checkArgs(args, navigator.sms.send);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-telephonyAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'send':
- PhoneGap.checkArgs(args, navigator.telephony.send);
- actionFound = true;
- break;
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-windowAPI = {
- execute: function(action, args, win, fail) {
- var actionFound = false;
- switch(action) {
- case 'newCard':
- PhoneGap.checkArgs(args, navigator.window.newCard);
- actionFound = true;
- break;
- case 'setFullScreen':
- PhoneGap.checkArgs(args, navigator.window.setFullScreen);
- actionFound = true;
- break;
- case 'setWindowProperties':
- PhoneGap.checkArgs(args, navigator.window.setWindowProperties);
- actionFound = true;
- break;
- case 'blockScreenTimeout':
- PhoneGap.checkArgs(args, navigator.window.blockScreenTimeout);
- actionFound = true;
- break;
- case 'setSubtleLightbar':
- PhoneGap.checkArgs(args, navigator.window.setSubtleLightbar);
- actionFound = true;
- break;
-
- }
-
- PhoneGap.callback(actionFound, win, fail);
- }
-}
-
-// this mapping acts as a shim to the webOS APIs
-PhoneGap.plugins = {};
-PhoneGap.plugins['navigator.accelerometer'] = accelerometerAPI;
-PhoneGap.plugins['navigator.application'] = applicationAPI;
-PhoneGap.plugins['navigator.camera'] = cameraAPI;
-PhoneGap.plugins['navigator.compass'] = compassAPI;
-PhoneGap.plugins['window.debug'] = debugAPI;
-PhoneGap.plugins['navigator.device'] = deviceAPI;
-PhoneGap.plugins['navigator.geolocation'] = geolocationAPI;
-PhoneGap.plugins['navigator.map'] = mapAPI;
-PhoneGap.plugins['navigator.mouse'] = mouseAPI;
-PhoneGap.plugins['navigator.network'] = networkAPI;
-PhoneGap.plugins['navigator.notification'] = notificationAPI;
-PhoneGap.plugins['navigator.orientation'] = orientationAPI;
-PhoneGap.plugins['navigator.sms'] = smsAPI;
-PhoneGap.plugins['navigator.telephony'] = telephonyAPI;
-PhoneGap.plugins['navigator.window'] = windowAPI;
-
-
-document.addEventListener('DOMContentLoaded', function () {
- window.phonegap = new PhoneGap();
- navigator.device.deviceReady();
-});