Advertisement
Guest User

jsGetMyLocalInspections

a guest
May 21st, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var db = window.openDatabase("MELInsp", "1.0", "MEL Inspection DB", 200000);
  2.  
  3. $t.jsGetMyLocalInspections = $t.createClass(null, {
  4.  
  5.     init: function(requestOptions) {
  6.         this.__requestOptions = $.extend({}, requestOptions);
  7.     },
  8.  
  9.     process: function(settings) {
  10.         if (this.__requestOptions.echo) {
  11.             settings.success(this.__requestOptions.echo);
  12.         } else {
  13.  
  14.             var ourFinalArray = [];
  15.             db.transaction(function(tx) {
  16.                 tx.executeSql('SELECT * FROM MyInspections', [], function(tx, results) {
  17.                     alert(results.rows.length + ' records');
  18.                     var len = results.rows.length,
  19.                     i;
  20.                     for (i = 0; i < len; i++) {
  21.                         // for each row
  22.                         ourFinalArray.push(results.rows.item(i));
  23.                         // pushing row object to an array
  24.                         }
  25.                     console.log("first JSON: " + JSON.stringify(ourFinalArray));
  26.  
  27.                     console.log("second JSON: " + JSON.stringify(ourFinalArray));
  28.                     settings.success(JSON.stringify(ourFinalArray));
  29.                     settings.complete('success');
  30.                 });
  31.             });
  32.         }
  33.     }
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement