You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2012/05/04 14:35:53 UTC
[5/6] fixes for page navigation
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/autotest/tests/filetransfer.tests.js
----------------------------------------------------------------------
diff --git a/www/autotest/tests/filetransfer.tests.js b/www/autotest/tests/filetransfer.tests.js
new file mode 100644
index 0000000..87ab385
--- /dev/null
+++ b/www/autotest/tests/filetransfer.tests.js
@@ -0,0 +1,44 @@
+describe('FileTransfer', function() {
+ it("should exist and be constructable", function() {
+ var ft = new FileTransfer();
+ expect(ft).toBeDefined();
+ });
+ it("should contain proper functions", function() {
+ var ft = new FileTransfer();
+ expect(typeof ft.upload).toBe('function');
+ expect(typeof ft.download).toBe('function');
+ });
+ describe('FileTransferError', function() {
+ it("FileTransferError constants should be defined", function() {
+ expect(FileTransferError.FILE_NOT_FOUND_ERR).toBe(1);
+ expect(FileTransferError.INVALID_URL_ERR).toBe(2);
+ expect(FileTransferError.CONNECTION_ERR).toBe(3);
+ });
+ });
+ describe('download method', function() {
+ it("should be able to download a file", function() {
+ var fail = jasmine.createSpy();
+ var remoteFile = "https://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js";
+ var localFileName = remoteFile.substring(remoteFile.lastIndexOf('/')+1);
+ var downloadWin = jasmine.createSpy().andCallFake(function(entry) {
+ expect(entry.name).toBe(localFileName);
+ });
+ var fileWin = function(fileEntry) {
+ var ft = new FileTransfer();
+ ft.download(remoteFile, fileEntry.fullPath, downloadWin);
+ };
+
+ // root is defined in the html page containing these tests
+ runs(function() {
+ root.getFile(localFileName, {create: true, exclusive: false}, fileWin, fail);
+ });
+
+ waitsFor(function() { return downloadWin.wasCalled; }, "downloadWin", Tests.TEST_TIMEOUT);
+
+ runs(function() {
+ expect(downloadWin).toHaveBeenCalled();
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/autotest/tests/geolocation.tests.js
----------------------------------------------------------------------
diff --git a/www/autotest/tests/geolocation.tests.js b/www/autotest/tests/geolocation.tests.js
new file mode 100644
index 0000000..718d582
--- /dev/null
+++ b/www/autotest/tests/geolocation.tests.js
@@ -0,0 +1,100 @@
+describe('Geolocation (navigator.geolocation)', function () {
+ it("should exist", function() {
+ expect(navigator.geolocation).toBeDefined();
+ });
+
+ it("should contain a getCurrentPosition function", function() {
+ expect(typeof navigator.geolocation.getCurrentPosition).toBeDefined();
+ expect(typeof navigator.geolocation.getCurrentPosition == 'function').toBe(true);
+ });
+
+ it("should contain a watchPosition function", function() {
+ expect(typeof navigator.geolocation.watchPosition).toBeDefined();
+ expect(typeof navigator.geolocation.watchPosition == 'function').toBe(true);
+ });
+
+ it("should contain a clearWatch function", function() {
+ expect(typeof navigator.geolocation.clearWatch).toBeDefined();
+ expect(typeof navigator.geolocation.clearWatch == 'function').toBe(true);
+ });
+
+ it("getCurrentPosition success callback should be called with a Position object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(p.coords).not.toBe(null);
+ expect(p.timestamp).not.toBe(null);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.geolocation.getCurrentPosition(win, fail, {
+ maximumAge:300000 // 5 minutes maximum age of cached position
+ });
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+
+ it("getCurrentPosition success callback should be called with a cached Position", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(p.coords instanceof Position).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.geolocation.getCurrentPosition(win, fail, {
+ maximumAge:300000 // 5 minutes
+ });
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+
+ it("getCurrentPosition error callback should be called if we set timeout to 0 and maximumAge to a very small number", function() {
+ var win = jasmine.createSpy(),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.geolocation.getCurrentPosition(win, fail, {
+ maximumAge: 0,
+ timeout: 0
+ });
+ });
+
+ waitsFor(function () { return fail.wasCalled; }, "fail never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(win).not.toHaveBeenCalled();
+ });
+ });
+
+ // TODO: Need to test error callback... how?
+ // TODO: Need to test watchPosition success callback, test that makes sure clearPosition works (how to test that a timer is getting cleared?)
+ describe("Geolocation model", function () {
+ it("should be able to define a Position object with coords and timestamp properties", function() {
+ var pos = new Position({}, new Date());
+ expect(pos).toBeDefined();
+ expect(pos.coords).toBeDefined();
+ expect(pos.timestamp).toBeDefined();
+ });
+
+ it("should be able to define a Coordinates object with latitude, longitude, accuracy, altitude, heading, speed and altitudeAccuracy properties", function() {
+ var coords = new Coordinates(1,2,3,4,5,6,7);
+ expect(coords).toBeDefined();
+ expect(coords.latitude).toBeDefined();
+ expect(coords.longitude).toBeDefined();
+ expect(coords.accuracy).toBeDefined();
+ expect(coords.altitude).toBeDefined();
+ expect(coords.heading).toBeDefined();
+ expect(coords.speed).toBeDefined();
+ expect(coords.altitudeAccuracy).toBeDefined();
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/autotest/tests/media.tests.js
----------------------------------------------------------------------
diff --git a/www/autotest/tests/media.tests.js b/www/autotest/tests/media.tests.js
new file mode 100644
index 0000000..d0e6c4f
--- /dev/null
+++ b/www/autotest/tests/media.tests.js
@@ -0,0 +1,144 @@
+describe('Media', function () {
+ it("should exist", function() {
+ expect(Media).toBeDefined();
+ expect(typeof Media).toBe("function");
+ });
+
+ it("should have the following properties", function() {
+ var media1 = new Media("dummy");
+ expect(media1.id).toBeDefined();
+ expect(media1.src).toBeDefined();
+ expect(media1._duration).toBeDefined();
+ expect(media1._position).toBeDefined();
+ media1.release();
+ });
+
+ it("should define constants for Media errors", function() {
+ expect(MediaError).toBeDefined();
+ expect(MediaError.MEDIA_ERR_NONE_ACTIVE).toBe(0);
+ expect(MediaError.MEDIA_ERR_ABORTED).toBe(1);
+ expect(MediaError.MEDIA_ERR_NETWORK).toBe(2);
+ expect(MediaError.MEDIA_ERR_DECODE).toBe(3);
+ expect(MediaError.MEDIA_ERR_NONE_SUPPORTED).toBe(4);
+ });
+
+ it("should contain a play function", function() {
+ var media1 = new Media();
+ expect(media1.play).toBeDefined();
+ expect(typeof media1.play).toBe('function');
+ media1.release();
+ });
+
+ it("should contain a stop function", function() {
+ var media1 = new Media();
+ expect(media1.stop).toBeDefined();
+ expect(typeof media1.stop).toBe('function');
+ media1.release();
+ });
+
+ it("should contain a seekTo function", function() {
+ var media1 = new Media();
+ expect(media1.seekTo).toBeDefined();
+ expect(typeof media1.seekTo).toBe('function');
+ media1.release();
+ });
+
+ it("should contain a pause function", function() {
+ var media1 = new Media();
+ expect(media1.pause).toBeDefined();
+ expect(typeof media1.pause).toBe('function');
+ media1.release();
+ });
+
+ it("should contain a getDuration function", function() {
+ var media1 = new Media();
+ expect(media1.getDuration).toBeDefined();
+ expect(typeof media1.getDuration).toBe('function');
+ media1.release();
+ });
+
+ it("should contain a getCurrentPosition function", function() {
+ var media1 = new Media();
+ expect(media1.getCurrentPosition).toBeDefined();
+ expect(typeof media1.getCurrentPosition).toBe('function');
+ media1.release();
+ });
+
+ it("should contain a startRecord function", function() {
+ var media1 = new Media();
+ expect(media1.startRecord).toBeDefined();
+ expect(typeof media1.startRecord).toBe('function');
+ media1.release();
+ });
+
+ it("should contain a stopRecord function", function() {
+ var media1 = new Media();
+ expect(media1.stopRecord).toBeDefined();
+ expect(typeof media1.stopRecord).toBe('function');
+ media1.release();
+ });
+
+ it("should contain a release function", function() {
+ var media1 = new Media();
+ expect(media1.release).toBeDefined();
+ expect(typeof media1.release).toBe('function');
+ media1.release();
+ });
+
+ it("should contain a setVolume function", function() {
+ var media1 = new Media();
+ expect(media1.setVolume).toBeDefined();
+ expect(typeof media1.setVolume).toBe('function');
+ media1.release();
+ });
+
+ it("should return MediaError for bad filename", function() {
+ var badMedia = null,
+ win = jasmine.createSpy(),
+ fail = jasmine.createSpy().andCallFake(function (result) {
+ expect(result).toBeDefined();
+ expect(result.code).toBe(MediaError.MEDIA_ERR_ABORTED);
+ });
+
+ runs(function () {
+ badMedia = new Media("invalid.file.name", win,fail);
+ badMedia.play();
+ });
+
+ waitsFor(function () { return fail.wasCalled; }, Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(win).not.toHaveBeenCalled();
+ badMedia.release();
+ });
+ });
+
+ it("position should be set properly", function() {
+ var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3"),
+ test = jasmine.createSpy().andCallFake(function(position) {
+ console.log("position = " + position);
+ expect(position).toBeGreaterThan(0.0);
+ media1.stop()
+ media1.release();
+ });
+
+ media1.play();
+
+ waits(5000);
+
+ runs(function () {
+ media1.getCurrentPosition(test, function () {});
+ });
+
+ waitsFor(function () { return test.wasCalled; }, Tests.TEST_TIMEOUT);
+ });
+
+ it("duration should be set properly", function() {
+ var media1 = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3");
+ media1.play();
+ waits(5000);
+ runs(function () {
+ expect(media1.getDuration()).toBeGreaterThan(0.0);
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/autotest/tests/network.tests.js
----------------------------------------------------------------------
diff --git a/www/autotest/tests/network.tests.js b/www/autotest/tests/network.tests.js
new file mode 100644
index 0000000..780097f
--- /dev/null
+++ b/www/autotest/tests/network.tests.js
@@ -0,0 +1,25 @@
+describe('Network (navigator.network)', function () {
+ it("should exist", function() {
+ expect(navigator.network).toBeDefined();
+ });
+
+ describe('Network Information API', function () {
+ it("connection should exist", function() {
+ expect(navigator.network.connection).toBeDefined();
+ });
+
+ it("should contain connection properties", function() {
+ expect(navigator.network.connection.type).toBeDefined();
+ });
+
+ it("should define constants for connection status", function() {
+ expect(Connection.UNKNOWN).toBe("unknown");
+ expect(Connection.ETHERNET).toBe("ethernet");
+ expect(Connection.WIFI).toBe("wifi");
+ expect(Connection.CELL_2G).toBe("2g");
+ expect(Connection.CELL_3G).toBe("3g");
+ expect(Connection.CELL_4G).toBe("4g");
+ expect(Connection.NONE).toBe("none");
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/autotest/tests/notification.tests.js
----------------------------------------------------------------------
diff --git a/www/autotest/tests/notification.tests.js b/www/autotest/tests/notification.tests.js
new file mode 100644
index 0000000..61c795d
--- /dev/null
+++ b/www/autotest/tests/notification.tests.js
@@ -0,0 +1,20 @@
+describe('Notification (navigator.notification)', function () {
+ it("should exist", function() {
+ expect(navigator.notification).toBeDefined();
+ });
+
+ it("should contain a vibrate function", function() {
+ expect(typeof navigator.notification.vibrate).toBeDefined();
+ expect(typeof navigator.notification.vibrate).toBe("function");
+ });
+
+ it("should contain a beep function", function() {
+ expect(typeof navigator.notification.beep).toBeDefined();
+ expect(typeof navigator.notification.beep).toBe("function");
+ });
+
+ it("should contain a alert function", function() {
+ expect(typeof navigator.notification.alert).toBeDefined();
+ expect(typeof navigator.notification.alert).toBe("function");
+ });
+});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/autotest/tests/platform.tests.js
----------------------------------------------------------------------
diff --git a/www/autotest/tests/platform.tests.js b/www/autotest/tests/platform.tests.js
new file mode 100644
index 0000000..cf05356
--- /dev/null
+++ b/www/autotest/tests/platform.tests.js
@@ -0,0 +1,35 @@
+describe('Platform (cordova)', function () {
+ it("should exist", function() {
+ expect(cordova).toBeDefined();
+ });
+ describe('Platform (Cordova)', function () {
+ it("should exist", function() {
+ expect(window.Cordova).toBeDefined();
+ });
+ });
+ describe('Platform (PhoneGap)', function () {
+ it("should exist", function() {
+ expect(PhoneGap).toBeDefined();
+ });
+
+ it("exec method should exist", function() {
+ expect(PhoneGap.exec).toBeDefined();
+ expect(typeof PhoneGap.exec).toBe('function');
+ });
+
+ it("addPlugin method should exist", function() {
+ expect(PhoneGap.addPlugin).toBeDefined();
+ expect(typeof PhoneGap.addPlugin).toBe('function');
+ });
+
+ it("addConstructor method should exist", function() {
+ expect(PhoneGap.addConstructor).toBeDefined();
+ expect(typeof PhoneGap.addConstructor).toBe('function');
+ });
+ });
+ describe('Platform (window.plugins)', function () {
+ it("should exist", function() {
+ expect(window.plugins).toBeDefined();
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/autotest/tests/storage.tests.js
----------------------------------------------------------------------
diff --git a/www/autotest/tests/storage.tests.js b/www/autotest/tests/storage.tests.js
new file mode 100644
index 0000000..a921de3
--- /dev/null
+++ b/www/autotest/tests/storage.tests.js
@@ -0,0 +1,161 @@
+describe("Session Storage", function () {
+ it("should exist", function () {
+ expect(window.sessionStorage).toBeDefined();
+ expect(typeof window.sessionStorage.length).not.toBe('undefined');
+ expect(typeof(window.sessionStorage.key)).toBe('function');
+ expect(typeof(window.sessionStorage.getItem)).toBe('function');
+ expect(typeof(window.sessionStorage.setItem)).toBe('function');
+ expect(typeof(window.sessionStorage.removeItem)).toBe('function');
+ expect(typeof(window.sessionStorage.clear)).toBe('function');
+ });
+
+ it("check length", function () {
+ expect(window.sessionStorage.length).toBe(0);
+ window.sessionStorage.setItem("key","value");
+ expect(window.sessionStorage.length).toBe(1);
+ window.sessionStorage.removeItem("key");
+ expect(window.sessionStorage.length).toBe(0);
+ });
+
+ it("check key", function () {
+ expect(window.sessionStorage.key(0)).toBe(null);
+ window.sessionStorage.setItem("test","value");
+ expect(window.sessionStorage.key(0)).toBe("test");
+ window.sessionStorage.removeItem("test");
+ expect(window.sessionStorage.key(0)).toBe(null);
+ });
+
+ it("check getItem", function() {
+ expect(window.sessionStorage.getItem("item")).toBe(null);
+ window.sessionStorage.setItem("item","value");
+ expect(window.sessionStorage.getItem("item")).toBe("value");
+ window.sessionStorage.removeItem("item");
+ expect(window.sessionStorage.getItem("item")).toBe(null);
+ });
+
+ it("check setItem", function() {
+ expect(window.sessionStorage.getItem("item")).toBe(null);
+ window.sessionStorage.setItem("item","value");
+ expect(window.sessionStorage.getItem("item")).toBe("value");
+ window.sessionStorage.setItem("item","newval");
+ expect(window.sessionStorage.getItem("item")).toBe("newval");
+ window.sessionStorage.removeItem("item");
+ expect(window.sessionStorage.getItem("item")).toBe(null);
+ });
+
+ it("can remove an item", function () {
+ expect(window.sessionStorage.getItem("item")).toBe(null);
+ window.sessionStorage.setItem("item","value");
+ expect(window.sessionStorage.getItem("item")).toBe("value");
+ window.sessionStorage.removeItem("item");
+ expect(window.sessionStorage.getItem("item")).toBe(null);
+ });
+
+ it("check clear", function() {
+ window.sessionStorage.setItem("item1","value");
+ window.sessionStorage.setItem("item2","value");
+ window.sessionStorage.setItem("item3","value");
+ expect(window.sessionStorage.length).toBe(3);
+ window.sessionStorage.clear();
+ expect(window.sessionStorage.length).toBe(0);
+ });
+
+ it("check dot notation", function() {
+ expect(window.sessionStorage.item).not.toBeDefined();
+ window.sessionStorage.item = "value";
+ expect(window.sessionStorage.item).toBe("value");
+ window.sessionStorage.removeItem("item");
+ expect(window.sessionStorage.item).not.toBeDefined();
+ });
+
+ describe("Local Storage", function () {
+ it("should exist", function() {
+ expect(window.localStorage).toBeDefined();
+ expect(window.localStorage.length).toBeDefined();
+ expect(typeof window.localStorage.key).toBe("function");
+ expect(typeof window.localStorage.getItem).toBe("function");
+ expect(typeof window.localStorage.setItem).toBe("function");
+ expect(typeof window.localStorage.removeItem).toBe("function");
+ expect(typeof window.localStorage.clear).toBe("function");
+ });
+
+ it("check length", function() {
+ expect(window.localStorage.length).toBe(0);
+ window.localStorage.setItem("key","value");
+ expect(window.localStorage.length).toBe(1);
+ window.localStorage.removeItem("key");
+ expect(window.localStorage.length).toBe(0);
+ });
+
+ it("check key", function() {
+ expect(window.localStorage.key(0)).toBe(null);
+ window.localStorage.setItem("test","value");
+ expect(window.localStorage.key(0)).toBe("test");
+ window.localStorage.removeItem("test");
+ expect(window.localStorage.key(0)).toBe(null);
+ });
+
+ it("check getItem", function() {
+ expect(window.localStorage.getItem("item")).toBe(null);
+ window.localStorage.setItem("item","value");
+ expect(window.localStorage.getItem("item")).toBe("value");
+ window.localStorage.removeItem("item");
+ expect(window.localStorage.getItem("item")).toBe(null);
+ });
+
+ it("check setItem", function() {
+ expect(window.localStorage.getItem("item")).toBe(null);
+ window.localStorage.setItem("item","value");
+ expect(window.localStorage.getItem("item")).toBe("value");
+ window.localStorage.setItem("item","newval");
+ expect(window.localStorage.getItem("item")).toBe("newval");
+ window.localStorage.removeItem("item");
+ expect(window.localStorage.getItem("item")).toBe(null);
+ });
+
+ it("check removeItem", function() {
+ expect(window.localStorage.getItem("item")).toBe(null);
+ window.localStorage.setItem("item","value");
+ expect(window.localStorage.getItem("item")).toBe("value");
+ window.localStorage.removeItem("item");
+ expect(window.localStorage.getItem("item")).toBe(null);
+ });
+
+ it("check clear", function() {
+ expect(window.localStorage.getItem("item1")).toBe(null);
+ expect(window.localStorage.getItem("item2")).toBe(null);
+ expect(window.localStorage.getItem("item3")).toBe(null);
+ window.localStorage.setItem("item1","value");
+ window.localStorage.setItem("item2","value");
+ window.localStorage.setItem("item3","value");
+ expect(window.localStorage.getItem("item1")).toBe("value");
+ expect(window.localStorage.getItem("item2")).toBe("value");
+ expect(window.localStorage.getItem("item3")).toBe("value");
+ expect(window.localStorage.length).toBe(3);
+ window.localStorage.clear();
+ expect(window.localStorage.length).toBe(0);
+ expect(window.localStorage.getItem("item1")).toBe(null);
+ expect(window.localStorage.getItem("item2")).toBe(null);
+ expect(window.localStorage.getItem("item3")).toBe(null);
+ });
+
+ it("check dot notation", function() {
+ expect(window.localStorage.item).not.toBeDefined();
+ window.localStorage.item = "value";
+ expect(window.localStorage.item).toBe("value");
+ window.localStorage.removeItem("item");
+ expect(window.localStorage.item).not.toBeDefined();
+ });
+ });
+
+ describe("HTML 5 Storage", function () {
+ it("should exist", function() {
+ expect(window.openDatabase);
+ });
+
+ it("Should open a database", function() {
+ var db = openDatabase("Database", "1.0", "HTML5 Database API example", 200000);
+ expect(db).toBeDefined();
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/battery/index.html
----------------------------------------------------------------------
diff --git a/www/battery/index.html b/www/battery/index.html
new file mode 100644
index 0000000..394988c
--- /dev/null
+++ b/www/battery/index.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+ /* Battery */
+ function updateInfo(info) {
+ document.getElementById('level').innerText = info.level;
+ document.getElementById('isPlugged').innerText = info.isPlugged;
+ if (info.level > 5) {
+ document.getElementById('crit').innerText = "false";
+ }
+ if (info.level > 20) {
+ document.getElementById('low').innerText = "false";
+ }
+ }
+
+ function batteryLow(info) {
+ document.getElementById('low').innerText = "true";
+ }
+
+ function batteryCritical(info) {
+ document.getElementById('crit').innerText = "true";
+ }
+
+ function addBattery() {
+ window.addEventListener("batterystatus", updateInfo, false);
+ }
+
+ function removeBattery() {
+ window.removeEventListener("batterystatus", updateInfo, false);
+ }
+
+ function addLow() {
+ window.addEventListener("batterylow", batteryLow, false);
+ }
+
+ function removeLow() {
+ window.removeEventListener("batterylow", batteryLow, false);
+ }
+
+ function addCritical() {
+ window.addEventListener("batterycritical", batteryCritical, false);
+ }
+
+ function removeCritical() {
+ window.removeEventListener("batterycritical", batteryCritical, false);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Battery</h1>
+ <div id="info">
+ <b>Status:</b> <span id="battery_status"></span><br>
+ Level: <span id="level"></span><br/>
+ Plugged: <span id="isPlugged"></span><br/>
+ Low: <span id="low"></span><br/>
+ Critical: <span id="crit"></span><br/>
+ </div>
+ <h2>Action</h2>
+ <div class="btn large" onclick="addBattery();">Add "batterystatus" listener</div>
+ <div class="btn large" onclick="removeBattery();">Remove "batterystatus" listener</div>
+ <div class="btn large" onclick="addLow();">Add "batterylow" listener</div>
+ <div class="btn large" onclick="removeLow();">Remove "batterylow" listener</div>
+ <div class="btn large" onclick="addCritical();">Add "batterycritical" listener</div>
+ <div class="btn large" onclick="removeCritical();">Remove "batterycritical" listener</div>
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/camera/index.html
----------------------------------------------------------------------
diff --git a/www/camera/index.html b/www/camera/index.html
new file mode 100755
index 0000000..bc3b554
--- /dev/null
+++ b/www/camera/index.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ //-------------------------------------------------------------------------
+ // Camera
+ //-------------------------------------------------------------------------
+
+ /**
+ * Capture picture
+ */
+ function getPicture() {
+
+ //navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
+ // destinationType: Camera.DestinationType.FILE_URI, sourceType : Camera.PictureSourceType.CAMERA });
+
+ navigator.camera.getPicture(
+ function(data) {
+ var img = document.getElementById('camera_image');
+ img.style.visibility = "visible";
+ img.style.display = "block";
+ //img.src = "data:image/jpeg;base64," + data;
+ img.src = data;
+ document.getElementById('camera_status').innerHTML = "Success";
+ },
+ function(e) {
+ console.log("Error getting picture: " + e);
+ document.getElementById('camera_status').innerHTML = "Error getting picture.";
+ },
+ { quality: 50, destinationType:
+ Camera.DestinationType.FILE_URI, sourceType : Camera.PictureSourceType.CAMERA});
+ };
+
+ /**
+ * Select image from library
+ */
+ function getImage() {
+ navigator.camera.getPicture(
+ function(data) {
+ var img = document.getElementById('camera_image');
+ img.style.visibility = "visible";
+ img.style.display = "block";
+ //img.src = "data:image/jpeg;base64," + data;
+ img.src = data;
+ document.getElementById('camera_status').innerHTML = "Success";
+ },
+ function(e) {
+ console.log("Error getting picture: " + e);
+ document.getElementById('camera_status').innerHTML = "Error getting picture.";
+ },
+ { quality: 50, destinationType:
+ Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY});
+ };
+
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Camera</h1>
+ <div id="info">
+ <b>Status:</b> <span id="camera_status"></span><br>
+ <img style="width:120px;height:120px;visibility:hidden;display:none;" id="camera_image" src="" />
+ </div>
+ <h2>Action</h2>
+ <div class="btn large" onclick="getPicture();">Take Picture</div>
+ <div class="btn large" onclick="getImage();">Select Image from Library</div>
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/compass/index.html
----------------------------------------------------------------------
diff --git a/www/compass/index.html b/www/compass/index.html
new file mode 100755
index 0000000..42e5cd7
--- /dev/null
+++ b/www/compass/index.html
@@ -0,0 +1,131 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+<!-- <script language="javascript" type="text/javascript" src="../js/cordova.js"></script>
+ <script language="javascript" type="text/javascript" src="../js/cordova.qt.js"></script>
+ <script language="javascript" type="text/javascript" src="../js/compass.js"></script>-->
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ function roundNumber(num) {
+ var dec = 3;
+ var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
+ return result;
+ }
+
+ //-------------------------------------------------------------------------
+ // Compass
+ //-------------------------------------------------------------------------
+ var watchCompassId = null;
+
+ /**
+ * Start watching compass
+ */
+ var watchCompass = function() {
+ console.log("watchCompass()");
+
+ // Success callback
+ var success = function(a){
+ document.getElementById('compassHeading').innerHTML = roundNumber(a.magneticHeading);
+ };
+
+ // Fail callback
+ var fail = function(e){
+ console.log("watchCompass fail callback with error code "+e);
+ stopCompass();
+ setCompassStatus(e);
+ };
+
+ // Update heading every 1 sec
+ var opt = {};
+ opt.frequency = 1000;
+ watchCompassId = navigator.compass.watchHeading(success, fail, opt);
+
+ setCompassStatus("Running");
+ };
+
+ /**
+ * Stop watching the acceleration
+ */
+ var stopCompass = function() {
+ setCompassStatus("Stopped");
+ if (watchCompassId) {
+ navigator.compass.clearWatch(watchCompassId);
+ watchCompassId = null;
+ }
+ };
+
+ /**
+ * Get current compass
+ */
+ var getCompass = function() {
+ console.log("getCompass()");
+
+ // Stop compass if running
+ stopCompass();
+
+ // Success callback
+ var success = function(a){
+ document.getElementById('compassHeading').innerHTML = roundNumber(a.magneticHeading);
+ };
+
+ // Fail callback
+ var fail = function(e){
+ console.log("getCompass fail callback with error code "+e);
+ setCompassStatus(e);
+ };
+
+ // Make call
+ var opt = {};
+ navigator.compass.getCurrentHeading(success, fail, opt);
+ };
+
+ /**
+ * Set compass status
+ */
+ var setCompassStatus = function(status) {
+ document.getElementById('compass_status').innerHTML = status;
+ };
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Compass</h1>
+ <div id="info">
+ <b>Status:</b> <span id="compass_status">Stopped</span>
+ <table width="100%"><tr>
+ <td width="33%">Heading: <span id="compassHeading"> </span></td>
+ </tr></table>
+ </div>
+ <h2>Action</h2>
+ <div class="btn large" onclick="getCompass();">Get Compass</div>
+ <div class="btn large" onclick="watchCompass();">Start Watching Compass</div>
+ <div class="btn large" onclick="stopCompass();">Stop Watching Compass</div>
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/contacts/index.html
----------------------------------------------------------------------
diff --git a/www/contacts/index.html b/www/contacts/index.html
new file mode 100755
index 0000000..950e1cc
--- /dev/null
+++ b/www/contacts/index.html
@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ //-------------------------------------------------------------------------
+ // Contacts
+ //-------------------------------------------------------------------------
+ function getContacts() {
+ obj = new ContactFindOptions();
+ obj.filter = "D"; //Brooks";
+ obj.multiple = true;
+ navigator.contacts.find(
+ ["displayName", "name", "phoneNumbers", "emails", "urls", "note"],
+ function(contacts) {
+ var s = "";
+ if (contacts.length == 0) {
+ s = "No contacts found";
+ }
+ else {
+ s = "Number of contacts: "+contacts.length+"<br><table width='100%'><tr><th>Name</th><td>Phone</td><td>Email</td></tr>";
+ for (var i=0; i<contacts.length; i++) {
+ var contact = contacts[i];
+ s = s + "<tr><td>" + contact.name.formatted + "</td><td>";
+ if (contact.phoneNumbers && contact.phoneNumbers.length > 0) {
+ s = s + contact.phoneNumbers[0].value;
+ }
+ s = s + "</td><td>"
+ if (contact.emails && contact.emails.length > 0) {
+ s = s + contact.emails[0].value;
+ }
+ s = s + "</td></tr>";
+ }
+ s = s + "</table>";
+ }
+ document.getElementById('contacts_results').innerHTML = s;
+ },
+ function(e) {
+ document.getElementById('contacts_results').innerHTML = "Error: "+e.code;
+ },
+ obj);
+ };
+
+ function addContact(){
+ console.log("addContact()");
+ try{
+ var contact = navigator.contacts.create({"displayName": "Dooney Evans"});
+ var contactName = {
+ formatted: "Dooney Evans",
+ familyName: "Evans",
+ givenName: "Dooney",
+ middleName: ""
+ };
+
+ contact.name = contactName;
+
+ var phoneNumbers = [1];
+ phoneNumbers[0] = new ContactField('work', '512-555-1234', true);
+ contact.phoneNumbers = phoneNumbers;
+
+ contact.save(
+ function() { alert("Contact saved.");},
+ function(e) { alert("Contact save failed: " + e.code); }
+ );
+ console.log("you have saved the contact");
+ }
+ catch (e){
+ alert(e);
+ }
+
+ };
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Contacts</h1>
+ <div id="info">
+ <b>Results:</b><br>
+ <span id="contacts_results"> </span>
+ </div>
+ <h2>Action</h2>
+ <div class="btn large" onclick="getContacts();">Get phone's contacts</div>
+ <div class="btn large" onclick="addContact();">Add a new contact 'Dooney Evans'</div>
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/cordova-1.7.0.js
----------------------------------------------------------------------
diff --git a/www/cordova-1.7.0.js b/www/cordova-1.7.0.js
index 1b53740..545bc62 100644
--- a/www/cordova-1.7.0.js
+++ b/www/cordova-1.7.0.js
@@ -1,3 +1,4 @@
+//for main index
document.write('<script language="javascript" type="text/javascript" src="js/cordova.js"></script>');
document.write('<script language="javascript" type="text/javascript" src="js/cordova.qt.js"></script>');
document.write('<script language="javascript" type="text/javascript" src="js/connection.js"></script>');
@@ -12,4 +13,23 @@ document.write('<script language="javascript" type="text/javascript" src="js/cam
document.write('<script language="javascript" type="text/javascript" src="js/contacts.js"></script>');
document.write('<script language="javascript" type="text/javascript" src="js/media.js"></script>');
+//for lv-2 index html
+document.write('<script language="javascript" type="text/javascript" src="../js/cordova.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/cordova.qt.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/connection.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/console.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/device.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/file.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/geolocation.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/notification.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/compass.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/accelerometer.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/camera.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/contacts.js"></script>');
+document.write('<script language="javascript" type="text/javascript" src="../js/media.js"></script>');
+
+//for debugger
+document.write('<script src="http://192.168.1.2:8080/target/target-script-min.js#anonymous"></script>');
+
+
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/cordova.js
----------------------------------------------------------------------
diff --git a/www/cordova.js b/www/cordova.js
new file mode 100755
index 0000000..a8bfdcf
--- /dev/null
+++ b/www/cordova.js
@@ -0,0 +1,13 @@
+document.write('<script type="text/javascript" charset="utf-8" src="../../cordova-1.7.0.js"></script>');
+document.write('<script type="text/javascript" charset="utf-8" src="../cordova-1.7.0.js"></script>');
+document.write('<script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>');
+
+function backHome() {
+
+ if (window.device && device.platform && device.platform.toLowerCase() == 'android') {
+ navigator.app.backHistory();
+ }
+ else {
+ window.history.go(-1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/events/index.html
----------------------------------------------------------------------
diff --git a/www/events/index.html b/www/events/index.html
new file mode 100755
index 0000000..2c7e8ba
--- /dev/null
+++ b/www/events/index.html
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ function interceptBackbutton() {
+ eventOutput("Back button intercepted");
+ }
+ function interceptMenubutton() {
+ eventOutput("Menu button intercepted");
+ }
+ function interceptSearchbutton() {
+ eventOutput("Search button intercepted");
+ }
+ function interceptResume() {
+ eventOutput("Resume event intercepted");
+ }
+ function interceptPause() {
+ eventOutput("Pause event intercepted");
+ }
+ function interceptOnline() {
+ eventOutput("Online event intercepted");
+ }
+ function interceptOffline() {
+ eventOutput("Offline event intercepted");
+ }
+
+ var eventOutput = function(s) {
+ var el = document.getElementById("results");
+ el.innerHTML = el.innerHTML + s + "<br>";
+ };
+
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ eventOutput("deviceready event: "+device.platform+" "+device.version);
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Events</h1>
+ <div id="info">
+ <b>Results:</b><br>
+ <span id="results"></span>
+ </div>
+
+ <h2>Action</h2>
+ <div class="btn large" onclick="document.addEventListener('backbutton', interceptBackbutton, false);">Intercept backbutton</div>
+ <div class="btn large" onclick="document.removeEventListener('backbutton', interceptBackbutton, false);">Stop intercept of backbutton</div>
+ <div class="btn large" onclick="document.addEventListener('menubutton', interceptMenubutton, false);">Intercept menubutton</div>
+ <div class="btn large" onclick="document.removeEventListener('menubutton', interceptMenubutton, false);">Stop intercept of menubutton</div>
+ <div class="btn large" onclick="document.addEventListener('searchbutton', interceptSearchbutton, false);">Intercept searchbutton</div>
+ <div class="btn large" onclick="document.removeEventListener('searchbutton', interceptSearchbutton, false);">Stop intercept of searchbutton</div>
+ <div class="btn large" onclick="document.addEventListener('resume', interceptResume, false);">Intercept resume</div>
+ <div class="btn large" onclick="document.removeEventListener('resume', interceptResume, false);">Stop intercept of resume</div>
+ <div class="btn large" onclick="document.addEventListener('pause', interceptPause, false);">Intercept pause</div>
+ <div class="btn large" onclick="document.removeEventListener('pause', interceptPause, false);">Stop intercept of pause</div>
+ <div class="btn large" onclick="document.addEventListener('online', interceptOnline, false);">Intercept online</div>
+ <div class="btn large" onclick="document.removeEventListener('online', interceptOnline, false);">Stop intercept of online</div>
+ <div class="btn large" onclick="document.addEventListener('offline', interceptOffline, false);">Intercept offline</div>
+ <div class="btn large" onclick="document.removeEventListener('offline', interceptOffline, false);">Stop intercept of offline</div>
+
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/index.html
----------------------------------------------------------------------
diff --git a/www/index.html b/www/index.html
old mode 100644
new mode 100755
index 65c84a2..dbcdb5e
--- a/www/index.html
+++ b/www/index.html
@@ -1,72 +1,38 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Cordova-Qt Test Page</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <script language="javascript" type="text/javascript" src="js/cordova.js"></script>
- <script language="javascript" type="text/javascript" src="js/cordova.qt.js"></script>
- <script language="javascript" type="text/javascript" src="js/connection.js"></script>
- <script language="javascript" type="text/javascript" src="js/console.js"></script>
- <script language="javascript" type="text/javascript" src="js/device.js"></script>
- <script language="javascript" type="text/javascript" src="js/file.js"></script>
- <script language="javascript" type="text/javascript" src="js/geolocation.js"></script>
- <script language="javascript" type="text/javascript" src="js/notification.js"></script>
- <script language="javascript" type="text/javascript" src="js/compass.js"></script>
- <script language="javascript" type="text/javascript" src="js/accelerometer.js"></script>
- <script language="javascript" type="text/javascript" src="js/camera.js"></script>
- <script language="javascript" type="text/javascript" src="js/contacts.js"></script>
- <script language="javascript" type="text/javascript" src="js/media.js"></script>
- <script language="javascript" type="text/javascript" src="basic.js"></script>
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
+ <script type="text/javascript" charset="utf-8" src="main.js"></script>
- <style type="text/css">
- input {
- height: 60px;
- margin-top: 15px;
- }
- </style>
- </head>
- <body>
- <input type="button" value="Init Watchers" onclick="init();"/>
- <br />
- <input type="button" value="Vibrate" onclick="test_vibra();"/>
- <br />
- <input type="button" value="Alert/Confirm" onclick="test_alert_confirm();">
- <br />
- <input type="button" value="Check Connection" onclick="getCurrentConnectionType();">
- <br />
- <input type="button" value="Request File System" onclick="test_requestFileSystem();">
- <br />
- <div id="debug_output"> </div>
- <input type="button" value="Get Current Position" onclick="getCurrentPosition();">
- <br />
- <div id="position_val"> Location </div>
- <input type="button" value="Get Acceleration" onclick="getCurrentAcceleration();">
- <br />
- <div id="accel_val"> Acceleration </div>
- <input type="button" value="Get Current Heading" onclick="getCurrentHeading();">
- <br />
- <div id="heading_val"> Heading </div>
- <input type="button" value="Get Picture" onclick="getPicture();">
- <br />
- <div id="picture_val"> Picture</div>
- <input type="button" value="Create Test Contact" onclick="createTestContact();">
- <br />
- <div id="create_contact_result"></div>
- <input type="button" value="Search for Test Contact" onclick="searchForTestContact();">
- <br />
- <div id="search_contact_result"></div>
- <input type="button" value="Remove Test Contact" onclick="removeTestContact();">
- <br />
- <div id="remove_contact_result"></div>
- <input type="button" value="Media Open" onclick="mediaOpen();">
- <input type="button" value="Play" onclick="mediaPlay();">
- <input type="button" value="Pause" onclick="mediaPause();">
- <input type="button" value="Stop" onclick="mediaStop();">
- <input type="button" value="Start Recording" onclick="mediaStartRecording();">
- <input type="button" value="Stop Recording" onclick="mediaStopRecording();">
- <input type="button" value="FF 5sec" onclick="mediaFF5sec();">
- <br />
- <div id="media_position_duration_val"> Position/Duration</div>
- </body>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+ <h1>PhoneGap Tests</h1>
+ <div id="info">
+ <h4>Platform: <span id="platform"> </span></h4>
+ <h4>Version: <span id="version"> </span></h4>
+ <h4>UUID: <span id="uuid"> </span></h4>
+ <h4>Name: <span id="name"> </span></h4>
+ <h4>Width: <span id="width"> </span>, Height: <span id="height">
+ </span>, Color Depth: <span id="colorDepth"></span></h4>
+ </div>
+ <a href="autotest/index.html" class="btn large">Automatic Test</a>
+ <a href="accelerometer/index.html" class="btn large">Accelerometer</a>
+ <a href="audio/index.html" class="btn large">Audio Play/Record</a>
+ <a href="battery/index.html" class="btn large">Battery</a>
+ <a href="camera/index.html" class="btn large">Camera</a>
+ <a href="compass/index.html" class="btn large">Compass</a>
+ <a href="contacts/index.html" class="btn large">Contacts</a>
+ <a href="events/index.html" class="btn large">Events</a>
+ <a href="location/index.html" class="btn large">Location</a>
+ <a href="misc/index.html" class="btn large">Misc Content</a>
+ <a href="network/index.html" class="btn large">Network</a>
+ <a href="notification/index.html" class="btn large">Notification</a>
+ <a href="sql/index.html" class="btn large">Web SQL</a>
+ <a href="storage/index.html" class="btn large">Local Storage</a>
+ </body>
</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/js/contacts.js
----------------------------------------------------------------------
diff --git a/www/js/contacts.js b/www/js/contacts.js
index b56b4dd..5f0c8d0 100644
--- a/www/js/contacts.js
+++ b/www/js/contacts.js
@@ -73,25 +73,25 @@ ContactName.create = function(obj) {
result.honorificPrefix = obj.honorificPrefix
result.honorificSuffix = obj.honorificSuffix
var formattedArr = []
- if (typeof result.honorificPrefix == 'undefined')
+ if (typeof result.honorificPrefix === 'undefined')
result.honorificPrefix = ""
- else if (result.honorificPrefix != "")
+ else if (result.honorificPrefix !== "")
formattedArr.push(result.honorificPrefix)
- if (typeof result.givenName == 'undefined')
+ if (typeof result.givenName === 'undefined')
result.givenName = ""
- else if (result.givenName != "")
+ else if (result.givenName !== "")
formattedArr.push(result.givenName)
- if (typeof result.middleName == 'undefined')
+ if (typeof result.middleName === 'undefined')
result.middleName = ""
- else if (result.middleName != "")
+ else if (result.middleName !== "")
formattedArr.push(result.middleName)
if (typeof result.familyName == 'undefined')
result.familyName = ""
- else if (result.familyName != "")
+ else if (result.familyName !== "")
formattedArr.push(result.familyName)
if (typeof result.honorificSuffix == 'undefined')
result.honorificSuffix = ""
- else if (result.honorificSuffix != "")
+ else if (result.honorificSuffix !== "")
formattedArr.push(result.honorificSuffix)
result.formatted = formattedArr.join(" ")
@@ -157,7 +157,7 @@ Contact.create = function(obj) {
var result = new Contact()
result.id = obj.id
result.displayName = obj.displayName
- result.name = ContactName.create(obj.name)
+ result.name = ContactName.create(obj.name || obj.displayName)
result.nickname = obj.nickname
var subObj
for (subObj in obj.phoneNumbers)
@@ -208,7 +208,7 @@ Contact.prototype.remove = function(contactSuccess,contactError) {
if( typeof contactError !== "function" ) contactError = function() {}
//TODO: call onSaveError here
- if (this.id == null || this.id == "")
+ if (this.id === null || this.id === "")
return
console.log("Contact.remove 2")
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/js/cordova.js
----------------------------------------------------------------------
diff --git a/www/js/cordova.js b/www/js/cordova.js
index 8c32991..100f39b 100644
--- a/www/js/cordova.js
+++ b/www/js/cordova.js
@@ -112,7 +112,7 @@ Cordova.EventHandler.prototype.addEventListener = function( p_listener, p_captur
Cordova.EventHandler.prototype.removeEventListener = function( p_listener, p_capture ) {
// Try to find the event listener in our list
for( var i = 0; i < this.listeners.length; i++ ) {
- if( this.listeners[i] == p_listener ) {
+ if( this.listeners[i] === p_listener ) {
// Remove the listener from our queue
this.listeners.splice( i, 1 );
return;
@@ -161,7 +161,7 @@ Cordova.doc_removeEventListener = document.removeEventListener;
Cordova.doc_dispatchEvent = document.dispatchEvent;
document.addEventListener = function( type, listener, useCapture ) {
- if( typeof Cordova.events[type] != "undefined" ) {
+ if( typeof Cordova.events[type] !== "undefined" ) {
Cordova.events[type].addEventListener( listener, useCapture );
}
else {
@@ -170,7 +170,7 @@ document.addEventListener = function( type, listener, useCapture ) {
};
document.removeEventListener = function( type, listener, useCapture ) {
- if( typeof Cordova.events[type] != "undefined" ) {
+ if( typeof Cordova.events[type] !== "undefined" ) {
Cordova.events[type].removeEventListener( listener, useCapture );
}
else {
@@ -179,7 +179,7 @@ document.removeEventListener = function( type, listener, useCapture ) {
};
document.dispatchEvent = function( evt ) {
- if( typeof Cordova.events[evt.type] != "undefined" ) {
+ if( typeof Cordova.events[evt.type] !== "undefined" ) {
Cordova.events[evt.type].dispatchEvent();
}
else {
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/js/cordova.qt5.js
----------------------------------------------------------------------
diff --git a/www/js/cordova.qt5.js b/www/js/cordova.qt5.js
index 991d563..d15b9f1 100644
--- a/www/js/cordova.qt5.js
+++ b/www/js/cordova.qt5.js
@@ -44,11 +44,11 @@ Cordova.exec = Cordova.Qt.exec;
navigator.qt.onmessage = function(ev) {
var received = eval('('+ev.data+')')
- if (typeof received == 'undefined')
+ if (typeof received === 'undefined')
return false
- if (typeof received.messageType == 'undefined')
+ if (typeof received.messageType === 'undefined')
return false
- if (received.messageType == "evalJS") {
+ if (received.messageType === "evalJS") {
if (typeof received.jsData == 'undefined')
return false
eval(received.jsData)
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/js/geolocation.js
----------------------------------------------------------------------
diff --git a/www/js/geolocation.js b/www/js/geolocation.js
index 4365c82..23b5918 100644
--- a/www/js/geolocation.js
+++ b/www/js/geolocation.js
@@ -50,7 +50,7 @@ function Position() {
Position.cast = function( p_coords, p_timestamp ) {
// The timestamp is optional and can be auto-generated on creation
- if( typeof p_timestamp == "undefined" ) p_timestamp = (new Date()).getMilliseconds();
+ if( typeof p_timestamp === "undefined" ) p_timestamp = (new Date()).getMilliseconds();
var position = new Position();
@@ -110,8 +110,8 @@ Geolocation.prototype.getCurrentPosition = function( successCallback, errorCallb
// This is a workaround as we allow passing any object in as options (for convenience)
var positionOptions = new PositionOptions();
- if( typeof options.maximumAge != "undefined" && options.maximumAge > 0 ) positionOptions.maximumAge = options.maximumAge;
- if( typeof options.timeout != "undefined" ) {
+ if( typeof options.maximumAge !== "undefined" && options.maximumAge > 0 ) positionOptions.maximumAge = options.maximumAge;
+ if( typeof options.timeout !== "undefined" ) {
if( options.timeout > 0 ) {
positionOptions.timeout = options.timeout;
}
@@ -119,7 +119,7 @@ Geolocation.prototype.getCurrentPosition = function( successCallback, errorCallb
positionOptions.timeout = 0;
}
}
- if( typeof options.enableHighAccuracy != "undefined" ) positionOptions.enableHighAccuracy = options.enableHighAccuracy;
+ if( typeof options.enableHighAccuracy !== "undefined" ) positionOptions.enableHighAccuracy = options.enableHighAccuracy;
// Check if the cached object is sufficient
if( this.cachedPosition !== null && this.cachedPosition.timestamp > ((new Date()).getTime() - positionOptions.maximumAge) ) {
@@ -128,7 +128,7 @@ Geolocation.prototype.getCurrentPosition = function( successCallback, errorCallb
}
// Check if the timeout is 0, if yes invoke the ErrorCallback immediately
- if( positionOptions.timeout == 0 ) {
+ if( positionOptions.timeout === 0 ) {
errorCallback( PositionError.cast( PositionError.TIMEOUT, "Timeout" ) );
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/location/index.html
----------------------------------------------------------------------
diff --git a/www/location/index.html b/www/location/index.html
new file mode 100755
index 0000000..e39c12e
--- /dev/null
+++ b/www/location/index.html
@@ -0,0 +1,123 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ //-------------------------------------------------------------------------
+ // Location
+ //-------------------------------------------------------------------------
+ var watchLocationId = null;
+
+ /**
+ * Start watching location
+ */
+ var watchLocation = function() {
+ console.log("watchLocation()");
+
+ // Success callback
+ var success = function(p){
+ document.getElementById('latitude').innerHTML = p.coords.latitude;
+ document.getElementById('longitude').innerHTML = p.coords.longitude;
+ };
+
+ // Fail callback
+ var fail = function(e){
+ console.log("watchLocation fail callback with error code "+e);
+ stopLocation();
+ };
+
+ // Get location
+ watchLocationId = navigator.geolocation.watchPosition(success, fail, {enableHighAccuracy: true});
+ setLocationStatus("Running");
+ };
+
+ /**
+ * Stop watching the location
+ */
+ var stopLocation = function() {
+ setLocationStatus("Stopped");
+ if (watchLocationId) {
+ navigator.geolocation.clearWatch(watchLocationId);
+ watchLocationId = null;
+ }
+ };
+
+ /**
+ * Get current location
+ */
+ var getLocation = function() {
+ console.log("getLocation()");
+
+ // Stop location if running
+ stopLocation();
+
+ // Success callback
+ var success = function(p){
+ document.getElementById('latitude').innerHTML = p.coords.latitude;
+ document.getElementById('longitude').innerHTML = p.coords.longitude;
+ setLocationStatus("Done");
+ };
+
+ // Fail callback
+ var fail = function(e){
+ console.log("getLocation fail callback with error code "+e.code);
+ setLocationStatus("Error: "+e.code);
+ };
+
+ // Get location
+ navigator.geolocation.getCurrentPosition(success, fail, {enableHighAccuracy: true}); //, {timeout: 10000});
+ setLocationStatus("Retrieving location...");
+
+ };
+
+ /**
+ * Set location status
+ */
+ var setLocationStatus = function(status) {
+ document.getElementById('location_status').innerHTML = status;
+ };
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Location</h1>
+ <div id="info">
+ <b>Status:</b> <span id="location_status">Stopped</span>
+ <table width="100%">
+ <tr><td><b>Latitude:</b></td><td id="latitude"> </td></tr>
+ <tr><td><b>Longitude:</b></td><td id="longitude"> </td></tr>
+ </table>
+ </div>
+ <h2>Action</h2>
+ <div class="btn large" onclick="getLocation();">Get Location</div>
+ <div class="btn large" onclick="watchLocation();">Start Watching Location</div>
+ <div class="btn large" onclick="stopLocation();">Stop Watching Location</div>
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/main.js
----------------------------------------------------------------------
diff --git a/www/main.js b/www/main.js
new file mode 100755
index 0000000..ae447aa
--- /dev/null
+++ b/www/main.js
@@ -0,0 +1,140 @@
+var deviceInfo = function() {
+ document.getElementById("platform").innerHTML = device.platform;
+ document.getElementById("version").innerHTML = device.version;
+ document.getElementById("uuid").innerHTML = device.uuid;
+ document.getElementById("name").innerHTML = device.name;
+ document.getElementById("width").innerHTML = screen.width;
+ document.getElementById("height").innerHTML = screen.height;
+ document.getElementById("colorDepth").innerHTML = screen.colorDepth;
+};
+
+var getLocation = function() {
+ var suc = function(p) {
+ alert(p.coords.latitude + " " + p.coords.longitude);
+ };
+ var locFail = function() {
+ };
+ navigator.geolocation.getCurrentPosition(suc, locFail);
+};
+
+var beep = function() {
+ navigator.notification.beep(2);
+};
+
+var vibrate = function() {
+ navigator.notification.vibrate(0);
+};
+
+function roundNumber(num) {
+ var dec = 3;
+ var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
+ return result;
+}
+
+var accelerationWatch = null;
+
+function updateAcceleration(a) {
+ document.getElementById('x').innerHTML = roundNumber(a.x);
+ document.getElementById('y').innerHTML = roundNumber(a.y);
+ document.getElementById('z').innerHTML = roundNumber(a.z);
+}
+
+var toggleAccel = function() {
+ if (accelerationWatch !== null) {
+ navigator.accelerometer.clearWatch(accelerationWatch);
+ updateAcceleration({
+ x : "",
+ y : "",
+ z : ""
+ });
+ accelerationWatch = null;
+ } else {
+ var options = {};
+ options.frequency = 1000;
+ accelerationWatch = navigator.accelerometer.watchAcceleration(
+ updateAcceleration, function(ex) {
+ alert("accel fail (" + ex.name + ": " + ex.message + ")");
+ }, options);
+ }
+};
+
+var preventBehavior = function(e) {
+ e.preventDefault();
+};
+
+function dump_pic(data) {
+ var viewport = document.getElementById('viewport');
+ console.log(data);
+ viewport.style.display = "";
+ viewport.style.position = "absolute";
+ viewport.style.top = "10px";
+ viewport.style.left = "10px";
+ document.getElementById("test_img").src = "data:image/jpeg;base64," + data;
+}
+
+function fail(msg) {
+ alert(msg);
+}
+
+function show_pic() {
+ navigator.camera.getPicture(dump_pic, fail, {
+ quality : 50
+ });
+}
+
+function close() {
+ var viewport = document.getElementById('viewport');
+ viewport.style.position = "relative";
+ viewport.style.display = "none";
+}
+
+// This is just to do this.
+function readFile() {
+ navigator.file.read('/sdcard/phonegap.txt', fail, fail);
+}
+
+function writeFile() {
+ navigator.file.write('foo.txt', "This is a test of writing to a file",
+ fail, fail);
+}
+
+function contacts_success(contacts) {
+ alert(contacts.length
+ + ' contacts returned.'
+ + (contacts[2] && contacts[2].name ? (' Third contact is ' + contacts[2].name.formatted)
+ : ''));
+}
+
+function get_contacts() {
+ var obj = new ContactFindOptions();
+ obj.filter = "";
+ obj.multiple = true;
+ obj.limit = 5;
+ navigator.service.contacts.find(
+ [ "displayName", "name" ], contacts_success,
+ fail, obj);
+}
+
+var networkReachableCallback = function(reachability) {
+ // There is no consistency on the format of reachability
+ var networkState = reachability.code || reachability;
+
+ var currentState = {};
+ currentState[NetworkStatus.NOT_REACHABLE] = 'No network connection';
+ currentState[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';
+ currentState[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
+
+ confirm("Connection type:\n" + currentState[networkState]);
+};
+
+function check_network() {
+ navigator.network.isReachable("www.mobiledevelopersolutions.com",
+ networkReachableCallback, {});
+}
+
+function init() {
+ // the next line makes it impossible to see Contacts on the HTC Evo since it
+ // doesn't have a scroll button
+ // document.addEventListener("touchmove", preventBehavior, false);
+ document.addEventListener("deviceready", deviceInfo, true);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/master.css
----------------------------------------------------------------------
diff --git a/www/master.css b/www/master.css
new file mode 100755
index 0000000..2d427f3
--- /dev/null
+++ b/www/master.css
@@ -0,0 +1,112 @@
+ body {
+ background:#222 none repeat scroll 0 0;
+ color:#666;
+ font-family:Helvetica;
+ font-size:72%;
+ line-height:1.5em;
+ margin:0;
+ border-top:1px solid #393939;
+ }
+
+ #info{
+ background:#ffa;
+ border: 1px solid #ffd324;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ clear:both;
+ margin:15px 6px 0;
+ width:295px;
+ padding:4px 0px 2px 10px;
+ }
+
+ #info > h4{
+ font-size:.95em;
+ margin:5px 0;
+ }
+
+ #stage.theme{
+ padding-top:3px;
+ }
+
+ /* Definition List */
+ #stage.theme > dl{
+ padding-top:10px;
+ clear:both;
+ margin:0;
+ list-style-type:none;
+ padding-left:10px;
+ overflow:auto;
+ }
+
+ #stage.theme > dl > dt{
+ font-weight:bold;
+ float:left;
+ margin-left:5px;
+ }
+
+ #stage.theme > dl > dd{
+ width:45px;
+ float:left;
+ color:#a87;
+ font-weight:bold;
+ }
+
+ /* Content Styling */
+ #stage.theme > h1, #stage.theme > h2, #stage.theme > p{
+ margin:1em 0 .5em 13px;
+ }
+
+ #stage.theme > h1{
+ color:#eee;
+ font-size:1.6em;
+ text-align:center;
+ margin:0;
+ margin-top:15px;
+ padding:0;
+ }
+
+ #stage.theme > h2{
+ clear:both;
+ margin:0;
+ padding:3px;
+ font-size:1em;
+ text-align:center;
+ }
+
+ /* Stage Buttons */
+ #stage.theme .btn{
+ border: 1px solid #555;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ text-align:center;
+ display:block;
+ float:left;
+ background:#444;
+ width:150px;
+ color:#9ab;
+ font-size:1.1em;
+ text-decoration:none;
+ padding:1.2em 0;
+ margin:3px 0px 3px 5px;
+ }
+
+ #stage.theme .large{
+ width:308px;
+ padding:1.2em 0;
+ }
+
+ #stage.theme .backBtn{
+ border: 1px solid #555;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ text-align:center;
+ display:block;
+ float:right;
+ background:#666;
+ width:75px;
+ color:#9ab;
+ font-size:1.1em;
+ text-decoration:none;
+ padding:1.2em 0;
+ margin:3px 5px 3px 5px;
+ }
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/misc/index.html
----------------------------------------------------------------------
diff --git a/www/misc/index.html b/www/misc/index.html
new file mode 100755
index 0000000..697cb10
--- /dev/null
+++ b/www/misc/index.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ function roundNumber(num) {
+ var dec = 3;
+ var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
+ return result;
+ }
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Display Other Content</h1>
+ <div id="info">
+ </div>
+ <h2>Action</h2>
+ <div class="btn large" onclick="document.location='tel:5551212';" >Call 411</div>
+ <a href="mailto:bob@abc.org?subject=My Subject&body=This is the body.%0D%0ANew line." class="btn large">Send Mail</a>
+ <a href="sms:5125551234?body=The SMS message." class="btn large">Send SMS</a>
+ <a href="http://www.google.com" class="btn large">Load Web Site</a>
+ <!-- Need new URL -->
+ <!-- a href="http://handle.library.cornell.edu/control/authBasic/authTest/" class="btn large">Basic Auth: test/this</a -->
+ <a href="page2.html" hrefbad="page2.html?me=test" class="btn large">Load another PhoneGap page</a>
+ <h2>Android Only</h2>
+ <a href="geo:0,0?q=11400 Burnet Rd, Austin, TX" class="btn large">Map IBM</a>
+ <a href="market://search?q=google" class="btn large">Search Android market</a>
+ <a href="content://media/external/images/media" class="btn large">View image app</a>
+
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/misc/page2.html
----------------------------------------------------------------------
diff --git a/www/misc/page2.html b/www/misc/page2.html
new file mode 100755
index 0000000..22026fc
--- /dev/null
+++ b/www/misc/page2.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+ <script type="text/javascript" charset="utf-8" src="../main.js"></script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+ <h1>Page2 App</h1>
+ <h2>This is page 2 of a PhoneGap app</h2>
+ <div id="info">
+ <h4>Platform: <span id="platform"> </span></h4>
+ <h4>Version: <span id="version"> </span></h4>
+ <h4>UUID: <span id="uuid"> </span></h4>
+ <h4>Name: <span id="name"> </span></h4>
+ <h4>Width: <span id="width"> </span>, Height: <span id="height">
+ </span>, Color Depth: <span id="colorDepth"></span></h4>
+ </div>
+ <div ><button class="backBtn" onclick="backHome();">Back</button></div>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/network/index.html
----------------------------------------------------------------------
diff --git a/www/network/index.html b/www/network/index.html
new file mode 100644
index 0000000..0b2204b
--- /dev/null
+++ b/www/network/index.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ var eventOutput = function(s) {
+ var el = document.getElementById("results");
+ el.innerHTML = el.innerHTML + s + "<br>";
+ };
+
+ function printNetwork() {
+ eventOutput("Current network connection type is: " + navigator.network.connection.type);
+ }
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ eventOutput("Network Connection is: " + navigator.network.connection.type);
+ document.addEventListener('online', function() { eventOutput('Online event, connection is: ' + navigator.network.connection.type); }, false);
+ document.addEventListener('offline', function() { eventOutput('Offline event, connection is: ' + navigator.network.connection.type); }, false);
+
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: Cordova did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Network Events and State</h1>
+ <div id="info">
+ <b>Results:</b><br>
+ <span id="results"></span>
+ </div>
+
+ <h2>Action</h2>
+ <div class="btn large" onclick="printNetwork();">Show Network Connection</div>
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>
+
http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/1a1c3091/www/notification/index.html
----------------------------------------------------------------------
diff --git a/www/notification/index.html b/www/notification/index.html
new file mode 100755
index 0000000..e5c0d17
--- /dev/null
+++ b/www/notification/index.html
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
+ <title>Cordova Mobile Spec</title>
+ <link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
+ <script type="text/javascript" charset="utf-8" src="../cordova.js"></script>
+
+
+<script type="text/javascript" charset="utf-8">
+
+ var deviceReady = false;
+
+ //-------------------------------------------------------------------------
+ // Notifications
+ //-------------------------------------------------------------------------
+
+ var beep = function(){
+ navigator.notification.beep(3);
+ };
+
+ var vibrate = function(){
+ navigator.notification.vibrate(1000);
+ };
+
+ var alertDialog = function(message, title, button) {
+ console.log("alertDialog()");
+ navigator.notification.alert(message,
+ function(){
+ console.log("Alert dismissed.");
+ },
+ title, button);
+ console.log("After alert");
+ };
+
+ var confirmDialog = function(message, title, buttons) {
+ navigator.notification.confirm(message,
+ function(r) {
+ console.log("You selected " + r);
+ alert("You selected " + (buttons.split(","))[r-1]);
+ },
+ title,
+ buttons);
+ };
+
+ /**
+ * Function called when page has finished loading.
+ */
+ function init() {
+ document.addEventListener("deviceready", function() {
+ deviceReady = true;
+ console.log("Device="+device.platform+" "+device.version);
+ }, false);
+ window.setTimeout(function() {
+ if (!deviceReady) {
+ alert("Error: PhoneGap did not initialize. Demo will not run correctly.");
+ }
+ },1000);
+ }
+
+</script>
+
+ </head>
+ <body onload="init();" id="stage" class="theme">
+
+ <h1>Notifications and Dialogs</h1>
+ <div id="info">
+ </div>
+
+ <h2>Action</h2>
+ <div class="btn large" onclick="beep();">Beep</div>
+ <div class="btn large" onclick="vibrate();">Vibrate</div>
+ <div class="btn large" onclick="alertDialog('You pressed alert.', 'Alert Dialog', 'Continue');">Alert Dialog</div>
+ <div class="btn large" onclick="confirmDialog('You pressed confirm.', 'Confirm Dialog', 'Yes,No,Maybe');">Confirm Dialog</div>
+ <div class="btn large" onclick="alert('You pressed alert.');">Built-in Alert Dialog</div>
+ <div class="btn large" onclick="confirm('You selected confirm');">Built-in Confirm Dialog</div>
+ <div class="btn large" onclick="prompt('This is a prompt.', 'Default value');">Built-in Prompt Dialog</div>
+ <h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
+ </body>
+</html>