Commit caa4fec2 authored by François Billioud's avatar François Billioud

comment and edit JIO Main class (avoid undefined option)

parent e4793d89
...@@ -15,15 +15,12 @@ ...@@ -15,15 +15,12 @@
return $!==undefined && sjcl!==undefined && Base64!==undefined; // check jQuery, sjcl & Base64 return $!==undefined && sjcl!==undefined && Base64!==undefined; // check jQuery, sjcl & Base64
}); });
function script() {
/** /**
* JIO main object. Contains all IO methods * JIO main object. Contains all IO methods
*/ */
var JIO = { var JIO = {
jioFileContent: null,//content of jio.json file jioFileContent: null, //content of jio.json file
storage: null,//the storage tree storage: null, //the storage tree
/** /**
* prepare and return the jio object * prepare and return the jio object
...@@ -32,14 +29,17 @@ ...@@ -32,14 +29,17 @@
* @return JIO object * @return JIO object
*/ */
initialize: function(jioData, applicant) { initialize: function(jioData, applicant) {
if(!dependenceLoaded()) {
setTimeout(function() {JIO.initialize(jioData, applicant)},50);
} else {
switch(typeof jioData) { switch(typeof jioData) {
case "string" :this.jioFileContent = jioData;break; case "string" :this.jioFileContent = jioData;break;
case "object" :this.jioFileContent = JSON.stringify(jioData);break; case "object" :this.jioFileContent = JSON.stringify(jioData);break;
case "function" :this.jioFileContent = jioData();break; case "function" :this.jioFileContent = jioData();break;
default:alert("Error while getting jio.json content");break; default:alert("Error while getting jio.json content");break;
} }
this.storage = createStorage(JSON.parse(this.jioFileContent), applicant)//create the object allowing IO in storages this.storage = createStorage(JSON.parse( this.jioFileContent ), applicant);//create the object allowing IO in storages
return this; }
}, },
/** /**
...@@ -49,14 +49,24 @@ ...@@ -49,14 +49,24 @@
isReady: function() {return this.jioFileContent && this.storage}, isReady: function() {return this.jioFileContent && this.storage},
//IO functions //IO functions
userNameAvailable: function(name, option) {return this.storage.userNameAvailable.apply(this.storage,arguments)}, getLocation: function() {return this.location},
loadDocument: function(fileName, option) {return this.storage.loadDocument.apply(this.storage,arguments)}, userNameAvailable: function(name, option) {
saveDocument: function(data, fileName, option) {return this.storage.saveDocument.apply(this.storage,arguments)}, return this.storage.userNameAvailable(name, option||{});
deleteDocument: function(file, option) {return this.storage.deleteDocument.apply(this.storage,arguments)}, },
getDocumentList: function(option) {return this.storage.getDocumentList.apply(this.storage,arguments)} loadDocument: function(fileName, option) {
return this.storage.loadDocument(fileName, option||{});
},
saveDocument: function(data, fileName, option) {
return this.storage.saveDocument(data, fileName, option||{});
},
deleteDocument: function(file, option) {
return this.storage.deleteDocument(file, option||{});
},
getDocumentList: function(option) {
return this.storage.getDocumentList(option||{});
} }
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment