/** * 监控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); } };