Changes

Jump to navigation Jump to search
m
no edit summary
Line 7: Line 7:  
// suppress console.log, switch to true for debug
 
// suppress console.log, switch to true for debug
 
var Debug_switch = true;
 
var Debug_switch = true;
+
var iOS = !!navigator.platform && /Macintosh|MacIntel|MacPPC|Mac68K|Mac|iPad|iPhone|iPod/.test(navigator.platform);
 +
 
 
// deterministic hash generator for creating user id#s from usernames, should be replaced by something more functional (guaranteed to be transitively different)
 
// deterministic hash generator for creating user id#s from usernames, should be replaced by something more functional (guaranteed to be transitively different)
 
hashCode = function(s) {
 
hashCode = function(s) {
Line 84: Line 85:     
// indexeddb internal mechanism for version tracking of schema
 
// indexeddb internal mechanism for version tracking of schema
pddb.onupgradeneeded = function(evt) {
+
pddb.onupgradeneeded = function() {
 
console.log('upgrading database');
 
console.log('upgrading database');
 
var db = pddb.result;
 
var db = pddb.result;
 
var store = db.createObjectStore(pddbname, {keyPath: "id"});
 
var store = db.createObjectStore(pddbname, {keyPath: "id"});
 
+
var index;
 
// shouldn't the index be the wiki.personaldata.io username?  
 
// shouldn't the index be the wiki.personaldata.io username?  
 
+
if ( iOS ) {
var index = db.store.createIndex("NameIndex", ["id"]);
+
index = db.store.createIndex("NameIndex", ["id"]);
 +
} else {
 +
index = store.createIndex("NameIndex", ["id"]);
 +
}
 +
 
};
 
};
 
// Database successfully opened function.
 
// Database successfully opened function.
pddb.onsuccess = function(xy) {
+
pddb.onsuccess = function() {
 
debuglog(pddb.result);
 
debuglog(pddb.result);
debuglog(xy);
   
var db = pddb.result;
 
var db = pddb.result;
var tx = db.transaction([pddbname], "readwrite");
+
var tx;
 +
 +
if ( iOS ) {
 +
tx = db.transaction([pddbname], "readwrite");
 +
} else {
 +
tx = db.transaction(pddbname, "readwrite");
 +
}
 +
 
var store = tx.objectStore(pddbname);
 
var store = tx.objectStore(pddbname);
 
var index = store.index("NameIndex");
 
var index = store.index("NameIndex");
Line 119: Line 130:  
// Mode 'checkin':
 
// Mode 'checkin':
 
// record is retrieved from database, parameter record is pushed if not found
 
// record is retrieved from database, parameter record is pushed if not found
if ( getRecord.result !== undefined ) {
+
if ( getRecord.result != undefined ) {
 
debuglog("getting from store");
 
debuglog("getting from store");
 
inp_obj = getRecord.result;
 
inp_obj = getRecord.result;
Line 153: Line 164:  
if ( sqitch === "get record" ) {
 
if ( sqitch === "get record" ) {
 
inp_obj = undefined;
 
inp_obj = undefined;
 +
} else if ( sqitch === "remove from record" ) {
 +
inp_obj = record;
 
} else {
 
} else {
 +
// any other method ...... would quit as record was not even foun
 
return undefined;
 
return undefined;
 
}
 
}
// Remove from record will quit as record was not even found
  −
   
}
 
}
 
}
 
}
530

edits

Navigation menu