1 2 /** 3 * conatins device functionalities 4 * @namespace 5 */ 6 7 var Device = { 8 /** 9 * called when the device be ready 10 * @memberOf Device 11 */ 12 onReady : function() { 13 RemoteDB.checkMD5(); 14 }, 15 /** 16 * display the content of the local database.<br> 17 * <u><b> Description </b></u><br> 18 * select records from myProduct table on the local database named main 19 * and display it on HTML elements 20 * @memberOf Device 21 */ 22 display : function() { 23 $(LocalDB.connection.transaction(function(tx) { 24 tx.executeSql("select * from myProduct", [], function(tx, results) { 25 var s = "<h4>Offers</h4>", price = "<h4>prices</h4>"; 26 console.log(results.rows.length + " records on database"); 27 for ( var i = 0; i < results.rows.length; i++) { 28 s += results.rows.item(i).name + "<br/>"; 29 price += "$ "+results.rows.item(i).price + "<br/>"; 30 } 31 $("#docs").html("Offers List"); 32 $("#a").html(s); 33 $("#b").html(price); 34 }); 35 })); 36 }, 37 /** 38 * show notification with new offers 39 * @memberOf Device 40 * @param {String} message message to view 41 */ 42 showAlert : function(message) { 43 navigator.notification.alert(message, // message 44 alertDismissed, // callback 45 'New Offer', // title 46 'OK' // buttonName 47 ); 48 }, 49 /** 50 * play sound one time when inserting new offers 51 * @memberOf Device 52 */ 53 playBeep : function(){ 54 navigator.notification.beep(1); 55 }, 56 /** 57 * vibrate for 1.5 sec when inserting new offers 58 * @memberOf Device 59 */ 60 vibrate : function(){ 61 navigator.notification.vibrate(1500); 62 } 63 } 64