varJIO=function(){vara=function(a,b){varc={job_method_object:{checkNameAvailability:{},saveDocument:{},loadDocument:{},getDocumentList:{},removeDocument:{}}},d={job_managing_method:{canSelect:function(a,b){returnJSON.stringify(a.storage)===JSON.stringify(b.storage)&&JSON.stringify(a.applicant)===JSON.stringify(b.applicant)&&a.fileName===b.fileName?!0:!1},canRemoveFailOrDone:function(a,b){returna.status==="fail"||a.status==="done"?!0:!1},canEliminate:function(a,b){returna.status!=="ongoing"&&(a.method==="removeDocument"&&b.method==="saveDocument"||a.method==="saveDocument"&&b.method==="removeDocument")?!0:!1},canReplace:function(a,b){returna.status!=="ongoing"&&a.method===b.method&&a.date<b.date?!0:!1},cannotAccept:function(a,b){if(a.status!=="ongoing"){if(a.method==="removeDocument"&&b.method==="loadDocument")return!0}else{if(a.method===b.method==="loadDocument")return!0;if(a.method==="removeDocument"&&(b.method==="loadDocument"||b.method==="removeDocument"))return!0;if(a.method===b.method==="saveDocument"&&a.fileContent===b.fileContent)return!0;if(a.method===b.method==="getDocumentList"||a.method===b.method==="checkNameAvailability")return!0}return!1},mustWait:function(a,b){returna.method==="getDocumentList"||a.method==="checkNameAvailability"||b.method==="getDocumentList"||b.method==="checkNameAvailability"?!1:!0}},queue_id:1,storage_type_object:{},max_wait_time:1e4},e=function(a,b){varc;for(cinb)a[c]=b[c];returna},f,g,h,i,j,k,l,m;returnf=function(a,c){vard={},e={},f={},g,h;returne.eventAction=function(a){returnh=a&&f[a],h||(g=b.Callbacks(),h={publish:g.fire,subscribe:g.add,unsubscribe:g.remove},a&&(f[a]=h)),h},d.publish=function(a,b){e.eventAction(a).publish(b)},d.subscribe=function(a,b){returne.eventAction(a).subscribe(b),b},d.unsubscribe=function(a,b){e.eventAction(a).unsubscribe(b)},d},g=function(a,b){varc=e({},a);returnc.id=0,c.status="initial",c.date=Date.now(),c},h=function(b,f){varh={},i={},j="jio/idarray";returnh.init=function(c){vard,e=function(){},f;i.use_local_storage&&(f=a.getItem(j)||[],b.publisher&&(i.publisher=b.publisher),i.jio_id=c.jio_id,i.job_object_name="jio/jobobject/"+i.jio_id,f.push(i.jio_id),a.setItem(j,f)),i.job_object={},h.copyJobQueueToLocalStorage();for(dini.recovered_job_object)i.recovered_job_object[d].callback=e,h.addJob(i.recovered_job_object[d])},h.close=function(){JSON.stringify(i.job_object)==="{}"&&a.deleteItem(i.job_object_name)},h.getNewQueueID=function(){varb=null,c=0,e=a.getItem(j)||[];for(b=0;b<e.length;b+=1)e[b]>=d.queue_id&&(d.queue_id=e[b]+1);returnc=d.queue_id,d.queue_id++,c},h.recoverOlderJobObject=function(){varb=null,c=[],d=!1,e;if(i.use_local_storage){e=a.getItem(j)||[];for(b=0;b<e.length;b+=1)a.getItem("jio/id/"+e[b])<Date.now()-1e4?(a.deleteItem("jio/id/"+e[b]),i.recovered_job_object=a.getItem("jio/jobobject/"+e[b]),a.deleteItem("jio/jobobject/"+e[b]),d=!0):c.push(e[b]);d&&a.setItem(j,c)}},h.isThereJobsWhere=function(a){varb="id";if(!a)return!0;for(bini.job_object)if(a(i.job_object[b]))return!0;return!1},h.copyJobQueueToLocalStorage=function(){returni.use_local_storage?a.setItem(i.job_object_name,i.job_object):!1},h.createJob=function(a){returnh.addJob(g(a))},h.addJob=function(a){varb=!0,c=[],e=[],f=[],g=null,j="id";for(jini.job_object){if(d.job_managing_method.canRemoveFailOrDone(i.job_object[j],a)){f.push(j);continue}if(d.job_managing_method.canSelect(i.job_object[j],a)){if(d.job_managing_method.canEliminate(i.job_object[j],a)){c.push(j);continue}if(d.job_managing_method.canReplace(i.job_object[j],a)){g=k({queue:h,job:i.job_object[j]}),g.replace(a),b=!1;break}if(d.job_managing_method.cannotAccept(i.job_object[j],a))return!1;if(d.job_managing_method.mustWait(i.job_object[j],a)){e.push(j);continue}}}if(b){for(j=0;j<c.length;j+=1)g=k({queue:h,job:i.job_object[c[j]]}),g.eliminate();if(e.length>0){a.status="wait",a.waitingFor={jobIdArray:e};for(j=0;j<e.length;j+=1)i.job_object[e[j]]&&(i.job_object[e[j]].maxtries=1)}for(j=0;j<f.length;j+=1)h.removeJob(i.job_object[f[j]]);a.id=i.job_id,a.tries=0,i.job_id++,i.job_object[a.id]=a}returnh.copyJobQueueToLocalStorage(),!0},h.removeJob=function(a){varb=e({where:function(a){return!0}},a),c,d=!1,f="key";if(b.job)i.job_object[b.job.id]&&b.where(i.job_object[b.job.id])&&(deletei.job_object[b.job.id],d=!0);elsefor(fini.job_object)b.where(i.job_object[f])&&(deletei.job_object[f],d=!0);d||console.error("No jobs was found, when trying to remove some."),h.copyJobQueueToLocalStorage()},h.resetAll=function(){vara="id";for(aini.job_object)i.job_object[a].status="initial";h.copyJobQueueToLocalStorage()},h.invokeAll=function(){vara="id",b,c;for(aini.job_object){c=!1;if(i.job_object[a].status==="initial")h.invoke(i.job_object[a]);elseif(i.job_object[a].status==="wait"){c=!0;if(i.job_object[a].waitingFor.jobIdArray)for(b=0;b<i.job_object[a].waitingFor.jobIdArray.length;b+=1)if(i.job_object[i.job_object[a].waitingFor.jobIdArray[b]]){c=!1;break}i.job_object[a].waitingFor.time&&i.job_object[a].waitingFor.time>Date.now()&&(c=!1),c&&h.invoke(i.job_object[a])}}this.copyJobQueueToLocalStorage()},h.invoke=function(a){varb;if(!c.job_method_object[a.method])return!1;h.isThereJobsWhere(function(b){returnb.method===a.method&&b.method==="initial"})?a.status="ongoing":(a.status="ongoing",i.publisher.publish(c.job_method_object[a.method]["start_"+a.method])),b=k({queue:this,job:a}),b.execute()},h.ended=function(a){varb=e({},a);h.removeJob({job:b});if(!c.job_method_object[b.method])return!1;if(!h.isThereJobsWhere(function(a){returna.method===b.method&&a.status==="ongoing"||a.status==="initial"})){i.publisher.publish(c.job_method_object[b.method]["stop_"+b.method]);return}},h.clean=function(){h.removeJob(undefined,{where:function(a){returna.status==="fail"}})},i.use_local_storage=b.options.use_local_storage,i.publisher=b.publisher,i.job_id=1,i.jio_id=0,i.job_object_name="",i.job_object={},i.recovered_job_object={},h},i=function(a,b){varc={},d={};returnd.interval=200,d.id=null,d.queue=a.queue,c.setIntervalDelay=function(a){d.interval=a},c.start=function(){returnd.id?!1:(d.id=setInterval(function(){d.queue.recoverOlderJobObject(),d.queue.invokeAll()},d.interval),!0)},c.stop=function(){returnd.id?(clearInterval(d.id),d.id=null,!0):!1},c},j=function(){varb={},c={};returnc.interval=400,c.id=null,b.start=function(a){returnc.id?!1:(b.touch(a),c.id=setInterval(function(){b.touch(a)},c.interval),!0)},b.stop=function(){returnc.id?(clearInterval(c.id),c.id=null,!0):!1},b.touch=function(b){a.setItem("jio/id/"+b,Date.now())},b},k=function(a){varb={},c={};returnc.job=a.job,c.callback=a.job.callback,c.queue=a.queue,c.res={status:"done",message:""},c.fail_checkNameAvailability=function(){c.res.message="Unable to check name availability."},c.done_checkNameAvailability=function(a){c.res.message=c.job.userName+" is "+(a?"":"not ")+"available.",c.res.return_value=a},c.fail_loadDocument=function(){c.res.message="Unable to load document."},c.done_loadDocument=function(a){c.res.message="Document loaded.",c.res.return_value=a,c.res.return_value.lastModified=(newDate(c.res.return_value.lastModified)).getTime(),c.res.return_value.creationDate=(newDate(c.res.return_value.creationDate)).getTime()},c.fail_saveDocument=function(){c.res.message="Unable to save document."},c.done_saveDocument=function(){c.res.message="Document saved."},c.fail_getDocumentList=function(){c.res.message="Unable to retrieve document list."},c.done_getDocumentList=function(a){varb;c.res.message="Document list received.",c.res.return_value=a;for(b=0;b<c.res.return_value.length;b+=1)c.res.return_value[b].lastModified=(newDate(c.res.return_value[b].lastModified)).getTime(),c.res.return_value[b].creationDate=(newDate(c.res.return_value[b].creationDate)).getTime()},c.fail_removeDocument=function(){c.res.message="Unable to removed document."},c.done_removeDocument=function(){c.res.message="Document removed."},c.retryLater=function(){vara=c.job.tries*c.job.tries*1e3;a>d.max_wait_time&&(a=d.max_wait_time),c.job.status="wait",c.job.waitingFor={time:Date.now()+a}},b.cloneJob=function(){returne({},c.job)},b.getUserName=function(){returnc.job.userName||""},b.getApplicantID=function(){returnc.job.applicant.ID||""},b.getStorageUserName=function(){returnc.job.storage.userName||""},b.getStoragePassword=function(){returnc.job.storage.password||""},b.getStorageLocation=function(){returnc.job.storage.location||""},b.getStorageArray=function(){returnc.job.storage.storageArray||[]},b.getFileName=function(){returnc.job.fileName||""},b.getFileContent=function(){returnc.job.fileContent||""},b.cloneOptionObject=function(){returne({},c.job.options)},b.getMaxTries=function(){returnc.job.maxtries},b.getTries=function(){returnc.job.tries||0},b.setMaxTries=function(a){c.job.maxtries=a},b.addJob=function(a){returnc.queue.createJob(a)},b.eliminate=function(){c.job.maxtries=1,c.job.tries=1,b.fail("Job Stopped!",0)},b.replace=function(a){c.job.tries=0,c.job.date=a.date,c.job.callback=a.callback,c.res.status="fail",c.res.message="Job Stopped!",c.res.error={},c.res.error.status=0,c.res.error.statusText="Replaced",c.res.error.message="The job was replaced by a newer one.",c["fail_"+c.job.method](),c.callback(c.res)},b.fail=function(a){c.res.status="fail",c.res.error=a,c.res.error.status=c.res.error.status||0,c.res.error.statusText=c.res.error.statusText||"Unknown Error",c.res.error.array=c.res.error.array||[],c.res.error.message=c.res.error.message||"",!c.job.maxtries||c.job.tries<c.job.maxtries?c.retryLater():(c.job.status="fail",c["fail_"+c.job.method](),c.queue.ended(c.job),c.callback(c.res))},b.done=function(a){c.job.status="done",c["done_"+c.job.method](a),c.queue.ended(c.job),c.callback(c.res)},b.execute=function(){returnc.job.tries=b.getTries()+1,d.storage_type_object[c.job.storage.type]?d.storage_type_object[c.job.storage.type]({job:c.job,queue:c.queue})[c.job.method]():null},b.checkNameAvailability=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b.loadDocument=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b.saveDocument=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b.getDocumentList=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b.removeDocument=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b},l=function(a,b){varc={},g={};c.getID=function(){returng.id},c.start=function(){returng.id!==0?!1:(g.id=g.queue.getNewQueueID(),g.queue.init({jio_id:g.id}),g.updater&&g.updater.start(g.id),g.listener.start(),g.ready=!0,c.isReady())},c.stop=function(){returng.queue.close(),g.listener.stop(),g.updater&&g.updater.stop(),g.ready=!1,g.id=0,!0},c.kill=function(){returng.queue.close(),g.listener.stop(),g.updater&&g.updater.stop(),g.ready=!1,!0},c.isReady=function(){returng.ready},c.publish=function(a,b){if(!c.isReady())return;returng.pubsub.publish(a,b)},c.subscribe=function(a,b){returng.pubsub.subscribe(a,b)},c.unsubscribe=function(a,b){returng.pubsub.unsubscribe(a,b)},c.checkNameAvailability=function(a){varb=e({userName:g.storage.userName,storage:g.storage,applicant:g.applicant,method:"checkNameAvailability",callback:function(){}},a);returnc.isReady()&&b.userName&&b.storage&&b.applicant?g.queue.createJob(b):null},c.saveDocument=function(a){varb=e({storage:g.storage,applicant:g.applicant,method:"saveDocument",callback:function(){}},a);returnc.isReady()&&b.fileName&&b.fileContent&&b.storage&&b.applicant?g.queue.createJob(b):null},c.loadDocument=function(a){varb=e({storage:g.storage,applicant:g.applicant,method:"loadDocument",callback:function(){}},a);returnc.isReady()&&b.fileName&&b.storage&&b.applicant?g.queue.createJob(b):null},c.getDocumentList=function(a){varb=e({storage:g.storage,applicant:g.applicant,method:"getDocumentList",callback:function(){}},a);returnc.isReady()&&b.storage&&b.applicant?g.queue.createJob(b):null},c.removeDocument=function(a){varb=e({storage:g.storage,applicant:g.applicant,method:"removeDocument",callback:function(){}},a);returnc.isReady()&&b.fileName&&b.storage&&b.applicant?g.queue.createJob(b):null};vark=e({use_local_storage:!0},a.options);returntypeofa.storage=="string"&&(a.storage=JSON.parse(a.storage)),typeofa.applicant=="string"&&(a.applicant=JSON.parse(a.applicant)),g.storage=a.storage,g.applicant=a.applicant,g.id=0,g.pubsub=f({options:k}),g.queue=h({publisher:g.pubsub,options:k}),g.listener=i({queue:g.queue,options:k}),g.ready=!1,k.use_local_storage?g.updater=j({options:k}):g.updater=null,g.storage&&!d.storage_type_object[g.storage.type]&&console.error('Unknown storage type "'+g.storage.type+'"'),c.start(),c},m=function(a,b){varf={};returnf.createNew=function(a,b,c){vard=e({use_local_storage:!0},c);returnl({storage:a,applicant:b,options:d})},f.newBaseStorage=function(a,b){returnk(a,b)},f.addStorageType=function(a,b){returna&&b?(d.storage_type_object[a]=b,!0):!1},f.getGlobalObject=function(){returnd},f.getConstObject=function(){returne({},c)},f},m()};returnwindow.requirejs?(define("JIO",["LocalOrCookieStorage","jQuery"],a),undefined):a(LocalOrCookieStorage,jQuery)}();
\ No newline at end of file
varJIO=function(){vara=function(a,b){varc={job_method_object:{checkNameAvailability:{},saveDocument:{},loadDocument:{},getDocumentList:{},removeDocument:{}}},d={job_managing_method:{canSelect:function(a,b){returnJSON.stringify(a.storage)===JSON.stringify(b.storage)&&JSON.stringify(a.applicant)===JSON.stringify(b.applicant)&&a.fileName===b.fileName?!0:!1},canRemoveFailOrDone:function(a,b){returna.status==="fail"||a.status==="done"?!0:!1},canEliminate:function(a,b){returna.status!=="ongoing"&&(a.method==="removeDocument"&&b.method==="saveDocument"||a.method==="saveDocument"&&b.method==="removeDocument")?!0:!1},canReplace:function(a,b){returna.status!=="ongoing"&&a.method===b.method&&a.date<b.date?!0:!1},cannotAccept:function(a,b){if(a.status!=="ongoing"){if(a.method==="removeDocument"&&b.method==="loadDocument")return!0}else{if(a.method===b.method==="loadDocument")return!0;if(a.method==="removeDocument"&&(b.method==="loadDocument"||b.method==="removeDocument"))return!0;if(a.method===b.method==="saveDocument"&&a.fileContent===b.fileContent)return!0;if(a.method===b.method==="getDocumentList"||a.method===b.method==="checkNameAvailability")return!0}return!1},mustWait:function(a,b){returna.method==="getDocumentList"||a.method==="checkNameAvailability"||b.method==="getDocumentList"||b.method==="checkNameAvailability"?!1:!0}},queue_id:1,storage_type_object:{},max_wait_time:1e4},e=function(a,b){varc;for(cinb)a[c]=b[c];returna},f,g,h,i,j,k,l,m;returnf=function(a,c){vard={},e={},f={},g,h;returne.eventAction=function(a){returnh=a&&f[a],h||(g=b.Callbacks(),h={publish:g.fire,subscribe:g.add,unsubscribe:g.remove},a&&(f[a]=h)),h},d.publish=function(a,b){e.eventAction(a).publish(b)},d.subscribe=function(a,b){returne.eventAction(a).subscribe(b),b},d.unsubscribe=function(a,b){e.eventAction(a).unsubscribe(b)},d},g=function(a,b){varc=e({},a);returnc.id=0,c.status="initial",c.date=Date.now(),c},h=function(b,f){varh={},i={},j="jio/idarray";returnh.init=function(c){vard,e=function(){},f;i.use_local_storage&&(f=a.getItem(j)||[],b.publisher&&(i.publisher=b.publisher),i.jio_id=c.jio_id,i.job_object_name="jio/jobobject/"+i.jio_id,f.push(i.jio_id),a.setItem(j,f)),i.job_object={},h.copyJobQueueToLocalStorage();for(dini.recovered_job_object)i.recovered_job_object[d].callback=e,h.addJob(i.recovered_job_object[d])},h.close=function(){JSON.stringify(i.job_object)==="{}"&&a.deleteItem(i.job_object_name)},h.getNewQueueID=function(){varb=null,c=0,e=a.getItem(j)||[];for(b=0;b<e.length;b+=1)e[b]>=d.queue_id&&(d.queue_id=e[b]+1);returnc=d.queue_id,d.queue_id++,c},h.recoverOlderJobObject=function(){varb=null,c=[],d=!1,e;if(i.use_local_storage){e=a.getItem(j)||[];for(b=0;b<e.length;b+=1)a.getItem("jio/id/"+e[b])<Date.now()-1e4?(a.deleteItem("jio/id/"+e[b]),i.recovered_job_object=a.getItem("jio/jobobject/"+e[b]),a.deleteItem("jio/jobobject/"+e[b]),d=!0):c.push(e[b]);d&&a.setItem(j,c)}},h.isThereJobsWhere=function(a){varb="id";if(!a)return!0;for(bini.job_object)if(a(i.job_object[b]))return!0;return!1},h.copyJobQueueToLocalStorage=function(){returni.use_local_storage?a.setItem(i.job_object_name,i.job_object):!1},h.createJob=function(a){returnh.addJob(g(a))},h.addJob=function(a){varb=!0,c=[],e=[],f=[],g=null,j="id";for(jini.job_object){if(d.job_managing_method.canRemoveFailOrDone(i.job_object[j],a)){f.push(j);continue}if(d.job_managing_method.canSelect(i.job_object[j],a)){if(d.job_managing_method.canEliminate(i.job_object[j],a)){c.push(j);continue}if(d.job_managing_method.canReplace(i.job_object[j],a)){g=k({queue:h,job:i.job_object[j]}),g.replace(a),b=!1;break}if(d.job_managing_method.cannotAccept(i.job_object[j],a))return!1;if(d.job_managing_method.mustWait(i.job_object[j],a)){e.push(j);continue}}}if(b){for(j=0;j<c.length;j+=1)g=k({queue:h,job:i.job_object[c[j]]}),g.eliminate();if(e.length>0){a.status="wait",a.waitingFor={jobIdArray:e};for(j=0;j<e.length;j+=1)i.job_object[e[j]]&&(i.job_object[e[j]].maxtries=1)}for(j=0;j<f.length;j+=1)h.removeJob(i.job_object[f[j]]);a.id=i.job_id,a.tries=0,i.job_id++,i.job_object[a.id]=a}returnh.copyJobQueueToLocalStorage(),!0},h.removeJob=function(a){varb=e({where:function(a){return!0}},a),c,d=!1,f="key";if(b.job)i.job_object[b.job.id]&&b.where(i.job_object[b.job.id])&&(deletei.job_object[b.job.id],d=!0);elsefor(fini.job_object)b.where(i.job_object[f])&&(deletei.job_object[f],d=!0);d||console.error("No jobs was found, when trying to remove some."),h.copyJobQueueToLocalStorage()},h.resetAll=function(){vara="id";for(aini.job_object)i.job_object[a].status="initial";h.copyJobQueueToLocalStorage()},h.invokeAll=function(){vara="id",b,c;for(aini.job_object){c=!1;if(i.job_object[a].status==="initial")h.invoke(i.job_object[a]);elseif(i.job_object[a].status==="wait"){c=!0;if(i.job_object[a].waitingFor.jobIdArray)for(b=0;b<i.job_object[a].waitingFor.jobIdArray.length;b+=1)if(i.job_object[i.job_object[a].waitingFor.jobIdArray[b]]){c=!1;break}i.job_object[a].waitingFor.time&&i.job_object[a].waitingFor.time>Date.now()&&(c=!1),c&&h.invoke(i.job_object[a])}}this.copyJobQueueToLocalStorage()},h.invoke=function(a){varb;if(!c.job_method_object[a.method])return!1;h.isThereJobsWhere(function(b){returnb.method===a.method&&b.method==="initial"})?a.status="ongoing":(a.status="ongoing",i.publisher.publish(c.job_method_object[a.method]["start_"+a.method])),b=k({queue:this,job:a}),b.execute()},h.ended=function(a){varb=e({},a);h.removeJob({job:b});if(!c.job_method_object[b.method])return!1;if(!h.isThereJobsWhere(function(a){returna.method===b.method&&a.status==="ongoing"||a.status==="initial"})){i.publisher.publish(c.job_method_object[b.method]["stop_"+b.method]);return}},h.clean=function(){h.removeJob(undefined,{where:function(a){returna.status==="fail"}})},i.use_local_storage=b.options.use_local_storage,i.publisher=b.publisher,i.job_id=1,i.jio_id=0,i.job_object_name="",i.job_object={},i.recovered_job_object={},h},i=function(a,b){varc={},d={};returnd.interval=200,d.id=null,d.queue=a.queue,c.setIntervalDelay=function(a){d.interval=a},c.start=function(){returnd.id?!1:(d.id=setInterval(function(){d.queue.recoverOlderJobObject(),d.queue.invokeAll()},d.interval),!0)},c.stop=function(){returnd.id?(clearInterval(d.id),d.id=null,!0):!1},c},j=function(){varb={},c={};returnc.interval=400,c.id=null,b.start=function(a){returnc.id?!1:(b.touch(a),c.id=setInterval(function(){b.touch(a)},c.interval),!0)},b.stop=function(){returnc.id?(clearInterval(c.id),c.id=null,!0):!1},b.touch=function(b){a.setItem("jio/id/"+b,Date.now())},b},k=function(a){varb={},c={};returnc.job=a.job,c.callback=a.job.callback,c.queue=a.queue,c.res={status:"done",message:""},c.fail_checkNameAvailability=function(){c.res.message="Unable to check name availability."},c.done_checkNameAvailability=function(a){c.res.message=c.job.userName+" is "+(a?"":"not ")+"available.",c.res.return_value=a},c.fail_loadDocument=function(){c.res.message="Unable to load document."},c.done_loadDocument=function(a){c.res.message="Document loaded.",c.res.return_value=a,c.res.return_value.lastModified=(newDate(c.res.return_value.lastModified)).getTime(),c.res.return_value.creationDate=(newDate(c.res.return_value.creationDate)).getTime()},c.fail_saveDocument=function(){c.res.message="Unable to save document."},c.done_saveDocument=function(){c.res.message="Document saved."},c.fail_getDocumentList=function(){c.res.message="Unable to retrieve document list."},c.done_getDocumentList=function(a){varb;c.res.message="Document list received.",c.res.return_value=a;for(b=0;b<c.res.return_value.length;b+=1)c.res.return_value[b].lastModified=(newDate(c.res.return_value[b].lastModified)).getTime(),c.res.return_value[b].creationDate=(newDate(c.res.return_value[b].creationDate)).getTime()},c.fail_removeDocument=function(){c.res.message="Unable to removed document."},c.done_removeDocument=function(){c.res.message="Document removed."},c.retryLater=function(){vara=c.job.tries*c.job.tries*1e3;a>d.max_wait_time&&(a=d.max_wait_time),c.job.status="wait",c.job.waitingFor={time:Date.now()+a}},b.cloneJob=function(){returne({},c.job)},b.getUserName=function(){returnc.job.userName||""},b.getApplicantID=function(){returnc.job.applicant.ID||""},b.getStorageUserName=function(){returnc.job.storage.userName||""},b.getStoragePassword=function(){returnc.job.storage.password||""},b.getStorageLocation=function(){returnc.job.storage.location||""},b.getStorageArray=function(){returnc.job.storage.storageArray||[]},b.getFileName=function(){returnc.job.fileName||""},b.getFileContent=function(){returnc.job.fileContent||""},b.cloneOptionObject=function(){returne({},c.job.options)},b.getMaxTries=function(){returnc.job.maxtries},b.getTries=function(){returnc.job.tries||0},b.setMaxTries=function(a){c.job.maxtries=a},b.addJob=function(a){returnc.queue.createJob(a)},b.eliminate=function(){c.job.maxtries=1,c.job.tries=1,b.fail("Job Stopped!",0)},b.replace=function(a){c.job.tries=0,c.job.date=a.date,c.job.callback=a.callback,c.res.status="fail",c.res.message="Job Stopped!",c.res.error={},c.res.error.status=0,c.res.error.statusText="Replaced",c.res.error.message="The job was replaced by a newer one.",c["fail_"+c.job.method](),c.callback(c.res)},b.fail=function(a){c.res.status="fail",c.res.error=a,c.res.error.status=c.res.error.status||0,c.res.error.statusText=c.res.error.statusText||"Unknown Error",c.res.error.array=c.res.error.array||[],c.res.error.message=c.res.error.message||"",!c.job.maxtries||c.job.tries<c.job.maxtries?c.retryLater():(c.job.status="fail",c["fail_"+c.job.method](),c.queue.ended(c.job),c.callback(c.res))},b.done=function(a){c.job.status="done",c["done_"+c.job.method](a),c.queue.ended(c.job),c.callback(c.res)},b.execute=function(){returnc.job.tries=b.getTries()+1,d.storage_type_object[c.job.storage.type]?d.storage_type_object[c.job.storage.type]({job:c.job,queue:c.queue})[c.job.method]():null},b.checkNameAvailability=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b.loadDocument=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b.saveDocument=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b.getDocumentList=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b.removeDocument=function(){b.fail({status:0,statusText:"Undefined Method",message:"This method must be redefined!"})},b},l=function(a,b){varc={},g={};g.wrongParametersError=function(a){varb="Method: "+a.method+", One or some parameters are undefined.";returnconsole.error(b),a.callback({status:"fail",error:{status:0,statusText:"Undefined Parameter",message:b}}),null},c.getID=function(){returng.id},c.start=function(){returng.id!==0?!1:(g.id=g.queue.getNewQueueID(),g.queue.init({jio_id:g.id}),g.updater&&g.updater.start(g.id),g.listener.start(),g.ready=!0,c.isReady())},c.stop=function(){returng.queue.close(),g.listener.stop(),g.updater&&g.updater.stop(),g.ready=!1,g.id=0,!0},c.kill=function(){returng.queue.close(),g.listener.stop(),g.updater&&g.updater.stop(),g.ready=!1,!0},c.isReady=function(){returng.ready},c.publish=function(a,b){if(!c.isReady())return;returng.pubsub.publish(a,b)},c.subscribe=function(a,b){returng.pubsub.subscribe(a,b)},c.unsubscribe=function(a,b){returng.pubsub.unsubscribe(a,b)},c.checkNameAvailability=function(a){varb=e({userName:g.storage.userName,storage:g.storage,applicant:g.applicant,method:"checkNameAvailability",callback:function(){}},a);returnc.isReady()&&b.userName&&b.storage&&b.applicant?g.queue.createJob(b):g.wrongParametersError(b)},c.saveDocument=function(a){varb=e({storage:g.storage,applicant:g.applicant,fileContent:"",method:"saveDocument",callback:function(){}},a);returnc.isReady()&&b.fileName&&b.storage&&b.applicant?g.queue.createJob(b):g.wrongParametersError(b)},c.loadDocument=function(a){varb=e({storage:g.storage,applicant:g.applicant,method:"loadDocument",callback:function(){}},a);returnc.isReady()&&b.fileName&&b.storage&&b.applicant?g.queue.createJob(b):g.wrongParametersError(b)},c.getDocumentList=function(a){varb=e({storage:g.storage,applicant:g.applicant,method:"getDocumentList",callback:function(){}},a);returnc.isReady()&&b.storage&&b.applicant?g.queue.createJob(b):g.wrongParametersError(b)},c.removeDocument=function(a){varb=e({storage:g.storage,applicant:g.applicant,method:"removeDocument",callback:function(){}},a);returnc.isReady()&&b.fileName&&b.storage&&b.applicant?g.queue.createJob(b):g.wrongParametersError(b)};vark=e({use_local_storage:!0},a.options);returntypeofa.storage=="string"&&(a.storage=JSON.parse(a.storage)),typeofa.applicant=="string"&&(a.applicant=JSON.parse(a.applicant)),g.storage=a.storage,g.applicant=a.applicant,g.id=0,g.pubsub=f({options:k}),g.queue=h({publisher:g.pubsub,options:k}),g.listener=i({queue:g.queue,options:k}),g.ready=!1,k.use_local_storage?g.updater=j({options:k}):g.updater=null,g.storage&&!d.storage_type_object[g.storage.type]&&console.error('Unknown storage type "'+g.storage.type+'"'),c.start(),c},m=function(a,b){varf={};returnf.createNew=function(a,b,c){vard=e({use_local_storage:!0},c);returnl({storage:a,applicant:b,options:d})},f.newBaseStorage=function(a,b){returnk(a,b)},f.addStorageType=function(a,b){returna&&b?(d.storage_type_object[a]=b,!0):!1},f.getGlobalObject=function(){returnd},f.getConstObject=function(){returne({},c)},f},m()};returnwindow.requirejs?(define("JIO",["LocalOrCookieStorage","jQuery"],a),undefined):a(LocalOrCookieStorage,jQuery)}();