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

Fix bug: copy object will now clone object instead of clone object root only.

parent e159ec00
/**
* JavaScript Input/Output
* @namespace JIO
* @module JIO
*/
var JIO = var JIO =
(function () { var jio_loader_function = function ( localOrCookieStorage, $ ) { (function () { var jio_loader_function = function ( localOrCookieStorage, $ ) {
...@@ -166,13 +170,6 @@ var JIO = ...@@ -166,13 +170,6 @@ var JIO =
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Tools // Tools
extend = function (o1,o2) {
var key;
for (key in o2) {
o1[key] = o2[key];
}
return o1;
},
// end Tools // end Tools
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
...@@ -226,7 +223,7 @@ var JIO = ...@@ -226,7 +223,7 @@ var JIO =
newJob = function ( spec, my ) { newJob = function ( spec, my ) {
// Job constructor // Job constructor
var job = extend({},spec); var job = $.extend(true,{},spec);
job['id']=0; job['id']=0;
job['status']='initial'; job['status']='initial';
job['date']=Date.now(); job['date']=Date.now();
...@@ -438,7 +435,7 @@ var JIO = ...@@ -438,7 +435,7 @@ var JIO =
// options.job = the job object containing at least {id:..}. // options.job = the job object containing at least {id:..}.
// options.where = remove values where options.where(job) === true // options.where = remove values where options.where(job) === true
var settings = extend ({where:function (job) {return true;}}, var settings = $.extend ({where:function (job) {return true;}},
options),andwhere,found=false,k='key'; options),andwhere,found=false,k='key';
//// modify the job list //// modify the job list
...@@ -553,7 +550,7 @@ var JIO = ...@@ -553,7 +550,7 @@ var JIO =
// It is a callback function called just before user callback. // It is a callback function called just before user callback.
// 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({},endedjob); // copy var job = $.extend(true,{},endedjob); // copy
// This job is supposed terminated, we can remove it from queue. // This job is supposed terminated, we can remove it from queue.
that.removeJob ({'job':job}); that.removeJob ({'job':job});
...@@ -797,7 +794,7 @@ var JIO = ...@@ -797,7 +794,7 @@ var JIO =
//// Getters Setters //// Getters Setters
that.cloneJob = function () { that.cloneJob = function () {
return extend({},priv.job); return $.extend(true,{},priv.job);
}; };
that.getUserName = function () { that.getUserName = function () {
return priv.job.userName || ''; return priv.job.userName || '';
...@@ -814,6 +811,9 @@ var JIO = ...@@ -814,6 +811,9 @@ var JIO =
that.getStorageLocation = function () { that.getStorageLocation = function () {
return priv.job.storage.location || ''; return priv.job.storage.location || '';
}; };
that.getSecondStorage = function () {
return priv.job.storage.storage || {};
};
that.getStorageArray = function () { that.getStorageArray = function () {
return priv.job.storage.storageArray || []; return priv.job.storage.storageArray || [];
}; };
...@@ -824,7 +824,7 @@ var JIO = ...@@ -824,7 +824,7 @@ var JIO =
return priv.job.fileContent || ''; return priv.job.fileContent || '';
}; };
that.cloneOptionObject = function () { that.cloneOptionObject = function () {
return extend({},priv.job.options); return $.extend(true,{},priv.job.options);
}; };
that.getMaxTries = function () { that.getMaxTries = function () {
return priv.job.maxtries; return priv.job.maxtries;
...@@ -1143,7 +1143,7 @@ var JIO = ...@@ -1143,7 +1143,7 @@ var JIO =
// } else { } // Error // } else { } // Error
// }}); // }});
var settings = extend ({ var settings = $.extend (true,{
'userName': priv.storage.userName, 'userName': priv.storage.userName,
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
...@@ -1176,7 +1176,7 @@ var JIO = ...@@ -1176,7 +1176,7 @@ var JIO =
// } else { } // Error // } else { } // Error
// }}); // }});
var settings = extend({ var settings = $.extend(true,{
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'fileContent': '', 'fileContent': '',
...@@ -1214,7 +1214,7 @@ var JIO = ...@@ -1214,7 +1214,7 @@ var JIO =
// fileName:'string',fileContent:'string', // fileName:'string',fileContent:'string',
// creationDate:123,lastModified:456 } // creationDate:123,lastModified:456 }
var settings = extend ({ var settings = $.extend (true,{
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'method':'loadDocument', 'method':'loadDocument',
...@@ -1248,7 +1248,7 @@ var JIO = ...@@ -1248,7 +1248,7 @@ var JIO =
// result.return_value is an Array that contains documents objects. // result.return_value is an Array that contains documents objects.
var settings = extend ({ var settings = $.extend (true,{
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'method':'getDocumentList', 'method':'getDocumentList',
...@@ -1278,7 +1278,7 @@ var JIO = ...@@ -1278,7 +1278,7 @@ var JIO =
// } else { } // Not Removed // } else { } // Not Removed
// }}); // }});
var settings = extend ({ var settings = $.extend (true,{
'storage': priv.storage, 'storage': priv.storage,
'applicant': priv.applicant, 'applicant': priv.applicant,
'method':'removeDocument', 'method':'removeDocument',
...@@ -1293,7 +1293,7 @@ var JIO = ...@@ -1293,7 +1293,7 @@ var JIO =
//// end Methods //// end Methods
//// Initialize //// Initialize
var settings = extend({'use_local_storage':true},spec.options); var settings = $.extend(true,{'use_local_storage':true},spec.options);
// objectify storage and applicant // objectify storage and applicant
if(typeof spec.storage === 'string') { if(typeof spec.storage === 'string') {
...@@ -1346,7 +1346,7 @@ var JIO = ...@@ -1346,7 +1346,7 @@ var JIO =
// applicant: the applicant object or json string // applicant: the applicant object or json string
// options.useLocalStorage: if true, save job queue on localStorage. // options.useLocalStorage: if true, save job queue on localStorage.
var settings = extend({'use_local_storage':true},options); var settings = $.extend(true,{'use_local_storage':true},options);
return newJioConstructor({storage:storage, return newJioConstructor({storage:storage,
applicant:applicant, applicant:applicant,
...@@ -1377,7 +1377,7 @@ var JIO = ...@@ -1377,7 +1377,7 @@ var JIO =
}; };
that.getConstObject = function () { that.getConstObject = function () {
// Returns a copy of the constants // Returns a copy of the constants
return extend({},jio_const_obj); return $.extend(true,{},jio_const_obj);
}; };
return that; return that;
}; };
......
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