//监控任务 (function () { var flights = (new FlightMonitorBox()).getAll(), flightId, initError = [], delay; if ((new FlightMonitorBox()).getCount() > 0 ) { Util.updateIcon('icons/icon_16.png'); (new TimerManager()).getTimer('flip').start(); } else { Util.updateIcon('icons/gray.png'); (new TimerManager()).getTimer('flip').halt(); } for (flightId in flights) { flights[flightId].flight.getData( true, true, function(data) { chrome.browserAction.setBadgeText({text: ''}); delete flights[flightId].error; }, function(error) { chrome.browserAction.setBadgeText({text: '!'}); flights[flightId].error = error; if (error.name === 'QuerySoldOutError') { initError.push({ flightId: flightId, status: '售罄', }); } if (error.name === 'QueryDateError') { initError.push({ flightId: flightId, status: '过期', }); } }, function() { (new FlightMonitorBox()).persistenceOne(flightId); if (initError.length) { Storage.set('showStage', { name: 'ticketAdvice', data: { errors: initError, advice: '请您重新设置' } }); Util.popup(); } delay = Math.floor(Math.random() * 120) * 1000; flights[flightId].monitor.lastTime = Util.date.now() - delay; (new TimerManager()).addTimer(getFlightTimer(flightId, config.monitor.interval - delay)); (new TimerManager()).getTimer(flightId).start(); } ); } }()); //超值线路 (function() { if (Storage.get('receiveCheap' === 'true')) { (new TimerManager()).getTimer('bargain').start(); } }());