Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to make it work with current browsers. #228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Lawnchair.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ Lawnchair.prototype = {
},
keyExtraction:function(object, key_path) {
var value=null;
if('key' in object) {value=object['key'];}
if(typeof( object) === 'string') {value = object;}
else if('key' in object) {value=object['key'];}
if(!value) {value=this.keyEmbellish(object);}
return value;
},
Expand Down
7 changes: 4 additions & 3 deletions src/adapters/html5-filesystem.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Lawnchair.adapter('html5-filesystem', (function(global){

var StorageInfo = global.StorageInfo || global.webkitStorageInfo || {};
var StorageInfo = global.StorageInfo || navigator.webkitPersistentStorage || global.webkitStorageInfo || {};
var TEMPORARY = global.TEMPORARY || StorageInfo.TEMPORARY;
var PERSISTENT = global.PERSISTENT || StorageInfo.PERSISTENT;
var BlobBuilder = global.BlobBuilder || global.WebKitBlobBuilder;
Expand Down Expand Up @@ -36,7 +36,7 @@ Lawnchair.adapter('html5-filesystem', (function(global){
msg = 'Unknown Error';
break;
};
if ( console ) console.error( e, msg );
if ( console ) console.error( e, msg, e.message);
};

var ls = function( reader, callback, entries ) {
Expand Down Expand Up @@ -73,7 +73,8 @@ Lawnchair.adapter('html5-filesystem', (function(global){
init: function( options, callback ) {
var me = this;
var error = function(e) { fail(e); if ( callback ) me.fn( me.name, callback ).call( me, me ); };
requestFileSystem( (options.storage === 'TEMPORARY' ? TEMPORARY : PERSISTENT), (options.size || 1024*1024*1024), function( fs ) {
//requestFileSystem( (options.storage === 'TEMPORARY' ? TEMPORARY : PERSISTENT), (options.size || 5*1024*1024), function( fs ) {
requestFileSystem( TEMPORARY, (options.size || 5*1024*1024), function( fs ) {
fs.root.getDirectory( options.name, {create:true}, function( directory ) {
filesystems[options.name] = directory;
if ( callback ) me.fn( me.name, callback ).call( me, me );
Expand Down
7 changes: 4 additions & 3 deletions src/adapters/indexed-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ Lawnchair.adapter('indexed-db', (function(){
var store = trans.objectStore(this.record);

for (var i = 0; i < objs.length; i++) {
var o = objs[i];
var row_key = self.keyExtraction(o);
store.put(o, row_key);
var o = objs[i];
var row_key = self.keyExtraction(o);
if("key" in o) store.put(o);
else store.put(o, row_key);
}
store.transaction.oncomplete = win;
store.transaction.onabort = fail;
Expand Down
5 changes: 4 additions & 1 deletion src/adapters/webkit-sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ Lawnchair.adapter('webkit-sqlite', (function () {

try {
for (var i = 0, l = objs.length; i < l; i++) {
insvals[i] = [JSON.stringify(objs[i]), ts, JSON.stringify(that.keyExtraction(objs[i]))];
var the_key = that.keyExtraction(objs[i]);
//JSON.stringify quotes strings
if(typeof(the_key) !== 'string') the_key = JSON.stringify(the_key);
insvals[i] = [JSON.stringify(objs[i]), ts, the_key];
}
} catch (e) {
fail(e)
Expand Down