added SQLite example in demo app
diff --git a/Makefile b/Makefile
index 3a5bb35..73ce259 100755
--- a/Makefile
+++ b/Makefile
@@ -45,7 +45,7 @@
js: lib/phonegap.js
-lib/phonegap.js: js/phonegap.js.base 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/storage.js js/telephony.js js/window.js js/windowproperties.js
+lib/phonegap.js: js/phonegap.js.base 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
$(MKPATH) lib
$(RM_F) $@
$(CAT) js/phonegap.js.base >> $@
@@ -68,7 +68,6 @@
$(CAT) js/position.js >> $@
$(CAT) js/service.js >> $@
$(CAT) js/sms.js >> $@
- $(CAT) js/storage.js >> $@
$(CAT) js/telephony.js >> $@
$(CAT) js/window.js >> $@
$(CAT) js/windowproperties.js >> $@
diff --git a/framework/index.html b/framework/index.html
index 2a86d67..f2cbb65 100644
--- a/framework/index.html
+++ b/framework/index.html
@@ -17,11 +17,22 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PhoneGap WebOS</title>
- <script type="text/javascript" src="phonegap.js"></script>
+ <link rel="stylesheet" href="jqtouch/jqtouch.css" />
+ <link rel="stylesheet" href="jqtouch/themes/default/theme.css" />
+ <link rel="stylesheet" href="css/main.css" />
+
+
+ <script type="text/javascript" src="phonegap.js"></script>
+ <script type="text/javascript">
+ var phonegap = new PhoneGap();
+ var db;
+ </script>
+
+
<link rel="stylesheet" type="text/css" href="menu.css">
</head>
-<body>
+<body onload="navigator.device.deviceReady();">
<a onclick="dashboard();">Dashboard</a>
@@ -34,6 +45,7 @@
<a onclick="launchmap()">Launch Map App</a>
<a onclick="navigator.window.newCard('about:blank', '<html><body>Hello again!</body></html>');menu(false);">Launch New Card</a>
<a onclick="getPicture();">Launch Camera</a>
+ <a onclick="storage();">Storage Tests</a>
<a onclick="menu(false);">Done</a>
</div>
@@ -53,8 +65,7 @@
<input type="button" onclick="displayCurrentOrientation();" value="Get Current Orientation">
<p>navigator.notification.alert();</p>
- <input type="button" onclick="navigator.notification.alert('alert');" value="Show Alert">
-
+ <input type="button" onclick="navigator.notification.alert('alert');" value="Show Alert">
</div>
@@ -62,14 +73,51 @@
<div id="net"></div>
-<div id="camera"></div>
+<div id="camera"></div>
-<script>
+<div id="storage" style="display: none">
+ <p>storage tests</p>
+ <input type="button" onclick="createDB();" value="Test SQLite DB">
+ <div id="storageResults"></div>
+</div>
+<script>
+function createDB() {
+ document.getElementById('storageResults').innerHTML = '';
+ db = window.openDatabase("test", "1.0", "Test DB", false);
+ db.transaction(populateDB, errorCB, successCB);
+}
-var phonegap = new PhoneGap();
-//must call this to let the device know that the app is ready
-navigator.device.deviceReady();
+function populateDB(tx) {
+ tx.executeSql('DROP TABLE IF EXISTS DEMO');
+ tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
+ tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
+ tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
+}
+
+function errorCB(tx, err) {
+ navigator.notification.alert("error: " + err);
+}
+
+function successCB() {
+ navigator.notification.alert('successfully created & populated');
+ db.transaction(queryDB, errorCB);
+}
+
+function queryDB(tx) {
+ tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
+}
+
+function querySuccess(tx, results) {
+ var len = results.rows.length;
+ navigator.notification.alert('rows inserted: ' + len);
+
+ if (len > 0) {
+ for (var i=0;i<len;i++) {
+ navigator.notification.alert('id: ' + results.rows.item(i).id + ' data: ' + results.rows.item(i).data);
+ }
+ }
+}
function dashboard() {
navigator.notification.newDashboard("dashboard.html");
@@ -80,6 +128,10 @@
page('info');
lastpage.innerHTML = deviceinfo;
}
+
+function storage() {
+ page('storage');
+}
function net() {
page('net');
@@ -154,6 +206,7 @@
}
var lastpage = document.getElementById('screen');
+
function page(id) {
lastpage.style.display = 'none';
lastpage = document.getElementById(id);
diff --git a/framework/phonegap.js b/framework/phonegap.js
index 084196e..8ca0106 100644
--- a/framework/phonegap.js
+++ b/framework/phonegap.js
@@ -1289,6 +1289,7 @@
* @author ryan
*/
+/*
function Storage() {
this.length = null;
this.available = true;
@@ -1379,9 +1380,10 @@
message: err
};
-};
+};
+*/
-if (typeof navigator.storage == "undefined") navigator.storage = new Storage();
+//if (typeof navigator.storage == "undefined") navigator.storage = new Storage();
/*
* This class provides access to the telephony features of the device.
diff --git a/js/storage.js b/js/storage.js
deleted file mode 100755
index dc2ec89..0000000
--- a/js/storage.js
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * TODO for Palm. Could just use below functionality, and implement simple serialization, or could map to Palm's data store APIs.
- * @author ryan
- */
-
-function Storage() {
- this.length = null;
- this.available = true;
- this.serialized = null;
- this.items = null;
-
- if (!window.widget) {
- this.available = false;
- return;
- }
- var pref = window.widget.preferenceForKey(Storage.PREFERENCE_KEY);
-
- //storage not yet created
- if (pref == "undefined" || pref == undefined) {
- this.length = 0;
- this.serialized = "({})";
- this.items = {};
- window.widget.setPreferenceForKey(this.serialized, Storage.PREFERENCE_KEY);
- } else {
- this.serialized = pref;
- '({"store_test": { "key": "store_test", "data": "asdfasdfs" },})';
-
- this.items = eval(this.serialized);
-
- }
-};
-
-Storage.PREFERENCE_KEY = "phonegap_storage_pref_key";
-
-Storage.prototype.index = function(key) {
-
- };
-
-Storage.prototype.getItem = function(key) {
-
- var err = "Storage unimplemented on Palm PhoneGap";
- debug.log(err);
- throw {
- name: "StorageError",
- message: err
- };
-
- try {
- return this.items[key].data;
- } catch(ex) {
- return null;
- }
-};
-
-Storage.prototype.setItem = function(key, data) {
-
- var err = "Storage unimplemented on Palm PhoneGap";
- debug.log(err);
- throw {
- name: "StorageError",
- message: err
- };
-
- if (!this.items[key])
- this.length++;
- this.items[key] = {
- "key": key,
- "data": data
- };
-
- this.serialize();
-};
-
-Storage.prototype.removeItem = function(key) {
- if (this.items[key]) {
- this.items[key] = undefined;
- this.length--;
- }
- this.serialize();
-};
-
-Storage.prototype.clear = function() {
- this.length = 0;
- this.serialized = "({})";
- this.items = {};
-};
-
-Storage.prototype.serialize = function() {
- var err = "Storage unimplemented on Palm PhoneGap";
- debug.log(err);
- throw {
- name: "StorageError",
- message: err
- };
-
-};
-
-if (typeof navigator.storage == "undefined") navigator.storage = new Storage();
-