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

Rename 'callback' to 'onResponse'

parent b38a48a0
......@@ -411,7 +411,7 @@
'limit':{begin:0,end:50},
// 'search':{name:'a'},
'maxtries':3,
'callback':function (result) {
'onResponse':function (result) {
if (result.status === 'done') {
priv.data_object.documentList = result.return_value;
priv.showDocumentListInsideLeftNavBar();
......@@ -446,7 +446,7 @@
priv.jio.saveDocument({
'name':basename+'.'+current_editor.ext,
'content':current_editor.getContent(),
'callback':function (result) {
'onResponse':function (result) {
if (result.status === 'fail') {
console.error (result.message);
}
......@@ -471,7 +471,7 @@
priv.jio.loadDocument({
'name':basename+'.'+current_editor.ext,
'maxtries':3,
'callback':function (result) {
'onResponse':function (result) {
if (result.status === 'fail') {
console.error (result.message);
} else {
......@@ -496,7 +496,7 @@
priv.loading_object.remove();
priv.jio.removeDocument({
'name':name,
'callback':function (result) {
'onResponse':function (result) {
if (result.status === 'fail') {
console.error (result.message);
}
......@@ -521,7 +521,7 @@
priv.loading_object.remove();
priv.jio.removeDocument({
name:documentarray[i],
callback:function (result) {
onResponse:function (result) {
cpt += 1;
if (cpt === l) {
if (typeof current_editor.update !== 'undefined') {
......
......@@ -259,7 +259,7 @@ var JIO =
priv.job_object = {};
that.copyJobQueueToLocalStorage();
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]);
}
};
......@@ -547,7 +547,7 @@ var JIO =
};
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.
var job = $.extend(true,{},endedjob); // copy
......@@ -698,7 +698,7 @@ var JIO =
//// Private attributes
priv.job = options.job;
priv.callback = options.job.callback;
priv.onResponse = options.job.onResponse;
priv.queue = options.queue;
priv.res = {'status':'done','message':''};
priv.sorted = false;
......@@ -854,7 +854,7 @@ var JIO =
priv.job.tries = 0;
priv.job.date = newjob.date;
priv.job.callback = newjob.callback;
priv.job.onResponse = newjob.onResponse;
priv.res.status = 'fail';
priv.res.message = 'Job Stopped!';
......@@ -863,7 +863,7 @@ var JIO =
priv.res.error.statusText = 'Replaced';
priv.res.error.message = 'The job was replaced by a newer one.';
priv['fail_'+priv.job.method]();
priv.callback(priv.res);
priv.onResponse(priv.res);
};
that.fail = function ( errorobject ) {
// Called when a job has failed.
......@@ -886,18 +886,18 @@ var JIO =
priv.job.status = 'fail';
priv['fail_'+priv.job.method]();
priv.queue.ended(priv.job);
priv.callback(priv.res);
priv.onResponse(priv.res);
}
};
that.done = function ( retvalue ) {
// 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.
priv.job.status = 'done';
priv['done_'+priv.job.method]( retvalue );
priv.queue.ended(priv.job);
priv.callback(priv.res);
priv.onResponse(priv.res);
};
that.execute = function () {
// Execute the good function from the good storage.
......@@ -1037,7 +1037,7 @@ var JIO =
var m = 'Method: '+ settings.method +
', One or some parameters are undefined.';
console.error (m);
settings.callback({status:'fail',
settings.onResponse({status:'fail',
error: {status:0,
statusText:'Undefined Parameter',
message: m}});
......@@ -1128,14 +1128,14 @@ var JIO =
// return value.
// options.storage : the storage where to check (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
// - false if the job was not added
// - true if the job was added or replaced
// example :
// jio.checkNameAvailability({'user_name':'myName','callback':
// jio.checkNameAvailability({'user_name':'myName','onResponse':
// function (result) {
// if (result.status === 'done') {
// if (result.return_value === true) { // available
......@@ -1148,7 +1148,7 @@ var JIO =
'storage': priv.storage,
'applicant': priv.applicant,
'method': 'checkNameAvailability',
'callback': function () {}
'onResponse': function () {}
},options);
// check dependencies
if (that.isReady() && settings.user_name &&
......@@ -1164,14 +1164,14 @@ var JIO =
// 'job_done' will be sent with this job.
// options.storage : the storage where to save (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
// - false if the job was not added
// - true if the job was added or replaced
// jio.saveDocument({'name':'file','content':'content',
// 'callback': function (result) {
// 'onResponse': function (result) {
// if (result.status === 'done') { // Saved
// } else { } // Error
// }});
......@@ -1181,7 +1181,7 @@ var JIO =
'applicant': priv.applicant,
'content': '',
'method':'saveDocument',
'callback': function () {}
'onResponse': function () {}
},options);
// check dependencies
if (that.isReady() && settings.name &&
......@@ -1198,13 +1198,13 @@ var JIO =
// return value.
// options.storage : the storage where to load (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
// - false if the job was not added
// - true if the job was added or replaced
// jio.loadDocument({'name':'file','callback':
// jio.loadDocument({'name':'file','onResponse':
// function (result) {
// if (result.status === 'done') { // Loaded
// } else { } // Error
......@@ -1218,7 +1218,7 @@ var JIO =
'storage': priv.storage,
'applicant': priv.applicant,
'method':'loadDocument',
'callback': function(){}
'onResponse': function(){}
},options);
// check dependencies
if (that.isReady() && settings.name &&
......@@ -1233,13 +1233,13 @@ var JIO =
// or in the storage set at init.
// options.storage : the storage where to get the list (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
// - false if the job was not added
// - true if the job was added or replaced
// jio.getDocumentList({'callback':
// jio.getDocumentList({'onResponse':
// function (result) {
// if (result.status === 'done') { // OK
// console.log(result.return_value);
......@@ -1252,7 +1252,7 @@ var JIO =
'storage': priv.storage,
'applicant': priv.applicant,
'method':'getDocumentList',
'callback':function(){}
'onResponse':function(){}
},options);
// check dependencies
if (that.isReady() && settings.storage && settings.applicant ) {
......@@ -1266,13 +1266,13 @@ var JIO =
// or in the storage set at init.
// options.storage : the storage where to remove (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
// - false if the job was not added
// - true if the job was added or replaced
// jio.removeDocument({'name':'file','callback':
// jio.removeDocument({'name':'file','onResponse':
// function (result) {
// if(result.status === 'done') { // Removed
// } else { } // Not Removed
......@@ -1282,7 +1282,7 @@ var JIO =
'storage': priv.storage,
'applicant': priv.applicant,
'method':'removeDocument',
'callback':function (){}
'onResponse':function (){}
},options);
if (that.isReady() && settings.name &&
settings.storage && settings.applicant ) {
......
......@@ -589,13 +589,13 @@
that.setMaxTries (1);
priv.execJobsFromStorageArray = function (callback) {
priv.execJobsFromStorageArray = function (onResponse) {
var newjob = {}, i;
for (i = 0; i < priv.storageArray.length; i += 1) {
newjob = that.cloneJob();
newjob.max_tries = priv.max_tries;
newjob.storage = priv.storageArray[i];
newjob.callback = callback;
newjob.onResponse = onResponse;
that.addJob ( newjob ) ;
}
};
......@@ -607,7 +607,7 @@
// this.job.storage.storageArray: An Array of storages.
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);
if (!done) {
if (result.status === 'fail') {
......@@ -637,7 +637,7 @@
}
}
};
priv.execJobsFromStorageArray(callback);
priv.execJobsFromStorageArray(onResponse);
};
that.saveDocument = function () {
// Save a single document in several storages.
......@@ -651,7 +651,7 @@
var res = {'status':'done'}, i = 'id',
done = false, error_array = [],
callback = function (result) {
onResponse = function (result) {
priv.return_value_array.push(result);
if (!done) {
if (result.status !== 'fail') {
......@@ -671,7 +671,7 @@
}
}
};
priv.execJobsFromStorageArray(callback);
priv.execJobsFromStorageArray(onResponse);
};
that.loadDocument = function () {
......@@ -687,7 +687,7 @@
var doc = {}, i = 'id',
done = false, error_array = [],
res = {'status':'done'}, callback = function (result) {
res = {'status':'done'}, onResponse = function (result) {
priv.return_value_array.push(result);
if (!done) {
if (result.status !== 'fail') {
......@@ -707,7 +707,7 @@
}
}
};
priv.execJobsFromStorageArray(callback);
priv.execJobsFromStorageArray(onResponse);
};
that.getDocumentList = function () {
......@@ -720,7 +720,7 @@
var res = {'status':'done'}, i = 'id',
done = false, error_array = [],
callback = function (result) {
onResponse = function (result) {
priv.return_value_array.push(result);
if (!done) {
if (result.status !== 'fail') {
......@@ -740,7 +740,7 @@
}
}
};
priv.execJobsFromStorageArray(callback);
priv.execJobsFromStorageArray(onResponse);
};
that.removeDocument = function () {
......@@ -753,7 +753,7 @@
var res = {'status':'done'}, i = 'key',
done = false, error_array = [],
callback = function (result) {
onResponse = function (result) {
priv.return_value_array.push(result);
if (!done) {
if (result.status !== 'fail') {
......@@ -773,7 +773,7 @@
}
}
};
priv.execJobsFromStorageArray(callback);
priv.execJobsFromStorageArray(onResponse);
};
return that;
};
......@@ -929,9 +929,9 @@
* returned the result.
* @method update
*/
priv.update = function (callback) {
priv.update = function (onResponse) {
// retreive list before, and then retreive all files
var getlist_callback = function (result) {
var getlist_onResponse = function (result) {
if (result.status === 'done') {
if (!priv.isAnIndexedStorage(that.getSecondStorage())) {
priv.addIndexedStorage(that.getSecondStorage());
......@@ -944,7 +944,7 @@
applicant: {ID:that.getApplicantID()},
method: 'getDocumentList',
max_tries: 3,
callback: getlist_callback
onResponse: getlist_onResponse
};
that.addJob ( newjob );
};
......@@ -957,7 +957,7 @@
var new_job = that.cloneJob();
priv.update();
new_job.storage = that.getSecondStorage();
new_job.callback = function (result) {
new_job.onResponse = function (result) {
if (result.status === 'done') {
that.done(result.return_value);
} else {
......@@ -974,7 +974,7 @@
that.saveDocument = function () {
var new_job = that.cloneJob();
new_job.storage = that.getSecondStorage();
new_job.callback = function (result) {
new_job.onResponse = function (result) {
if (result.status === 'done') {
if (!priv.isFileIndexed(that.getFileName())) {
priv.addFile({name:that.getFileName(),
......@@ -998,7 +998,7 @@
*/
that.loadDocument = function () {
var file_array, i, l, new_job,
loadCallback = function (result) {
loadOnResponse = function (result) {
if (result.status === 'done') {
// if (file_array[i].last_modified !==
// result.return_value.last_modified ||
......@@ -1016,7 +1016,7 @@
secondLoadDocument = function () {
new_job = that.cloneJob();
new_job.storage = that.getSecondStorage();
new_job.callback = loadCallback;
new_job.onResponse = loadOnResponse;
that.addJob ( new_job );
},
settings = that.cloneOptionObject();
......@@ -1061,7 +1061,7 @@
that.removeDocument = function () {
var new_job = that.cloneJob();
new_job.storage = that.getSecondStorage();
new_job.callback = function (result) {
new_job.onResponse = function (result) {
if (result.status === 'done') {
priv.removeFile(that.getFileName());
priv.update();
......@@ -1139,7 +1139,7 @@
that.checkNameAvailability = function () {
var new_job = that.cloneJob();
new_job.storage = that.getSecondStorage();
new_job.callback = function (result) {
new_job.onResponse = function (result) {
if (result.status === 'done') {
that.done(result.return_value);
} else {
......@@ -1172,7 +1172,7 @@
new_job.name = new_file_name;
new_job.content = newfilecontent;
new_job.storage = that.getSecondStorage();
new_job.callback = function (result) {
new_job.onResponse = function (result) {
if (result.status === 'done') {
that.done();
} else {
......@@ -1202,10 +1202,10 @@
new_job = that.cloneJob();
new_job.name = new_file_name;
new_job.storage = that.getSecondStorage();
new_job.callback = loadCallback;
new_job.onResponse = loadOnResponse;
that.addJob ( new_job );
},
loadCallback = function (result) {
loadOnResponse = function (result) {
if (result.status === 'done') {
result.return_value.name = that.getFileName();
if (option.metadata_only) {
......@@ -1243,24 +1243,24 @@
_1 = function () {
new_job = that.cloneJob();
new_job.storage = that.getSecondStorage();
new_job.callback = getListCallback;
new_job.onResponse = getListOnResponse;
that.addJob ( new_job );
},
getListCallback = function (result) {
getListOnResponse = function (result) {
if (result.status === 'done') {
array = result.return_value;
for (i = 0, l = array.length; i < l; i+= 1) {
// cpt--;
priv.decrypt (array[i].name,
lastCallback,i,'name');
lastOnResponse,i,'name');
// priv.decrypt (array[i].content,
// lastCallback,i,'content');
// lastOnResponse,i,'content');
}
} else {
that.fail(result.error);
}
},
lastCallback = function (res,index,key) {
lastOnResponse = function (res,index,key) {
var tmp;
cpt++;
if (typeof res === 'object') {
......@@ -1296,10 +1296,10 @@
new_job = that.cloneJob();
new_job.name = new_file_name;
new_job.storage = that.getSecondStorage();
new_job.callback = removeCallback;
new_job.onResponse = removeOnResponse;
that.addJob(new_job);
},
removeCallback = function (result) {
removeOnResponse = function (result) {
if (result.status === 'done') {
that.done();
} else {
......
This diff is collapsed.
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