Light12306/RwTicketAssistantV2/app/air/js/flight/Monitor.js

41 lines
806 B
JavaScript
Raw Normal View History

/**
* 监控monitor用于判断
* @class Monitor
* @constructor
* @param {String} type: absolute/relative
* @param {Number} extra: 低于的价格type=absolute时生效
*/
var Monitor = function(type, price) {
this.type = type;
this.price = price;
this.time = Util.date.now();
};
Monitor.prototype.getSetting = function() {
return {
type: this.type,
price: this.price,
time: this.time
};
};
Monitor.prototype.judge = function(flight) {
};
var MonitorFactory = {
getFromKeeper: function() {
var info = InputKeeper.getInfo();
if (info.type == 'absolute') {
return new Monitor('absolute', parseInt(info.absolutePrice, 10));
} else {
return new Monitor('relative');
}
},
getFromSetting: function(setting) {
return new Monitor(setting.type, setting.price);
}
};