Commit e5fcf54d authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Rename 'callback' to 'onResponse'

parent b38a48a0
...@@ -411,7 +411,7 @@ ...@@ -411,7 +411,7 @@
'limit':{begin:0,end:50}, 'limit':{begin:0,end:50},
// 'search':{name:'a'}, // 'search':{name:'a'},
'maxtries':3, 'maxtries':3,
'callback':function (result) { 'onResponse':function (result) {
if (result.status === 'done') { if (result.status === 'done') {
priv.data_object.documentList = result.return_value; priv.data_object.documentList = result.return_value;
priv.showDocumentListInsideLeftNavBar(); priv.showDocumentListInsideLeftNavBar();
...@@ -446,7 +446,7 @@ ...@@ -446,7 +446,7 @@
priv.jio.saveDocument({ priv.jio.saveDocument({
'name':basename+'.'+current_editor.ext, 'name':basename+'.'+current_editor.ext,
'content':current_editor.getContent(), 'content':current_editor.getContent(),
'callback':function (result) { 'onResponse':function (result) {
if (result.status === 'fail') { if (result.status === 'fail') {
console.error (result.message); console.error (result.message);
} }
...@@ -471,7 +471,7 @@ ...@@ -471,7 +471,7 @@
priv.jio.loadDocument({ priv.jio.loadDocument({
'name':basename+'.'+current_editor.ext, 'name':basename+'.'+current_editor.ext,
'maxtries':3, 'maxtries':3,
'callback':function (result) { 'onResponse':function (result) {
if (result.status === 'fail') { if (result.status === 'fail') {
console.error (result.message); console.error (result.message);
} else { } else {
...@@ -496,7 +496,7 @@ ...@@ -496,7 +496,7 @@
priv.loading_object.remove(); priv.loading_object.remove();
priv.jio.removeDocument({ priv.jio.removeDocument({
'name':name, 'name':name,
'callback':function (result) { 'onResponse':function (result) {
if (result.status === 'fail') { if (result.status === 'fail') {
console.error (result.message); console.error (result.message);
} }
...@@ -521,7 +521,7 @@ ...@@ -521,7 +521,7 @@
priv.loading_object.remove(); priv.loading_object.remove();
priv.jio.removeDocument({ priv.jio.removeDocument({
name:documentarray[i], name:documentarray[i],
callback:function (result) { onResponse:function (result) {
cpt += 1; cpt += 1;
if (cpt === l) { if (cpt === l) {
if (typeof current_editor.update !== 'undefined') { if (typeof current_editor.update !== 'undefined') {
......
...@@ -259,7 +259,7 @@ var JIO = ...@@ -259,7 +259,7 @@ var JIO =
priv.job_object = {}; priv.job_object = {};
that.copyJobQueueToLocalStorage(); that.copyJobQueueToLocalStorage();
for (k in priv.recovered_job_object) { for (k in priv.recovered_job_object) {
priv.recovered_job_object[k].callback = emptyFun; priv.recovered_job_object[k].onResponse = emptyFun;
that.addJob (priv.recovered_job_object[k]); that.addJob (priv.recovered_job_object[k]);
} }
}; };
...@@ -547,7 +547,7 @@ var JIO = ...@@ -547,7 +547,7 @@ var JIO =
}; };
that.ended = function (endedjob) { that.ended = function (endedjob) {
// It is a callback function called just before user callback. // It is a callback function called just before user onResponse.
// It is called to manage job_object according to the ended job. // It is called to manage job_object according to the ended job.
var job = $.extend(true,{},endedjob); // copy var job = $.extend(true,{},endedjob); // copy
...@@ -698,7 +698,7 @@ var JIO = ...@@ -698,7 +698,7 @@ var JIO =
//// Private attributes //// Private attributes
priv.job = options.job; priv.job = options.job;
priv.callback = options.job.callback; priv.onResponse = options.job.onResponse;
priv.queue = options.queue; priv.queue = options.queue;
priv.res = {'status':'done','message':''}; priv.res = {'status':'done','message':''};
priv.sorted = false; priv.sorted = false;
...@@ -854,7 +854,7 @@ var JIO = ...@@ -854,7 +854,7 @@ var JIO =
priv.job.tries = 0; priv.job.tries = 0;
priv.job.date = newjob.date; priv.job.date = newjob.date;
priv.job.callback = newjob.callback; priv.job.onResponse = newjob.onResponse;
priv.res.status = 'fail'; priv.res.status = 'fail';
priv.res.message = 'Job Stopped!'; priv.res.message = 'Job Stopped!';
...@@ -863,7 +863,7 @@ var JIO = ...@@ -863,7 +863,7 @@ var JIO =
priv.res.error.statusText = 'Replaced'; priv.res.error.statusText = 'Replaced';
priv.res.error.message = 'The job was replaced by a newer one.'; priv.res.error.message = 'The job was replaced by a newer one.';
priv['fail_'+priv.job.method](); priv['fail_'+priv.job.method]();
priv.callback(priv.res); priv.onResponse(priv.res);
}; };
that.fail = function ( errorobject ) { that.fail = function ( errorobject ) {
// Called when a job has failed. // Called when a job has failed.
...@@ -886,18 +886,18 @@ var JIO = ...@@ -886,18 +886,18 @@ var JIO =
priv.job.status = 'fail'; priv.job.status = 'fail';
priv['fail_'+priv.job.method](); priv['fail_'+priv.job.method]();
priv.queue.ended(priv.job); priv.queue.ended(priv.job);
priv.callback(priv.res); priv.onResponse(priv.res);
} }
}; };
that.done = function ( retvalue ) { that.done = function ( retvalue ) {
// Called when a job has terminated successfully. // Called when a job has terminated successfully.
// It will return the return value by the calling the callback // It will return the return value by the calling of onResponse
// function. // function.
priv.job.status = 'done'; priv.job.status = 'done';
priv['done_'+priv.job.method]( retvalue ); priv['done_'+priv.job.method]( retvalue );
priv.queue.ended(priv.job); priv.queue.ended(priv.job);
priv.callback(priv.res); priv.onResponse(priv.res);
}; };
that.execute = function () { that.execute = function () {
// Execute the good function from the good storage. // Execute the good function from the good storage.
...@@ -1037,7 +1037,7 @@ var JIO = ...@@ -1037,7 +1037,7 @@ var JIO =
var m = 'Method: '+ settings.method + var m = 'Method: '+ settings.method +
', One or some parameters are undefined.'; ', One or some parameters are undefined.';
console.error (m); console.error (m);
settings.callback({status:'fail', settings.onResponse({status:'fail',
error: {status:0, error: {status:0,
statusText:'Undefined Parameter', statusText:'Undefined Parameter',
message: m}}); message: m}});
...@@ -1128,14 +1128,14 @@ var JIO = ...@@ -1128,14 +1128,14 @@ var JIO =
// return value. // return value.
// options.storage : the storage where to check (optional) // options.storage : the storage where to check (optional)
// options.applicant : the applicant (optional) // options.applicant : the applicant (optional)
// options.callback(result) : called to get the result. // options.onResponse(result) : called to get the result.
// returns: - null if dependencies are missing // returns: - null if dependencies are missing
// - false if the job was not added // - false if the job was not added
// - true if the job was added or replaced // - true if the job was added or replaced
// example : // example :
// jio.checkNameAvailability({'user_name':'myName','callback': // jio.checkNameAvailability({'user_name':'myName','onResponse':
// function (result) { // function (result) {
// if (result.status === 'done') { // if (result.status === 'done') {
// if (result.return_value === true) { // available // if (result.return_value === true) { // available
...@@ -1148,7 +1148,7 @@ var JIO = ...@@ -1148,7 +1148,7 @@ var JIO =
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'method': 'checkNameAvailability', 'method': 'checkNameAvailability',
'callback': function () {} 'onResponse': function () {}
},options); },options);
// check dependencies // check dependencies
if (that.isReady() && settings.user_name && if (that.isReady() && settings.user_name &&
...@@ -1164,14 +1164,14 @@ var JIO = ...@@ -1164,14 +1164,14 @@ var JIO =
// 'job_done' will be sent with this job. // 'job_done' will be sent with this job.
// options.storage : the storage where to save (optional) // options.storage : the storage where to save (optional)
// options.applicant : the applicant (optional) // options.applicant : the applicant (optional)
// options.callback(result) : called to get the result. // options.onResponse(result) : called to get the result.
// returns: - null if dependencies are missing // returns: - null if dependencies are missing
// - false if the job was not added // - false if the job was not added
// - true if the job was added or replaced // - true if the job was added or replaced
// jio.saveDocument({'name':'file','content':'content', // jio.saveDocument({'name':'file','content':'content',
// 'callback': function (result) { // 'onResponse': function (result) {
// if (result.status === 'done') { // Saved // if (result.status === 'done') { // Saved
// } else { } // Error // } else { } // Error
// }}); // }});
...@@ -1181,7 +1181,7 @@ var JIO = ...@@ -1181,7 +1181,7 @@ var JIO =
'applicant': priv.applicant, 'applicant': priv.applicant,
'content': '', 'content': '',
'method':'saveDocument', 'method':'saveDocument',
'callback': function () {} 'onResponse': function () {}
},options); },options);
// check dependencies // check dependencies
if (that.isReady() && settings.name && if (that.isReady() && settings.name &&
...@@ -1198,13 +1198,13 @@ var JIO = ...@@ -1198,13 +1198,13 @@ var JIO =
// return value. // return value.
// options.storage : the storage where to load (optional) // options.storage : the storage where to load (optional)
// options.applicant : the applicant (optional) // options.applicant : the applicant (optional)
// options.callback(result) : called to get the result. // options.onResponse(result) : called to get the result.
// returns: - null if dependencies are missing // returns: - null if dependencies are missing
// - false if the job was not added // - false if the job was not added
// - true if the job was added or replaced // - true if the job was added or replaced
// jio.loadDocument({'name':'file','callback': // jio.loadDocument({'name':'file','onResponse':
// function (result) { // function (result) {
// if (result.status === 'done') { // Loaded // if (result.status === 'done') { // Loaded
// } else { } // Error // } else { } // Error
...@@ -1218,7 +1218,7 @@ var JIO = ...@@ -1218,7 +1218,7 @@ var JIO =
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'method':'loadDocument', 'method':'loadDocument',
'callback': function(){} 'onResponse': function(){}
},options); },options);
// check dependencies // check dependencies
if (that.isReady() && settings.name && if (that.isReady() && settings.name &&
...@@ -1233,13 +1233,13 @@ var JIO = ...@@ -1233,13 +1233,13 @@ var JIO =
// or in the storage set at init. // or in the storage set at init.
// options.storage : the storage where to get the list (optional) // options.storage : the storage where to get the list (optional)
// options.applicant : the applicant (optional) // options.applicant : the applicant (optional)
// options.callback(result) : called to get the result. // options.onResponse(result) : called to get the result.
// returns: - null if dependencies are missing // returns: - null if dependencies are missing
// - false if the job was not added // - false if the job was not added
// - true if the job was added or replaced // - true if the job was added or replaced
// jio.getDocumentList({'callback': // jio.getDocumentList({'onResponse':
// function (result) { // function (result) {
// if (result.status === 'done') { // OK // if (result.status === 'done') { // OK
// console.log(result.return_value); // console.log(result.return_value);
...@@ -1252,7 +1252,7 @@ var JIO = ...@@ -1252,7 +1252,7 @@ var JIO =
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'method':'getDocumentList', 'method':'getDocumentList',
'callback':function(){} 'onResponse':function(){}
},options); },options);
// check dependencies // check dependencies
if (that.isReady() && settings.storage && settings.applicant ) { if (that.isReady() && settings.storage && settings.applicant ) {
...@@ -1266,13 +1266,13 @@ var JIO = ...@@ -1266,13 +1266,13 @@ var JIO =
// or in the storage set at init. // or in the storage set at init.
// options.storage : the storage where to remove (optional) // options.storage : the storage where to remove (optional)
// options.applicant : the applicant (optional) // options.applicant : the applicant (optional)
// options.callback(result) : called to get the result. // options.onResponse(result) : called to get the result.
// returns: - null if dependencies are missing // returns: - null if dependencies are missing
// - false if the job was not added // - false if the job was not added
// - true if the job was added or replaced // - true if the job was added or replaced
// jio.removeDocument({'name':'file','callback': // jio.removeDocument({'name':'file','onResponse':
// function (result) { // function (result) {
// if(result.status === 'done') { // Removed // if(result.status === 'done') { // Removed
// } else { } // Not Removed // } else { } // Not Removed
...@@ -1282,7 +1282,7 @@ var JIO = ...@@ -1282,7 +1282,7 @@ var JIO =
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'method':'removeDocument', 'method':'removeDocument',
'callback':function (){} 'onResponse':function (){}
},options); },options);
if (that.isReady() && settings.name && if (that.isReady() && settings.name &&
settings.storage && settings.applicant ) { settings.storage && settings.applicant ) {
......
...@@ -589,13 +589,13 @@ ...@@ -589,13 +589,13 @@
that.setMaxTries (1); that.setMaxTries (1);
priv.execJobsFromStorageArray = function (callback) { priv.execJobsFromStorageArray = function (onResponse) {
var newjob = {}, i; var newjob = {}, i;
for (i = 0; i < priv.storageArray.length; i += 1) { for (i = 0; i < priv.storageArray.length; i += 1) {
newjob = that.cloneJob(); newjob = that.cloneJob();
newjob.max_tries = priv.max_tries; newjob.max_tries = priv.max_tries;
newjob.storage = priv.storageArray[i]; newjob.storage = priv.storageArray[i];
newjob.callback = callback; newjob.onResponse = onResponse;
that.addJob ( newjob ) ; that.addJob ( newjob ) ;
} }
}; };
...@@ -607,7 +607,7 @@ ...@@ -607,7 +607,7 @@
// this.job.storage.storageArray: An Array of storages. // this.job.storage.storageArray: An Array of storages.
var i = 'id', done = false, error_array = [], var i = 'id', done = false, error_array = [],
res = {'status':'done'}, callback = function (result) { res = {'status':'done'}, onResponse = function (result) {
priv.return_value_array.push(result); priv.return_value_array.push(result);
if (!done) { if (!done) {
if (result.status === 'fail') { if (result.status === 'fail') {
...@@ -637,7 +637,7 @@ ...@@ -637,7 +637,7 @@
} }
} }
}; };
priv.execJobsFromStorageArray(callback); priv.execJobsFromStorageArray(onResponse);
}; };
that.saveDocument = function () { that.saveDocument = function () {
// Save a single document in several storages. // Save a single document in several storages.
...@@ -651,7 +651,7 @@ ...@@ -651,7 +651,7 @@
var res = {'status':'done'}, i = 'id', var res = {'status':'done'}, i = 'id',
done = false, error_array = [], done = false, error_array = [],
callback = function (result) { onResponse = function (result) {
priv.return_value_array.push(result); priv.return_value_array.push(result);
if (!done) { if (!done) {
if (result.status !== 'fail') { if (result.status !== 'fail') {
...@@ -671,7 +671,7 @@ ...@@ -671,7 +671,7 @@
} }
} }
}; };
priv.execJobsFromStorageArray(callback); priv.execJobsFromStorageArray(onResponse);
}; };
that.loadDocument = function () { that.loadDocument = function () {
...@@ -687,7 +687,7 @@ ...@@ -687,7 +687,7 @@
var doc = {}, i = 'id', var doc = {}, i = 'id',
done = false, error_array = [], done = false, error_array = [],
res = {'status':'done'}, callback = function (result) { res = {'status':'done'}, onResponse = function (result) {
priv.return_value_array.push(result); priv.return_value_array.push(result);
if (!done) { if (!done) {
if (result.status !== 'fail') { if (result.status !== 'fail') {
...@@ -707,7 +707,7 @@ ...@@ -707,7 +707,7 @@
} }
} }
}; };
priv.execJobsFromStorageArray(callback); priv.execJobsFromStorageArray(onResponse);
}; };
that.getDocumentList = function () { that.getDocumentList = function () {
...@@ -720,7 +720,7 @@ ...@@ -720,7 +720,7 @@
var res = {'status':'done'}, i = 'id', var res = {'status':'done'}, i = 'id',
done = false, error_array = [], done = false, error_array = [],
callback = function (result) { onResponse = function (result) {
priv.return_value_array.push(result); priv.return_value_array.push(result);
if (!done) { if (!done) {
if (result.status !== 'fail') { if (result.status !== 'fail') {
...@@ -740,7 +740,7 @@ ...@@ -740,7 +740,7 @@
} }
} }
}; };
priv.execJobsFromStorageArray(callback); priv.execJobsFromStorageArray(onResponse);
}; };
that.removeDocument = function () { that.removeDocument = function () {
...@@ -753,7 +753,7 @@ ...@@ -753,7 +753,7 @@
var res = {'status':'done'}, i = 'key', var res = {'status':'done'}, i = 'key',
done = false, error_array = [], done = false, error_array = [],
callback = function (result) { onResponse = function (result) {
priv.return_value_array.push(result); priv.return_value_array.push(result);
if (!done) { if (!done) {
if (result.status !== 'fail') { if (result.status !== 'fail') {
...@@ -773,7 +773,7 @@ ...@@ -773,7 +773,7 @@
} }
} }
}; };
priv.execJobsFromStorageArray(callback); priv.execJobsFromStorageArray(onResponse);
}; };
return that; return that;
}; };
...@@ -929,9 +929,9 @@ ...@@ -929,9 +929,9 @@
* returned the result. * returned the result.
* @method update * @method update
*/ */
priv.update = function (callback) { priv.update = function (onResponse) {
// retreive list before, and then retreive all files // retreive list before, and then retreive all files
var getlist_callback = function (result) { var getlist_onResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
if (!priv.isAnIndexedStorage(that.getSecondStorage())) { if (!priv.isAnIndexedStorage(that.getSecondStorage())) {
priv.addIndexedStorage(that.getSecondStorage()); priv.addIndexedStorage(that.getSecondStorage());
...@@ -944,7 +944,7 @@ ...@@ -944,7 +944,7 @@
applicant: {ID:that.getApplicantID()}, applicant: {ID:that.getApplicantID()},
method: 'getDocumentList', method: 'getDocumentList',
max_tries: 3, max_tries: 3,
callback: getlist_callback onResponse: getlist_onResponse
}; };
that.addJob ( newjob ); that.addJob ( newjob );
}; };
...@@ -957,7 +957,7 @@ ...@@ -957,7 +957,7 @@
var new_job = that.cloneJob(); var new_job = that.cloneJob();
priv.update(); priv.update();
new_job.storage = that.getSecondStorage(); new_job.storage = that.getSecondStorage();
new_job.callback = function (result) { new_job.onResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
that.done(result.return_value); that.done(result.return_value);
} else { } else {
...@@ -974,7 +974,7 @@ ...@@ -974,7 +974,7 @@
that.saveDocument = function () { that.saveDocument = function () {
var new_job = that.cloneJob(); var new_job = that.cloneJob();
new_job.storage = that.getSecondStorage(); new_job.storage = that.getSecondStorage();
new_job.callback = function (result) { new_job.onResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
if (!priv.isFileIndexed(that.getFileName())) { if (!priv.isFileIndexed(that.getFileName())) {
priv.addFile({name:that.getFileName(), priv.addFile({name:that.getFileName(),
...@@ -998,7 +998,7 @@ ...@@ -998,7 +998,7 @@
*/ */
that.loadDocument = function () { that.loadDocument = function () {
var file_array, i, l, new_job, var file_array, i, l, new_job,
loadCallback = function (result) { loadOnResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
// if (file_array[i].last_modified !== // if (file_array[i].last_modified !==
// result.return_value.last_modified || // result.return_value.last_modified ||
...@@ -1016,7 +1016,7 @@ ...@@ -1016,7 +1016,7 @@
secondLoadDocument = function () { secondLoadDocument = function () {
new_job = that.cloneJob(); new_job = that.cloneJob();
new_job.storage = that.getSecondStorage(); new_job.storage = that.getSecondStorage();
new_job.callback = loadCallback; new_job.onResponse = loadOnResponse;
that.addJob ( new_job ); that.addJob ( new_job );
}, },
settings = that.cloneOptionObject(); settings = that.cloneOptionObject();
...@@ -1061,7 +1061,7 @@ ...@@ -1061,7 +1061,7 @@
that.removeDocument = function () { that.removeDocument = function () {
var new_job = that.cloneJob(); var new_job = that.cloneJob();
new_job.storage = that.getSecondStorage(); new_job.storage = that.getSecondStorage();
new_job.callback = function (result) { new_job.onResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
priv.removeFile(that.getFileName()); priv.removeFile(that.getFileName());
priv.update(); priv.update();
...@@ -1139,7 +1139,7 @@ ...@@ -1139,7 +1139,7 @@
that.checkNameAvailability = function () { that.checkNameAvailability = function () {
var new_job = that.cloneJob(); var new_job = that.cloneJob();
new_job.storage = that.getSecondStorage(); new_job.storage = that.getSecondStorage();
new_job.callback = function (result) { new_job.onResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
that.done(result.return_value); that.done(result.return_value);
} else { } else {
...@@ -1172,7 +1172,7 @@ ...@@ -1172,7 +1172,7 @@
new_job.name = new_file_name; new_job.name = new_file_name;
new_job.content = newfilecontent; new_job.content = newfilecontent;
new_job.storage = that.getSecondStorage(); new_job.storage = that.getSecondStorage();
new_job.callback = function (result) { new_job.onResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
that.done(); that.done();
} else { } else {
...@@ -1202,10 +1202,10 @@ ...@@ -1202,10 +1202,10 @@
new_job = that.cloneJob(); new_job = that.cloneJob();
new_job.name = new_file_name; new_job.name = new_file_name;
new_job.storage = that.getSecondStorage(); new_job.storage = that.getSecondStorage();
new_job.callback = loadCallback; new_job.onResponse = loadOnResponse;
that.addJob ( new_job ); that.addJob ( new_job );
}, },
loadCallback = function (result) { loadOnResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
result.return_value.name = that.getFileName(); result.return_value.name = that.getFileName();
if (option.metadata_only) { if (option.metadata_only) {
...@@ -1243,24 +1243,24 @@ ...@@ -1243,24 +1243,24 @@
_1 = function () { _1 = function () {
new_job = that.cloneJob(); new_job = that.cloneJob();
new_job.storage = that.getSecondStorage(); new_job.storage = that.getSecondStorage();
new_job.callback = getListCallback; new_job.onResponse = getListOnResponse;
that.addJob ( new_job ); that.addJob ( new_job );
}, },
getListCallback = function (result) { getListOnResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
array = result.return_value; array = result.return_value;
for (i = 0, l = array.length; i < l; i+= 1) { for (i = 0, l = array.length; i < l; i+= 1) {
// cpt--; // cpt--;
priv.decrypt (array[i].name, priv.decrypt (array[i].name,
lastCallback,i,'name'); lastOnResponse,i,'name');
// priv.decrypt (array[i].content, // priv.decrypt (array[i].content,
// lastCallback,i,'content'); // lastOnResponse,i,'content');
} }
} else { } else {
that.fail(result.error); that.fail(result.error);
} }
}, },
lastCallback = function (res,index,key) { lastOnResponse = function (res,index,key) {
var tmp; var tmp;
cpt++; cpt++;
if (typeof res === 'object') { if (typeof res === 'object') {
...@@ -1296,10 +1296,10 @@ ...@@ -1296,10 +1296,10 @@
new_job = that.cloneJob(); new_job = that.cloneJob();
new_job.name = new_file_name; new_job.name = new_file_name;
new_job.storage = that.getSecondStorage(); new_job.storage = that.getSecondStorage();
new_job.callback = removeCallback; new_job.onResponse = removeOnResponse;
that.addJob(new_job); that.addJob(new_job);
}, },
removeCallback = function (result) { removeOnResponse = function (result) {
if (result.status === 'done') { if (result.status === 'done') {
that.done(); that.done();
} else { } else {
......
...@@ -146,7 +146,7 @@ test ('All tests', function () { ...@@ -146,7 +146,7 @@ test ('All tests', function () {
deepEqual (result[retmethod],value,message);}; deepEqual (result[retmethod],value,message);};
t.spy(o,'f'); t.spy(o,'f');
o.jio[method]({'user_name':'Dummy','name':'file', o.jio[method]({'user_name':'Dummy','name':'file',
'content':'content','callback':o.f, 'content':'content','onResponse':o.f,
'max_tries':1}); 'max_tries':1});
clock.tick(510); clock.tick(510);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -201,12 +201,12 @@ test ('Simple Job Elimination', function () { ...@@ -201,12 +201,12 @@ test ('Simple Job Elimination', function () {
{'ID':'jiotests'}); {'ID':'jiotests'});
id = o.jio.getID(); id = o.jio.getID();
o.jio.saveDocument({'name':'file','content':'content', o.jio.saveDocument({'name':'file','content':'content',
'callback':o.f1,'max_tries':1}); 'onResponse':o.f1,'max_tries':1});
ok(LocalOrCookieStorage.getItem('jio/job_object/'+id)['1'], ok(LocalOrCookieStorage.getItem('jio/job_object/'+id)['1'],
'job creation'); 'job creation');
clock.tick(10); clock.tick(10);
o.jio.removeDocument({'name':'file','content':'content', o.jio.removeDocument({'name':'file','content':'content',
'callback':o.f2,'max_tries':1}); 'onResponse':o.f2,'max_tries':1});
o.tmp = LocalOrCookieStorage.getItem('jio/job_object/'+id)['1']; o.tmp = LocalOrCookieStorage.getItem('jio/job_object/'+id)['1'];
ok(!o.tmp || o.tmp.status === 'fail','job elimination'); ok(!o.tmp || o.tmp.status === 'fail','job elimination');
}); });
...@@ -225,10 +225,10 @@ test ('Simple Job Replacement', function () { ...@@ -225,10 +225,10 @@ test ('Simple Job Replacement', function () {
{'ID':'jiotests'}); {'ID':'jiotests'});
id = o.jio.getID(); id = o.jio.getID();
o.jio.saveDocument({'name':'file','content':'content', o.jio.saveDocument({'name':'file','content':'content',
'callback':o.f1,'max_tries':1}); 'onResponse':o.f1,'max_tries':1});
clock.tick(10); clock.tick(10);
o.jio.saveDocument({'name':'file','content':'content', o.jio.saveDocument({'name':'file','content':'content',
'callback':o.f2,'max_tries':1}); 'onResponse':o.f2,'max_tries':1});
deepEqual(LocalOrCookieStorage.getItem( deepEqual(LocalOrCookieStorage.getItem(
'jio/job_object/'+id)['1'].date,10, 'jio/job_object/'+id)['1'].date,10,
'The first job date have to be equal to the second job date.'); 'The first job date have to be equal to the second job date.');
...@@ -250,10 +250,10 @@ test ('Simple Job Waiting', function () { ...@@ -250,10 +250,10 @@ test ('Simple Job Waiting', function () {
{'ID':'jiotests'}); {'ID':'jiotests'});
id = o.jio.getID(); id = o.jio.getID();
o.jio.saveDocument({'name':'file','content':'content', o.jio.saveDocument({'name':'file','content':'content',
'callback':o.f3,'max_tries':1}); 'onResponse':o.f3,'max_tries':1});
clock.tick(200); clock.tick(200);
o.jio.saveDocument({'name':'file','content':'content', o.jio.saveDocument({'name':'file','content':'content',
'callback':o.f4,'max_tries':1}); 'onResponse':o.f4,'max_tries':1});
ok(LocalOrCookieStorage.getItem( ok(LocalOrCookieStorage.getItem(
'jio/job_object/'+id)['2'] && 'jio/job_object/'+id)['2'] &&
LocalOrCookieStorage.getItem( LocalOrCookieStorage.getItem(
...@@ -284,7 +284,7 @@ test ('Simple Time Waiting' , function () { ...@@ -284,7 +284,7 @@ test ('Simple Time Waiting' , function () {
o.jio = JIO.newJio({'type':'dummyall3tries','user_name':'dummy'}, o.jio = JIO.newJio({'type':'dummyall3tries','user_name':'dummy'},
{'ID':'jiotests'}); {'ID':'jiotests'});
o.jio.saveDocument({'name':'file','content':'content', o.jio.saveDocument({'name':'file','content':'content',
'callback':o.f,'max_tries':3}); 'onResponse':o.f,'max_tries':3});
clock.tick(100000); clock.tick(100000);
ok(o.f.calledOnce,'callback called once.'); ok(o.f.calledOnce,'callback called once.');
ok(o.res,'job done.'); ok(o.res,'job done.');
...@@ -304,7 +304,7 @@ test ('Check name availability', function () { ...@@ -304,7 +304,7 @@ test ('Check name availability', function () {
deepEqual(result.return_value,value,'checking name availabality');}; deepEqual(result.return_value,value,'checking name availabality');};
t.spy(o,'f'); t.spy(o,'f');
o.jio.checkNameAvailability( o.jio.checkNameAvailability(
{'user_name':'MrCheckName','callback': o.f,'max_tries':1}); {'user_name':'MrCheckName','onResponse': o.f,'max_tries':1});
clock.tick(510); clock.tick(510);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
...@@ -337,7 +337,7 @@ test ('Document save', function () { ...@@ -337,7 +337,7 @@ test ('Document save', function () {
deepEqual(result.status,value,message);}; deepEqual(result.status,value,message);};
t.spy(o,'f'); t.spy(o,'f');
o.jio.saveDocument( o.jio.saveDocument(
{'name':'file','content':'content','callback': o.f, {'name':'file','content':'content','onResponse': o.f,
'max_tries':1}); 'max_tries':1});
clock.tick(510); clock.tick(510);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -384,7 +384,7 @@ test ('Document load', function () { ...@@ -384,7 +384,7 @@ test ('Document load', function () {
deepEqual(result[res],value,'loading document');}; deepEqual(result[res],value,'loading document');};
t.spy(o,'f'); t.spy(o,'f');
o.jio.loadDocument( o.jio.loadDocument(
{'name':'file','callback': o.f,'max_tries':1}); {'name':'file','onResponse': o.f,'max_tries':1});
clock.tick(510); clock.tick(510);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
...@@ -419,7 +419,7 @@ test ('Get document list', function () { ...@@ -419,7 +419,7 @@ test ('Get document list', function () {
objectifyDocumentArray(value),'getting list'); objectifyDocumentArray(value),'getting list');
}; };
t.spy(o,'f'); t.spy(o,'f');
o.jio.getDocumentList({'callback': o.f,'max_tries':1}); o.jio.getDocumentList({'onResponse': o.f,'max_tries':1});
clock.tick(510); clock.tick(510);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
...@@ -451,7 +451,7 @@ test ('Document remove', function () { ...@@ -451,7 +451,7 @@ test ('Document remove', function () {
deepEqual(result.status,'done','removing document');}; deepEqual(result.status,'done','removing document');};
t.spy(o,'f'); t.spy(o,'f');
o.jio.removeDocument( o.jio.removeDocument(
{'name':'file','callback': o.f,'max_tries':1}); {'name':'file','onResponse': o.f,'max_tries':1});
clock.tick(510); clock.tick(510);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
...@@ -486,7 +486,7 @@ test ('Check name availability', function () { ...@@ -486,7 +486,7 @@ test ('Check name availability', function () {
o.f = function (result) { o.f = function (result) {
deepEqual(result[method],value,'checking name availability');}; deepEqual(result[method],value,'checking name availability');};
t.spy(o,'f'); t.spy(o,'f');
o.jio.checkNameAvailability({'user_name':'davcheck','callback':o.f, o.jio.checkNameAvailability({'user_name':'davcheck','onResponse':o.f,
'max_tries':1}); 'max_tries':1});
clock.tick(500); clock.tick(500);
server.respond(); server.respond();
...@@ -526,7 +526,7 @@ test ('Document load', function () { ...@@ -526,7 +526,7 @@ test ('Document load', function () {
o.f = function (result) { o.f = function (result) {
deepEqual (result.return_value,doc,message);}; deepEqual (result.return_value,doc,message);};
t.spy(o,'f'); t.spy(o,'f');
o.jio.loadDocument({'name':'file','callback':o.f,'max_tries':1}); o.jio.loadDocument({'name':'file','onResponse':o.f,'max_tries':1});
clock.tick(500); clock.tick(500);
server.respond(); server.respond();
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -584,7 +584,7 @@ test ('Document save', function () { ...@@ -584,7 +584,7 @@ test ('Document save', function () {
deepEqual (result.status,value,message);}; deepEqual (result.status,value,message);};
t.spy(o,'f'); t.spy(o,'f');
o.jio.saveDocument({'name':'file','content':'content', o.jio.saveDocument({'name':'file','content':'content',
'callback':o.f,'max_tries':1}); 'onResponse':o.f,'max_tries':1});
clock.tick(500); clock.tick(500);
server.respond(); server.respond();
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -633,7 +633,7 @@ test ('Get Document List', function () { ...@@ -633,7 +633,7 @@ test ('Get Document List', function () {
} }
}; };
t.spy(o,'f'); t.spy(o,'f');
o.jio.getDocumentList({'callback':o.f,'max_tries':1}); o.jio.getDocumentList({'onResponse':o.f,'max_tries':1});
clock.tick(500); clock.tick(500);
server.respond(); server.respond();
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -664,7 +664,7 @@ test ('Remove document', function () { ...@@ -664,7 +664,7 @@ test ('Remove document', function () {
o.f = function (result) { o.f = function (result) {
deepEqual (result.status,value,message);}; deepEqual (result.status,value,message);};
t.spy(o,'f'); t.spy(o,'f');
o.jio.removeDocument({'name':'file','callback':o.f,'max_tries':1}); o.jio.removeDocument({'name':'file','onResponse':o.f,'max_tries':1});
clock.tick(500); clock.tick(500);
server.respond(); server.respond();
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -695,7 +695,7 @@ test ('Check name availability', function () { ...@@ -695,7 +695,7 @@ test ('Check name availability', function () {
deepEqual (result.return_value,value,message); deepEqual (result.return_value,value,message);
}; };
t.spy(o,'f'); t.spy(o,'f');
o.jio.checkNameAvailability({'user_name':'Dummy','callback':o.f, o.jio.checkNameAvailability({'user_name':'Dummy','onResponse':o.f,
'max_tries':o.max_tries}); 'max_tries':o.max_tries});
clock.tick(300000); clock.tick(300000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
...@@ -761,7 +761,7 @@ test ('Document load', function () { ...@@ -761,7 +761,7 @@ test ('Document load', function () {
o.f = function (result) { o.f = function (result) {
deepEqual (result.return_value,doc,message);}; deepEqual (result.return_value,doc,message);};
t.spy(o,'f'); t.spy(o,'f');
o.jio.loadDocument({'name':'file','callback':o.f}); o.jio.loadDocument({'name':'file','onResponse':o.f});
clock.tick(100000); clock.tick(100000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
...@@ -797,7 +797,7 @@ test ('Document save', function () { ...@@ -797,7 +797,7 @@ test ('Document save', function () {
deepEqual (result.status,value,message);}; deepEqual (result.status,value,message);};
t.spy(o,'f'); t.spy(o,'f');
o.jio.saveDocument({'name':'file','content':'content', o.jio.saveDocument({'name':'file','content':'content',
'callback':o.f,'max_tries':3}); 'onResponse':o.f,'max_tries':3});
clock.tick(500); clock.tick(500);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
...@@ -821,7 +821,7 @@ test ('Get Document List', function () { ...@@ -821,7 +821,7 @@ test ('Get Document List', function () {
objectifyDocumentArray(value),'getting list'); objectifyDocumentArray(value),'getting list');
}; };
t.spy(o,'f'); t.spy(o,'f');
o.jio.getDocumentList({'callback':o.f,'max_tries':3}); o.jio.getDocumentList({'onResponse':o.f,'max_tries':3});
clock.tick(100000); clock.tick(100000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
...@@ -847,7 +847,7 @@ test ('Remove document', function () { ...@@ -847,7 +847,7 @@ test ('Remove document', function () {
o.f = function (result) { o.f = function (result) {
deepEqual (result.status,value,message);}; deepEqual (result.status,value,message);};
t.spy(o,'f'); t.spy(o,'f');
o.jio.removeDocument({'name':'file','callback':o.f,'max_tries':3}); o.jio.removeDocument({'name':'file','onResponse':o.f,'max_tries':3});
clock.tick(100000); clock.tick(100000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
...@@ -870,7 +870,7 @@ test ('Check name availability', function () { ...@@ -870,7 +870,7 @@ test ('Check name availability', function () {
deepEqual (result.return_value,value,message);}; deepEqual (result.return_value,value,message);};
t.spy(o,'f'); t.spy(o,'f');
o.jio.checkNameAvailability({user_name:'MrIndexedCheck', o.jio.checkNameAvailability({user_name:'MrIndexedCheck',
callback:o.f,max_tries:3}); onResponse:o.f,max_tries:3});
clock.tick(100000); clock.tick(100000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok(false, 'no response / too much results'); ok(false, 'no response / too much results');
...@@ -893,7 +893,7 @@ test ('Document load', function () { ...@@ -893,7 +893,7 @@ test ('Document load', function () {
// loading must take long time with dummyall3tries // loading must take long time with dummyall3tries
o.f = function () {}; o.f = function () {};
this.spy(o,'f'); this.spy(o,'f');
o.jio.loadDocument({name:'memo',max_tries:3,callback:o.f, o.jio.loadDocument({name:'memo',max_tries:3,onResponse:o.f,
options:{metadata_only:true}}); options:{metadata_only:true}});
clock.tick(500); clock.tick(500);
ok(!o.f.calledOnce,'Callback must not be called'); ok(!o.f.calledOnce,'Callback must not be called');
...@@ -905,7 +905,7 @@ test ('Document load', function () { ...@@ -905,7 +905,7 @@ test ('Document load', function () {
deepEqual (result.return_value,o.doc,'Document metadata retrieved'); deepEqual (result.return_value,o.doc,'Document metadata retrieved');
}; };
this.spy(o,'f2'); this.spy(o,'f2');
o.jio.loadDocument({name:'memo',max_tries:3,callback:o.f2, o.jio.loadDocument({name:'memo',max_tries:3,onResponse:o.f2,
options:{metadata_only:true}}); options:{metadata_only:true}});
clock.tick(500); clock.tick(500);
if (!o.f2.calledOnce) { if (!o.f2.calledOnce) {
...@@ -918,7 +918,7 @@ test ('Document load', function () { ...@@ -918,7 +918,7 @@ test ('Document load', function () {
deepEqual (result.return_value,o.doc2,'Simple document loading'); deepEqual (result.return_value,o.doc2,'Simple document loading');
}; };
this.spy(o,'f3'); this.spy(o,'f3');
o.jio.loadDocument({name:'file',max_tries:3,callback:o.f3}); o.jio.loadDocument({name:'file',max_tries:3,onResponse:o.f3});
clock.tick(100000); clock.tick(100000);
if (!o.f3.calledOnce) { if (!o.f3.calledOnce) {
ok (false, 'no response / too much results'); ok (false, 'no response / too much results');
...@@ -936,7 +936,7 @@ test ('Document save', function () { ...@@ -936,7 +936,7 @@ test ('Document save', function () {
deepEqual (result.status,'done','document save'); deepEqual (result.status,'done','document save');
}; };
this.spy(o,'f'); this.spy(o,'f');
o.jio.saveDocument({name:'file',max_tries:3,callback:o.f}); o.jio.saveDocument({name:'file',max_tries:3,onResponse:o.f});
clock.tick(100000); clock.tick(100000);
if (!o.f.calledOnce){ if (!o.f.calledOnce){
ok (false, 'no response / too much results'); ok (false, 'no response / too much results');
...@@ -955,7 +955,7 @@ test ('Get document list', function () { ...@@ -955,7 +955,7 @@ test ('Get document list', function () {
// getting list must take long time with dummyall3tries // getting list must take long time with dummyall3tries
o.f = function () {}; o.f = function () {};
this.spy(o,'f'); this.spy(o,'f');
o.jio.getDocumentList({max_tries:3,callback:o.f}); o.jio.getDocumentList({max_tries:3,onResponse:o.f});
clock.tick(500); clock.tick(500);
ok(!o.f.calledOnce,'Callback must not be called'); ok(!o.f.calledOnce,'Callback must not be called');
// wail long time too retreive list // wail long time too retreive list
...@@ -965,7 +965,7 @@ test ('Get document list', function () { ...@@ -965,7 +965,7 @@ test ('Get document list', function () {
deepEqual (result.return_value,[o.doc1,o.doc2],'get document list'); deepEqual (result.return_value,[o.doc1,o.doc2],'get document list');
}; };
this.spy(o,'f2'); this.spy(o,'f2');
o.jio.getDocumentList({max_tries:3,callback:o.f2}); o.jio.getDocumentList({max_tries:3,onResponse:o.f2});
clock.tick(500); clock.tick(500);
if (!o.f2.calledOnce) { if (!o.f2.calledOnce) {
ok (false, 'no response / too much results'); ok (false, 'no response / too much results');
...@@ -982,7 +982,7 @@ test ('Remove document', function () { ...@@ -982,7 +982,7 @@ test ('Remove document', function () {
deepEqual (result.status,'done','document remove'); deepEqual (result.status,'done','document remove');
}; };
this.spy(o,'f'); this.spy(o,'f');
o.jio.removeDocument({name:'file',max_tries:3,callback:o.f}); o.jio.removeDocument({name:'file',max_tries:3,onResponse:o.f});
clock.tick(100000); clock.tick(100000);
if (!o.f.calledOnce){ if (!o.f.calledOnce){
ok (false, 'no response / too much results'); ok (false, 'no response / too much results');
...@@ -1003,7 +1003,7 @@ test ('Check name availability' , function () { ...@@ -1003,7 +1003,7 @@ test ('Check name availability' , function () {
}; };
this.spy(o,'f'); this.spy(o,'f');
o.jio.checkNameAvailability({user_name:'cryptcheck', o.jio.checkNameAvailability({user_name:'cryptcheck',
max_tries:1,callback:o.f}); max_tries:1,onResponse:o.f});
clock.tick(1000); clock.tick(1000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok (false, 'no response / too much results'); ok (false, 'no response / too much results');
...@@ -1024,7 +1024,7 @@ test ('Document save' , function () { ...@@ -1024,7 +1024,7 @@ test ('Document save' , function () {
}; };
this.spy(o,'f'); this.spy(o,'f');
o.jio.saveDocument({name:'testsave',content:'contentoftest', o.jio.saveDocument({name:'testsave',content:'contentoftest',
max_tries:1,callback:o.f}); max_tries:1,onResponse:o.f});
clock.tick(1000); clock.tick(1000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok (false, 'no response / too much results'); ok (false, 'no response / too much results');
...@@ -1072,7 +1072,7 @@ test ('Document Load' , function () { ...@@ -1072,7 +1072,7 @@ test ('Document Load' , function () {
content:'kSulH8Qo105dSKHcY2hEBXWXC9b+3PCEFSm1k7k', content:'kSulH8Qo105dSKHcY2hEBXWXC9b+3PCEFSm1k7k',
last_modified:500,creation_date:500}); last_modified:500,creation_date:500});
o.jio.loadDocument({name:'testload', o.jio.loadDocument({name:'testload',
max_tries:1,callback:o.f}); max_tries:1,onResponse:o.f});
clock.tick(1000); clock.tick(1000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok (false, 'no response / too much results'); ok (false, 'no response / too much results');
...@@ -1122,7 +1122,7 @@ test ('Get Document List', function () { ...@@ -1122,7 +1122,7 @@ test ('Get Document List', function () {
LocalOrCookieStorage.setItem( LocalOrCookieStorage.setItem(
'jio/local/cryptgetlistlocal/jiotests/'+o.doc_encrypt_list[1].name, 'jio/local/cryptgetlistlocal/jiotests/'+o.doc_encrypt_list[1].name,
o.doc_encrypt_list[1]); o.doc_encrypt_list[1]);
o.jio.getDocumentList({max_tries:1,callback:o.f}); o.jio.getDocumentList({max_tries:1,onResponse:o.f});
clock.tick (2000); clock.tick (2000);
if (!o.f.calledOnce) { if (!o.f.calledOnce) {
ok (false, 'no response / too much results'); ok (false, 'no response / too much results');
...@@ -1154,7 +1154,7 @@ test ('Remove document', function () { ...@@ -1154,7 +1154,7 @@ test ('Remove document', function () {
"content":"LKaLZopWgML6IxERqoJ2mUyyO", "content":"LKaLZopWgML6IxERqoJ2mUyyO",
"creation_date":500, "creation_date":500,
"last_modified":500}); "last_modified":500});
o.jio.removeDocument({name:'file',max_tries:1,callback:o.f}); o.jio.removeDocument({name:'file',max_tries:1,onResponse:o.f});
clock.tick(1000); clock.tick(1000);
if (!o.f.calledOnce){ if (!o.f.calledOnce){
ok (false, 'no response / too much results'); ok (false, 'no response / too much results');
......
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