var FlightMonitorBox=function(){var n=this;this.history=[];this.storage=Storage;this.init();FlightMonitorBox=function(){return n}};FlightMonitorBox.prototype.init=function(){var r=this.storage.get("monitorBox"),t=[],i,n;for(this.flights={},this.count=0,r!==null&&(t=JSON.parse(r)),n=t.length-1;n>=0;n--)this.storage.get(t[n])!==null&&(i=JSON.parse(this.storage.get(t[n])),this.add(FlightFactory.getFromId(t[n]).setData(i.flight),i.monitor,i.lastShowedPrice,i.error));return this};FlightMonitorBox.prototype.add=function(n,t,i,r){var u=n.getId();if(this.flights[u]!==undefined)throw{name:"MonitorDulipcateId",message:"重复航班"};if(this.count>=config.monitor.limit)throw{name:"MonitorLimit",message:"最多允许同时关注"+config.monitor.limit+"条航线"};return this.flights[u]={flight:n,monitor:t,lastShowedPrice:i,error:r},this.count++,this.history.push(u),this};FlightMonitorBox.prototype.remove=function(n){return delete this.flights[n],this.storage.remove(n),this.count--,this};FlightMonitorBox.prototype.getAll=function(){return this.flights};FlightMonitorBox.prototype.getCount=function(){return this.count};FlightMonitorBox.prototype.get=function(n){return this.flights[n]};FlightMonitorBox.prototype.persistenceOne=function(n){this.storage.set(n,JSON.stringify({flight:this.flights[n].flight.data,monitor:this.flights[n].monitor,lastShowedPrice:this.flights[n].lastShowedPrice,error:this.flights[n].error}))};FlightMonitorBox.prototype.persistence=function(){var t=[],n;for(n in this.flights)t.push(n),this.persistenceOne(n);this.storage.set("monitorBox",JSON.stringify(t));this.storage.set("monitorHistory",JSON.stringify(this.history.slice(-20)))}