1 2 /** 3 * conatins device functionalities 4 * 5 * @namespace 6 */ 7 8 var Device = { 9 /** 10 * called when the device be ready 11 * 12 * @memberOf Device 13 */ 14 onReady : function() { 15 RemoteDB.checkMD5(); 16 }, 17 /** 18 * display the content of the local database.<br> 19 * <u><b> Description </b></u><br> 20 * select records from myProduct table on the local database named main and 21 * display it on HTML elements 22 * 23 * @memberOf Device 24 */ 25 display : function() { 26 $(LocalDB.connection.transaction(function(tx) { 27 tx.executeSql("select * from myProduct", [], function(tx, results) { 28 var s = "<h4>Offers</h4>", price = "<h4>prices</h4>"; 29 console.log(results.rows.length + " records on database"); 30 for ( var i = 0; i < results.rows.length; i++) { 31 s += results.rows.item(i).name + "<br/>"; 32 price += "$ "+results.rows.item(i).price + "<br/>"; 33 } 34 $("#docs").html("Offers List"); 35 $("#a").html(s); 36 $("#b").html(price); 37 }); 38 })); 39 }, 40 /** 41 * show notification with new offers.<br> 42 * 1. notify at notification bar.<br> 43 * 2. notify with sound for 1 second.<br> 44 * 3. notify with vibration for 1.5 second.<br> 45 * this done using plugin for notifications {@link http://code.google.com/p/jsdoc-toolkit/} 46 * @memberOf Device 47 * @param {String} 48 * message message to view 49 */ 50 notify : function(message) { 51 navigator.systemNotification.enableNotification(); 52 PhoneGap.exec(null, null, "systemNotification", "cancelNotification", []); 53 navigator.systemNotification.createStatusBarNotification(message); 54 navigator.systemNotification.showTickerText("new offer"); 55 navigator.notification.beep(1); 56 navigator.notification.vibrate(1500); 57 ); 58 } 59 } 60