var debug=function(e){console.log(e)},http={ajax:function(e,n,t){var s=new Headers;return s.append("Content-Type","application/json"),s.append("X-Requested-With","XMLHttpRequest"),fetch(e,{method:t,headers:s,credentials:"same-origin"})},get:function(e){return this.ajax(e,{},"get")},post:function(e,n){return this.ajax(e,n,"post")},json:function(e,n,t){return this.ajax(e,n,t).then(function(e){return e.json()})}},JobManager={jobs:{},getJob:function(e){return this.jobs[e]},isRunning:function(e){var n=this.jobs[e];return!(!n||!n.running)&&(debug(e+": isRunning"),!0)},start:function(e){this.isRunning(e.id)?debug(jobId+": 任务正在运行中"):(this.jobs[e.id]=e,this.execute(e))},pause:function(e){delete this.jobs[e.id]},fire:function(e){postMessage(e)},execute:function(e){if((e=this.getJob(e.id))&&!e.runing){e.runing=!0;try{var n=this;http.json(e.relUrl+"?c=system&a=job&do=execute&id="+e.id,"","get").then(function(t){0==t.message.errno&&(n.fire(t.message.message),t.message.message.finished||setTimeout(function(){n.execute(e)},1e3))}),e.runing=!1}catch(n){e.runing=!1}return!0}}};onmessage=function(e){var n=e.data;n.start?JobManager.start(n):JobManager.pause(n)};