varJIO=function(){vara=function(a,b){varc={jobMethodObject:{checkNameAvailability:{start_event:"start_checkingNameAvailability",stop_event:"stop_checkingNameAvailability",retvalue:"isAvailable"},saveDocument:{start_event:"start_saving",stop_event:"stop_saving",retvalue:"isSaved"},loadDocument:{start_event:"start_loading",stop_event:"stop_loading",retvalue:"fileContent"},getDocumentList:{start_event:"start_gettingList",stop_event:"stop_gettingList",retvalue:"list"},removeDocument:{start_event:"start_removing",stop_event:"stop_removing",retvalue:"isRemoved"}}},d={jobManagingMethod:{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}},localStorage:null,queueID:1,storageTypeObject:{}},e,f,g,h,i,j,k,l;returne=function(){vara={},c={},d={},e,f;returnc.eventAction=function(a){returnf=a&&d[a],f||(e=b.Callbacks(),f={publish:e.fire,subscribe:e.add,unsubscribe:e.remove},a&&(d[a]=f)),f},a.publish=function(a,b){c.eventAction(a).publish(b)},a.subscribe=function(a,b){returnc.eventAction(a).subscribe(b),b},a.unsubscribe=function(a,b){c.eventAction(a).unsubscribe(b)},a},f=function(a){varc=b.extend({},a);returnc.id=0,c.status="initial",c.date=Date.now(),c},g=function(a,e){varg={},h={};returng.init=function(b){varc,d=function(){};b.publisher&&(h.publisher=a),h.jioID=b.jioID,h.jobObjectName="jio/jobObject/"+b.jioID,h.jobObject={},g.copyJobQueueToLocalStorage();for(cinh.recoveredJobObject)h.recoveredJobObject[c].callback=d,g.addJob(h.recoveredJobObject[c])},g.close=function(){JSON.stringify(h.jobObject)==="{}"&&d.localStorage.deleteItem(h.jobObjectName)},g.getNewQueueID=function(){vara=d.localStorage.getAll(),b=0,c="key",e=["splitedkey"];for(cina)e=c.split("/"),e[0]==="jio"&&e[1]==="id"&&JSON.parse(e[2])>=d.queueID&&(d.queueID=JSON.parse(e[2])+1);returnb=d.queueID,d.queueID++,b},g.recoverOlderJobObject=function(){vara=d.localStorage.getAll(),b="key",c=["splitedkey"];for(bina)c=b.split("/"),c[0]==="jio"&&c[1]==="id"&&a[b]<Date.now()-1e4&&(d.localStorage.deleteItem(b),h.recoveredJobObject=d.localStorage.getItem("jio/jioObject/"+c[2]),d.localStorage.deleteItem("jio/jobObject/"+c[2]))},g.isThereJobsWhere=function(a){varb="id";if(!a)return!0;for(binh.jobObject)if(a(h.jobObject[b]))return!0;return!1},g.copyJobQueueToLocalStorage=function(){returnh.useLocalStorage?d.localStorage.setItem(h.jobObjectName,h.jobObject):!1},g.createJob=function(a){returng.addJob(newf(a))},g.addJob=function(a){varb={newone:!0,elimArray:[],waitArray:[],removeArray:[]},c=null,e="id";for(einh.jobObject)if(d.jobManagingMethod.canSelect(h.jobObject[e],a)){if(d.jobManagingMethod.canRemoveFailOrDone(h.jobObject[e],a)){b.removeArray.push(e);continue}if(d.jobManagingMethod.canEliminate(h.jobObject[e],a)){b.elimArray.push(e);continue}if(d.jobManagingMethod.canReplace(h.jobObject[e],a)){c=newj({queue:g,job:h.jobObject[e]}),c.replace(a),b.newone=!1;break}if(d.jobManagingMethod.cannotAccept(h.jobObject[e],a))return!1;if(d.jobManagingMethod.mustWait(h.jobObject[e],a)){b.waitArray.push(e);continue}}if(b.newone){for(einb.elimArray)c=newj({queue:g,job:h.jobObject[b.elimArray[e]]}),c.eliminate();if(b.waitArray.length>0){a.status="wait",a.waitingFor={jobIdArray:b.waitArray};for(einb.waitArray)h.jobObject[b.waitArray[e]]&&(h.jobObject[b.waitArray[e]].maxtries=1)}for(einb.removeArray)g.removeJob(h.jobObject[b.removeArray[e]]);a.id=h.jobid,a.tries=0,h.jobid++,h.jobObject[a.id]=a}returng.copyJobQueueToLocalStorage(),!0},g.removeJob=function(a){varc=b.extend({where:function(a){return!0}},a),d,e=!1,f="key";if(c.job)h.jobObject[c.job.id]&&c.where(h.jobObject[c.job.id])&&(deleteh.jobObject[c.job.id],e=!0);elsefor(finh.jobObject)c.where(h.jobObject[f])&&(deleteh.jobObject[f],e=!0);e||b.error("No jobs was found, when trying to remove some."),g.copyJobQueueToLocalStorage()},g.resetAll=function(){vara="id";for(ainh.jobObject)h.jobObject[a].status="initial";g.copyJobQueueToLocalStorage()},g.invokeAll=function(){vara="id",b;for(ainh.jobObject){b=!1;if(h.jobObject[a].status==="initial")g.invoke(h.jobObject[a]);elseif(h.jobObject[a].status==="wait"){b=!0;if(h.jobObject[a].waitingFor.jobIdArray)for(varcinh.jobObject[a].waitingFor.jobIdArray)if(h.jobObject[h.jobObject[a].waitingFor.jobIdArray[c]]){b=!1;break}h.jobObject[a].waitingFor.time&&h.jobObject[a].waitingFor.time>Date.now()&&(b=!1),b&&g.invoke(h.jobObject[a])}}this.copyJobQueueToLocalStorage()},g.invoke=function(a){varb;if(!c.jobMethodObject[a.method])return!1;g.isThereJobsWhere(function(b){returnb.method===a.method&&b.method==="initial"})?a.status="ongoing":(a.status="ongoing",h.publisher.publish(c.jobMethodObject[a.method].start_event)),b=newj({queue:this,job:a}),b.execute()},g.ended=function(a){switch(a.status){case"done":g.removeJob({job:a});break;case"fail":g.copyJobQueueToLocalStorage();break;case"wait":break;default:}if(!c.jobMethodObject[a.method])return!1;if(!g.isThereJobsWhere(function(b){returnb.method===a.method&&b.status==="ongoing"||b.status==="initial"})){h.publisher.publish(c.jobMethodObject[a.method].stop_event);return}},g.clean=function(){g.removeJob(undefined,{where:function(a){returna.status==="fail"}})},h.useLocalStorage=e.useLocalStorage,h.publisher=a,h.jobid=1,h.jioID=0,h.jobObjectName="",h.jobObject={},h.recoveredJobObject={},g},h=function(a){varb={},c={};returnc.interval=200,c.id=null,c.queue=a,b.setIntervalDelay=function(a){c.interval=a},b.start=function(){returnc.id?!1:(c.id=setInterval(function(){c.queue.recoverOlderJobObject(),c.queue.invokeAll()},c.interval),!0)},b.stop=function(){returnc.id?(clearInterval(c.id),c.id=null,!0):!1},b},i=function(){vara={},b={};returnb.interval=400,b.id=null,a.start=function(c){returnb.id?!1:(a.touch(c),b.id=setInterval(function(){a.touch(c)},b.interval),!0)},a.stop=function(){returnb.id?(clearInterval(b.id),b.id=null,!0):!1},a.touch=function(a){d.localStorage.setItem("jio/id/"+a,Date.now())},a},j=function(a){varc={},e={};returne.job=a.job,e.callback=a.job.callback,e.queue=a.queue,e.res={status:"done",message:""},e.fail_checkNameAvailability=function(){e.res.isAvailable=!1},e.done_checkNameAvailability=function(a){e.res.message=e.job.userName+" is "+(a?"":"not ")+"available.",e.res.isAvailable=a},e.fail_loadDocument=function(){e.res.document={}},e.done_loadDocument=function(a){e.res.message="Document loaded.",e.res.document=a,e.res.document.lastModified=(newDate(e.res.document.lastModified)).getTime(),e.res.document.creationDate=(newDate(e.res.document.creationDate)).getTime()},e.fail_saveDocument=function(){e.res.isSaved=!1},e.done_saveDocument=function(){e.res.message="Document saved.",e.res.isSaved=!0},e.fail_getDocumentList=function(){e.res.list=[]},e.done_getDocumentList=function(a){varb;e.res.message="Document list received.",e.res.list=a;for(bine.res.list)e.res.list[b].lastModified=(newDate(e.res.list[b].lastModified)).getTime(),e.res.list[b].creationDate=(newDate(e.res.list[b].creationDate)).getTime()},e.fail_removeDocument=function(){e.res.isRemoved=!1},e.done_removeDocument=function(){e.res.message="Document removed.",e.res.isRemoved=!0},e.retryLater=function(){e.job.status="wait",e.job.waitingFor={time:Date.now()+e.job.tries*e.job.tries*1e3}},c.cloneJob=function(){returnb.extend({},e.job)},c.getUserName=function(){returne.job.userName||""},c.getApplicantID=function(){returne.job.applicant.ID||""},c.getStorageUserName=function(){returne.job.storage.userName||""},c.getStoragePassword=function(){returne.job.storage.password||""},c.getStorageLocation=function(){returne.job.storage.location||""},c.getStorageArray=function(){returne.job.storage.storageArray||[]},c.getFileName=function(){returne.job.fileName||""},c.getFileContent=function(){returne.job.fileContent||""},c.cloneOptionObject=function(){returnb.extend({},e.job.options)},c.getMaxTries=function(){returne.job.maxtries},c.getTries=function(){returne.job.tries||0},c.setMaxTries=function(a){e.job.maxtries=a},c.addJob=function(a){returne.queue.createJob(a)},c.eliminate=function(){e.job.maxtries=1,e.job.tries=1,c.fail("Job Stopped!",0)},c.replace=function(a){e.job.tries=0,e.job.date=a.date,e.job.callback=a.callback,e.res.status="fail",e.res.message="Job Stopped!",e.res.errno=0,e["fail_"+e.job.method](),e.callback(e.res)},c.fail=function(a,b){e.res.status="fail",e.res.message=a,e.res.errno=b,!e.job.maxtries||e.job.tries<e.job.maxtries?e.retryLater():(e.job.status="fail",e["fail_"+e.job.method](),e.queue.ended(e.job),e.callback(e.res))},c.done=function(a){e.job.status="done",e["done_"+e.job.method](a),e.queue.ended(e.job),e.callback(e.res)},c.execute=function(){returne.job.tries=c.getTries()+1,d.storageTypeObject[e.job.storage.type]?d.storageTypeObject[e.job.storage.type]({job:e.job,queue:e.queue})[e.job.method]():null},c.checkNameAvailability=function(){c.fail("This method must be redefined!",0)},c.loadDocument=function(){c.fail("This method must be redefined!",0)},c.saveDocument=function(){c.fail("This method must be redefined!",0)},c.getDocumentList=function(){c.fail("This method must be redefined!",0)},c.removeDocument=function(){c.fail("This method must be redefined!",0)},c},k=function(a,c,f){varj={},k={};j.getID=function(){returnk.id},j.start=function(){returnk.id!==0?!1:(k.id=k.queue.getNewQueueID(),k.queue.init({jioID:k.id}),k.updater&&k.updater.start(k.id),k.listener.start(),k.ready=!0,j.isReady())},j.stop=function(){returnk.queue.close(),k.listener.stop(),k.updater&&k.updater.stop(),k.ready=!1,k.id=0,!0},j.kill=function(){returnk.queue.close(),k.listener.stop(),k.updater&&k.updater.stop(),k.ready=!1,!0},j.isReady=function(){returnk.ready},j.publish=function(a,b){if(!j.isReady())return;returnk.pubsub.publish(a,b)},j.subscribe=function(a,b){returnk.pubsub.subscribe(a,b)},j.unsubscribe=function(a,b){returnk.pubsub.unsubscribe(a,b)},j.checkNameAvailability=function(a){varc=b.extend({userName:k.storage.userName,storage:k.storage,applicant:k.applicant,method:"checkNameAvailability",callback:function(){}},a);returnj.isReady()&&c.userName&&c.storage&&c.applicant?k.queue.createJob(c):null},j.saveDocument=function(a){varc=b.extend({storage:k.storage,applicant:k.applicant,method:"saveDocument",callback:function(){}},a);returnj.isReady()&&c.fileName&&c.fileContent&&c.storage&&c.applicant?k.queue.createJob(c):null},j.loadDocument=function(a){varc=b.extend({storage:k.storage,applicant:k.applicant,method:"loadDocument",callback:function(){}},a);returnj.isReady()&&c.fileName&&c.storage&&c.applicant?k.queue.createJob(c):null},j.getDocumentList=function(a){varc=b.extend({storage:k.storage,applicant:k.applicant,method:"getDocumentList",callback:function(){}},a);returnj.isReady()&&c.storage&&c.applicant?k.queue.createJob(c):null},j.removeDocument=function(a){varc=b.extend({storage:k.storage,applicant:k.applicant,method:"removeDocument",callback:function(){}},a);returnj.isReady()&&c.fileName&&c.storage&&c.applicant?k.queue.createJob(c):null};varl=b.extend({useLocalStorage:!0},f);returntypeofa=="string"&&(a=JSON.parse(f.storage)),typeofc=="string"&&(c=JSON.parse(f.applicant)),k.storage=a,k.applicant=c,k.id=0,k.pubsub=newe(l),k.queue=newg(k.pubsub,l),k.listener=newh(k.queue,l),k.ready=!1,l.useLocalStorage?k.updater=newi(l):k.updater=null,k.storage&&!d.storageTypeObject[k.storage.type]&&b.error('Unknown storage type "'+k.storage.type+'"'),j.start(),j},l=function(){vare={};returne.createNew=function(c,e,f){varg=b.extend({useLocalStorage:!0},f);returnd.localStorage===null&&(d.localStorage=a),newk(c,e,g)},e.newBaseStorage=function(a){returnnewj(a)},e.addStorageType=function(a,b){returna&&b?(d.storageTypeObject[a]=b,!0):!1},e.getGlobalObject=function(){returnd},e.getConstObject=function(){returnb.extend({},c)},e},newl};returnwindow.requirejs?(define("JIO",["LocalOrCookieStorage","jQuery"],a),undefined):a(LocalOrCookieStorage,jQuery)}();
\ No newline at end of file
varJIO=function(){vara=function(a,b){varc={jobMethodObject:{checkNameAvailability:{start_event:"start_checkingNameAvailability",stop_event:"stop_checkingNameAvailability",retvalue:"isAvailable"},saveDocument:{start_event:"start_saving",stop_event:"stop_saving",retvalue:"isSaved"},loadDocument:{start_event:"start_loading",stop_event:"stop_loading",retvalue:"fileContent"},getDocumentList:{start_event:"start_gettingList",stop_event:"stop_gettingList",retvalue:"list"},removeDocument:{start_event:"start_removing",stop_event:"stop_removing",retvalue:"isRemoved"}}},d={jobManagingMethod:{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}},localStorage:null,queueID:1,storageTypeObject:{}},e,f,g,h,i,j,k,l;returne=function(){vara={},c={},d={},e,f;returnc.eventAction=function(a){returnf=a&&d[a],f||(e=b.Callbacks(),f={publish:e.fire,subscribe:e.add,unsubscribe:e.remove},a&&(d[a]=f)),f},a.publish=function(a,b){c.eventAction(a).publish(b)},a.subscribe=function(a,b){returnc.eventAction(a).subscribe(b),b},a.unsubscribe=function(a,b){c.eventAction(a).unsubscribe(b)},a},f=function(a){varc=b.extend({},a);returnc.id=0,c.status="initial",c.date=Date.now(),c},g=function(a,e){varg={},h={};returng.init=function(b){varc,d=function(){};b.publisher&&(h.publisher=a),h.jioID=b.jioID,h.jobObjectName="jio/jobObject/"+b.jioID,h.jobObject={},g.copyJobQueueToLocalStorage();for(cinh.recoveredJobObject)h.recoveredJobObject[c].callback=d,g.addJob(h.recoveredJobObject[c])},g.close=function(){JSON.stringify(h.jobObject)==="{}"&&d.localStorage.deleteItem(h.jobObjectName)},g.getNewQueueID=function(){vara=d.localStorage.getAll(),b=0,c="key",e=["splitedkey"];for(cina)e=c.split("/"),e[0]==="jio"&&e[1]==="id"&&JSON.parse(e[2])>=d.queueID&&(d.queueID=JSON.parse(e[2])+1);returnb=d.queueID,d.queueID++,b},g.recoverOlderJobObject=function(){vara=d.localStorage.getAll(),b="key",c=["splitedkey"];for(bina)c=b.split("/"),c[0]==="jio"&&c[1]==="id"&&a[b]<Date.now()-1e4&&(d.localStorage.deleteItem(b),h.recoveredJobObject=d.localStorage.getItem("jio/jioObject/"+c[2]),d.localStorage.deleteItem("jio/jobObject/"+c[2]))},g.isThereJobsWhere=function(a){varb="id";if(!a)return!0;for(binh.jobObject)if(a(h.jobObject[b]))return!0;return!1},g.copyJobQueueToLocalStorage=function(){returnh.useLocalStorage?d.localStorage.setItem(h.jobObjectName,h.jobObject):!1},g.createJob=function(a){returng.addJob(newf(a))},g.addJob=function(a){varb={newone:!0,elimArray:[],waitArray:[],removeArray:[]},c=null,e="id";for(einh.jobObject){if(d.jobManagingMethod.canRemoveFailOrDone(h.jobObject[e],a)){b.removeArray.push(e);continue}if(d.jobManagingMethod.canSelect(h.jobObject[e],a)){if(d.jobManagingMethod.canEliminate(h.jobObject[e],a)){b.elimArray.push(e);continue}if(d.jobManagingMethod.canReplace(h.jobObject[e],a)){c=newj({queue:g,job:h.jobObject[e]}),c.replace(a),b.newone=!1;break}if(d.jobManagingMethod.cannotAccept(h.jobObject[e],a))return!1;if(d.jobManagingMethod.mustWait(h.jobObject[e],a)){b.waitArray.push(e);continue}}}if(b.newone){for(einb.elimArray)c=newj({queue:g,job:h.jobObject[b.elimArray[e]]}),c.eliminate();if(b.waitArray.length>0){a.status="wait",a.waitingFor={jobIdArray:b.waitArray};for(einb.waitArray)h.jobObject[b.waitArray[e]]&&(h.jobObject[b.waitArray[e]].maxtries=1)}for(einb.removeArray)g.removeJob(h.jobObject[b.removeArray[e]]);a.id=h.jobid,a.tries=0,h.jobid++,h.jobObject[a.id]=a}returng.copyJobQueueToLocalStorage(),!0},g.removeJob=function(a){varc=b.extend({where:function(a){return!0}},a),d,e=!1,f="key";if(c.job)h.jobObject[c.job.id]&&c.where(h.jobObject[c.job.id])&&(deleteh.jobObject[c.job.id],e=!0);elsefor(finh.jobObject)c.where(h.jobObject[f])&&(deleteh.jobObject[f],e=!0);e||b.error("No jobs was found, when trying to remove some."),g.copyJobQueueToLocalStorage()},g.resetAll=function(){vara="id";for(ainh.jobObject)h.jobObject[a].status="initial";g.copyJobQueueToLocalStorage()},g.invokeAll=function(){vara="id",b;for(ainh.jobObject){b=!1;if(h.jobObject[a].status==="initial")g.invoke(h.jobObject[a]);elseif(h.jobObject[a].status==="wait"){b=!0;if(h.jobObject[a].waitingFor.jobIdArray)for(varcinh.jobObject[a].waitingFor.jobIdArray)if(h.jobObject[h.jobObject[a].waitingFor.jobIdArray[c]]){b=!1;break}h.jobObject[a].waitingFor.time&&h.jobObject[a].waitingFor.time>Date.now()&&(b=!1),b&&g.invoke(h.jobObject[a])}}this.copyJobQueueToLocalStorage()},g.invoke=function(a){varb;if(!c.jobMethodObject[a.method])return!1;g.isThereJobsWhere(function(b){returnb.method===a.method&&b.method==="initial"})?a.status="ongoing":(a.status="ongoing",h.publisher.publish(c.jobMethodObject[a.method].start_event)),b=newj({queue:this,job:a}),b.execute()},g.ended=function(a){vard=b.extend({},a);g.removeJob({job:d});if(!c.jobMethodObject[d.method])return!1;if(!g.isThereJobsWhere(function(a){returna.method===d.method&&a.status==="ongoing"||a.status==="initial"})){h.publisher.publish(c.jobMethodObject[d.method].stop_event);return}},g.clean=function(){g.removeJob(undefined,{where:function(a){returna.status==="fail"}})},h.useLocalStorage=e.useLocalStorage,h.publisher=a,h.jobid=1,h.jioID=0,h.jobObjectName="",h.jobObject={},h.recoveredJobObject={},g},h=function(a){varb={},c={};returnc.interval=200,c.id=null,c.queue=a,b.setIntervalDelay=function(a){c.interval=a},b.start=function(){returnc.id?!1:(c.id=setInterval(function(){c.queue.recoverOlderJobObject(),c.queue.invokeAll()},c.interval),!0)},b.stop=function(){returnc.id?(clearInterval(c.id),c.id=null,!0):!1},b},i=function(){vara={},b={};returnb.interval=400,b.id=null,a.start=function(c){returnb.id?!1:(a.touch(c),b.id=setInterval(function(){a.touch(c)},b.interval),!0)},a.stop=function(){returnb.id?(clearInterval(b.id),b.id=null,!0):!1},a.touch=function(a){d.localStorage.setItem("jio/id/"+a,Date.now())},a},j=function(a){varc={},e={};returne.job=a.job,e.callback=a.job.callback,e.queue=a.queue,e.res={status:"done",message:""},e.fail_checkNameAvailability=function(){e.res.isAvailable=!1},e.done_checkNameAvailability=function(a){e.res.message=e.job.userName+" is "+(a?"":"not ")+"available.",e.res.isAvailable=a},e.fail_loadDocument=function(){e.res.document={}},e.done_loadDocument=function(a){e.res.message="Document loaded.",e.res.document=a,e.res.document.lastModified=(newDate(e.res.document.lastModified)).getTime(),e.res.document.creationDate=(newDate(e.res.document.creationDate)).getTime()},e.fail_saveDocument=function(){e.res.isSaved=!1},e.done_saveDocument=function(){e.res.message="Document saved.",e.res.isSaved=!0},e.fail_getDocumentList=function(){e.res.list=[]},e.done_getDocumentList=function(a){varb;e.res.message="Document list received.",e.res.list=a;for(bine.res.list)e.res.list[b].lastModified=(newDate(e.res.list[b].lastModified)).getTime(),e.res.list[b].creationDate=(newDate(e.res.list[b].creationDate)).getTime()},e.fail_removeDocument=function(){e.res.isRemoved=!1},e.done_removeDocument=function(){e.res.message="Document removed.",e.res.isRemoved=!0},e.retryLater=function(){e.job.status="wait",e.job.waitingFor={time:Date.now()+e.job.tries*e.job.tries*1e3}},c.cloneJob=function(){returnb.extend({},e.job)},c.getUserName=function(){returne.job.userName||""},c.getApplicantID=function(){returne.job.applicant.ID||""},c.getStorageUserName=function(){returne.job.storage.userName||""},c.getStoragePassword=function(){returne.job.storage.password||""},c.getStorageLocation=function(){returne.job.storage.location||""},c.getStorageArray=function(){returne.job.storage.storageArray||[]},c.getFileName=function(){returne.job.fileName||""},c.getFileContent=function(){returne.job.fileContent||""},c.cloneOptionObject=function(){returnb.extend({},e.job.options)},c.getMaxTries=function(){returne.job.maxtries},c.getTries=function(){returne.job.tries||0},c.setMaxTries=function(a){e.job.maxtries=a},c.addJob=function(a){returne.queue.createJob(a)},c.eliminate=function(){e.job.maxtries=1,e.job.tries=1,c.fail("Job Stopped!",0)},c.replace=function(a){e.job.tries=0,e.job.date=a.date,e.job.callback=a.callback,e.res.status="fail",e.res.message="Job Stopped!",e.res.errno=0,e["fail_"+e.job.method](),e.callback(e.res)},c.fail=function(a,b){e.res.status="fail",e.res.message=a,e.res.errno=b,!e.job.maxtries||e.job.tries<e.job.maxtries?e.retryLater():(e.job.status="fail",e["fail_"+e.job.method](),e.queue.ended(e.job),e.callback(e.res))},c.done=function(a){e.job.status="done",e["done_"+e.job.method](a),e.queue.ended(e.job),e.callback(e.res)},c.execute=function(){returne.job.tries=c.getTries()+1,d.storageTypeObject[e.job.storage.type]?d.storageTypeObject[e.job.storage.type]({job:e.job,queue:e.queue})[e.job.method]():null},c.checkNameAvailability=function(){c.fail("This method must be redefined!",0)},c.loadDocument=function(){c.fail("This method must be redefined!",0)},c.saveDocument=function(){c.fail("This method must be redefined!",0)},c.getDocumentList=function(){c.fail("This method must be redefined!",0)},c.removeDocument=function(){c.fail("This method must be redefined!",0)},c},k=function(a,c,f){varj={},k={};j.getID=function(){returnk.id},j.start=function(){returnk.id!==0?!1:(k.id=k.queue.getNewQueueID(),k.queue.init({jioID:k.id}),k.updater&&k.updater.start(k.id),k.listener.start(),k.ready=!0,j.isReady())},j.stop=function(){returnk.queue.close(),k.listener.stop(),k.updater&&k.updater.stop(),k.ready=!1,k.id=0,!0},j.kill=function(){returnk.queue.close(),k.listener.stop(),k.updater&&k.updater.stop(),k.ready=!1,!0},j.isReady=function(){returnk.ready},j.publish=function(a,b){if(!j.isReady())return;returnk.pubsub.publish(a,b)},j.subscribe=function(a,b){returnk.pubsub.subscribe(a,b)},j.unsubscribe=function(a,b){returnk.pubsub.unsubscribe(a,b)},j.checkNameAvailability=function(a){varc=b.extend({userName:k.storage.userName,storage:k.storage,applicant:k.applicant,method:"checkNameAvailability",callback:function(){}},a);returnj.isReady()&&c.userName&&c.storage&&c.applicant?k.queue.createJob(c):null},j.saveDocument=function(a){varc=b.extend({storage:k.storage,applicant:k.applicant,method:"saveDocument",callback:function(){}},a);returnj.isReady()&&c.fileName&&c.fileContent&&c.storage&&c.applicant?k.queue.createJob(c):null},j.loadDocument=function(a){varc=b.extend({storage:k.storage,applicant:k.applicant,method:"loadDocument",callback:function(){}},a);returnj.isReady()&&c.fileName&&c.storage&&c.applicant?k.queue.createJob(c):null},j.getDocumentList=function(a){varc=b.extend({storage:k.storage,applicant:k.applicant,method:"getDocumentList",callback:function(){}},a);returnj.isReady()&&c.storage&&c.applicant?k.queue.createJob(c):null},j.removeDocument=function(a){varc=b.extend({storage:k.storage,applicant:k.applicant,method:"removeDocument",callback:function(){}},a);returnj.isReady()&&c.fileName&&c.storage&&c.applicant?k.queue.createJob(c):null};varl=b.extend({useLocalStorage:!0},f);returntypeofa=="string"&&(a=JSON.parse(f.storage)),typeofc=="string"&&(c=JSON.parse(f.applicant)),k.storage=a,k.applicant=c,k.id=0,k.pubsub=newe(l),k.queue=newg(k.pubsub,l),k.listener=newh(k.queue,l),k.ready=!1,l.useLocalStorage?k.updater=newi(l):k.updater=null,k.storage&&!d.storageTypeObject[k.storage.type]&&b.error('Unknown storage type "'+k.storage.type+'"'),j.start(),j},l=function(){vare={};returne.createNew=function(c,e,f){varg=b.extend({useLocalStorage:!0},f);returnd.localStorage===null&&(d.localStorage=a),newk(c,e,g)},e.newBaseStorage=function(a){returnnewj(a)},e.addStorageType=function(a,b){returna&&b?(d.storageTypeObject[a]=b,!0):!1},e.getGlobalObject=function(){returnd},e.getConstObject=function(){returnb.extend({},c)},e},newl};returnwindow.requirejs?(define("JIO",["LocalOrCookieStorage","jQuery"],a),undefined):a(LocalOrCookieStorage,jQuery)}();