显示查询速度等级
This commit is contained in:
parent
ba9d32164c
commit
676770dd4d
@ -11,10 +11,10 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mask.final {
|
||||
opacity: 0.6;
|
||||
transition: all 0.2s linear;
|
||||
}
|
||||
#mask.final {
|
||||
opacity: 0.6;
|
||||
transition: all 0.2s linear;
|
||||
}
|
||||
|
||||
.float-dialog {
|
||||
display: none;
|
||||
@ -27,50 +27,94 @@
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
|
||||
.float-dialog > header {
|
||||
line-height: 32px;
|
||||
font-size: 16px;
|
||||
border-bottom: 1px solid #c6c6c6;
|
||||
color: #333333;
|
||||
text-indent: 30px;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
}
|
||||
.float-dialog > header {
|
||||
line-height: 32px;
|
||||
font-size: 16px;
|
||||
border-bottom: 1px solid #c6c6c6;
|
||||
color: #333333;
|
||||
text-indent: 30px;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.float-dialog > header .fa {
|
||||
color: #999;
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 50%;
|
||||
margin-top: -8px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
}
|
||||
.float-dialog > header .fa {
|
||||
color: #999;
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 50%;
|
||||
margin-top: -8px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.float-dialog > header .fa:hover {
|
||||
color: #444;
|
||||
}
|
||||
.float-dialog > header .fa:hover {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.float-dialog > section {
|
||||
padding: 20px 30px 15px 30px;
|
||||
}
|
||||
.float-dialog > section {
|
||||
padding: 20px 30px 15px 30px;
|
||||
}
|
||||
|
||||
.float-dialog > footer {
|
||||
padding: 0 30px 20px 30px;
|
||||
text-align: center;
|
||||
}
|
||||
.float-dialog > footer {
|
||||
padding: 0 30px 20px 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.float-dialog > footer button,
|
||||
.float-dialog > footer a {
|
||||
margin-right: 10px;
|
||||
width: 150px;
|
||||
}
|
||||
.float-dialog > footer button,
|
||||
.float-dialog > footer a {
|
||||
margin-right: 10px;
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.float-dialog > footer button:last-child,
|
||||
.float-dialog > footer a:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
.float-dialog > footer button:last-child,
|
||||
.float-dialog > footer a:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.cancel-button {
|
||||
}
|
||||
|
||||
/*查询速度表*/
|
||||
#speed-meter {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
padding: 5px;
|
||||
border: 1px solid #C2DEC2;
|
||||
background: #EEF9EE;
|
||||
font-size: 12px;
|
||||
color: #50A050;
|
||||
transition: all linear 0.5s;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
#speed-meter.visible {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#speed-meter.visible:hover {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
#speed-meter span {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#speed-meter.speed-good {
|
||||
border-color: #C2DEC2;
|
||||
background-color: #EEF9EE;
|
||||
color: #50A050;
|
||||
}
|
||||
|
||||
#speed-meter.speed-normal {
|
||||
border-color: #C2C8DE;
|
||||
background-color: #EEF2F9;
|
||||
color: #506CA0;
|
||||
}
|
||||
|
||||
#speed-meter.speed-bad {
|
||||
border-color: #DEC2C2;
|
||||
background-color: #F9EEEE;
|
||||
color: #A05050;
|
||||
}
|
@ -1315,6 +1315,10 @@
|
||||
(关注微信后按提醒输入的哦)
|
||||
</p>
|
||||
</section>
|
||||
<section id="speed-meter">
|
||||
<i class="fa fa-clock-o"></i>
|
||||
当前查询网速为 <span>1</span>级 (<span></span>毫秒)
|
||||
</section>
|
||||
<script src="js/modules/jquery/jquery.js"></script>
|
||||
<script src="js/modules/underscore/underscore.js"></script>
|
||||
<script src="js/modules/colorbox/jquery.colorbox.js"></script>
|
||||
|
@ -21,7 +21,9 @@
|
||||
while (lastQueryTimes.length > 20)
|
||||
lastQueryTimes.shift();
|
||||
|
||||
averageQueryTime = lastQueryTimes.length > 0 ? _.reduce(lastQueryTimes, function (x, y) { return x + y; }) / lastQueryTimes : 0;
|
||||
averageQueryTime = lastQueryTimes.length > 0 ? _.reduce(lastQueryTimes, function (x, y) {
|
||||
return x + y;
|
||||
}) / lastQueryTimes.length : 0;
|
||||
};
|
||||
Object.defineProperty(exports, "averageQueryTime", {
|
||||
get: function () {
|
||||
@ -36,7 +38,9 @@
|
||||
|
||||
var detectSuggest = function (result) {
|
||||
result.suggestTransit = result.available.length > 0 && result.available.length <= 3;
|
||||
var notFeCount = _.count(result.available, function (t) { return t.from.endpoint && t.to.endpoint; });
|
||||
var notFeCount = _.count(result.available, function (t) {
|
||||
return t.from.endpoint && t.to.endpoint;
|
||||
});
|
||||
result.suggestMoreStat = notFeCount < 4 && notFeCount < result.available.length / 3;
|
||||
|
||||
result.hasSuggest = result.suggestMoreStat | result.suggestTransit;
|
||||
@ -52,16 +56,16 @@
|
||||
var sc = m[1];
|
||||
var sp = m[2][0] === '*' ? null : parseInt(m[2], 10);
|
||||
var st = parseInt(m[3], 10);
|
||||
var seat = { code: sc, name: param.toSeatTypeName(sc), price: sp, selected: false };
|
||||
var seat = {code: sc, name: param.toSeatTypeName(sc), price: sp, selected: false};
|
||||
if (st < 3000) {
|
||||
seat.count = st;
|
||||
|
||||
//TODO 二等软座提交是否和二等座一样都用的MO?
|
||||
//一等软座 7, 二等软座 8
|
||||
if (sc === "7") {
|
||||
data.push({ code: "M", name: param.toSeatTypeName("M"), price: sp, count: st, selected: false });
|
||||
data.push({code: "M", name: param.toSeatTypeName("M"), price: sp, count: st, selected: false});
|
||||
} else if (sc === "8") {
|
||||
data.push({ code: "O", name: param.toSeatTypeName("O"), price: sp, count: st, selected: false });
|
||||
data.push({code: "O", name: param.toSeatTypeName("O"), price: sp, count: st, selected: false});
|
||||
} else {
|
||||
data.push(seat);
|
||||
}
|
||||
@ -72,7 +76,8 @@
|
||||
data.push(seat);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -80,10 +85,20 @@
|
||||
var result = data;
|
||||
if (!Array.isArray(result.data) || !result.data.length || !result.data[0].queryLeftNewDTO) {
|
||||
exports.events.fireEvent("requestFailed");
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
var date = query.date;
|
||||
var trainData = { query: query, raw: result, rawTrainMap: {}, trainMap: {}, auto: null, nextTime: null, noProcess: noProcess, noAction: noAction };
|
||||
var trainData = {
|
||||
query: query,
|
||||
raw: result,
|
||||
rawTrainMap: {},
|
||||
trainMap: {},
|
||||
auto: null,
|
||||
nextTime: null,
|
||||
noProcess: noProcess,
|
||||
noAction: noAction
|
||||
};
|
||||
var messages = (result.messages || []).join("");
|
||||
|
||||
trainData.notInSellTime = messages.indexOf("在预售日期范围") !== -1;
|
||||
@ -133,7 +148,9 @@
|
||||
};
|
||||
var kp = getTicketInfo(t.queryLeftNewDTO.yp_info);
|
||||
train.tickets = kp;
|
||||
train.ticketMap = _.mapObject(kp, function (e) { return e.code; });
|
||||
train.ticketMap = _.mapObject(kp, function (e) {
|
||||
return e.code;
|
||||
});
|
||||
|
||||
//起售时间
|
||||
var selltimem = /(0*(\d+)月0*(\d+)日)?(\d+)\s*点\s*((\d+)分)?\s*起售/i.exec(t.buttonTextInfo.replace(/<.*?>/g, ''));
|
||||
@ -249,7 +266,7 @@
|
||||
|
||||
var queryFail = function () {
|
||||
if (queryCount++ < 5) {
|
||||
def.notify({ action: "requery" });
|
||||
def.notify({action: "requery"});
|
||||
//def.notify("12306出问题了,正在第 " + queryCount + " 次重连...");
|
||||
setTimeout(sendQueryRequest, 2000);
|
||||
} else {
|
||||
@ -266,7 +283,9 @@
|
||||
};
|
||||
var cookie = (function (obj) {
|
||||
var arr = [];
|
||||
_.forEach(obj, function (v, k) { arr.push(k + '=' + v); });
|
||||
_.forEach(obj, function (v, k) {
|
||||
arr.push(k + '=' + v);
|
||||
});
|
||||
return arr.join("; ");
|
||||
})(extensionVersion >= 720 ? {
|
||||
"_jc_save_fromStation": escape(fromName + "," + from),
|
||||
@ -338,8 +357,8 @@
|
||||
}
|
||||
else postFetchTicketUrl();
|
||||
}).fail(function () {
|
||||
def.reject("网络错误");
|
||||
});
|
||||
def.reject("网络错误");
|
||||
});
|
||||
};
|
||||
var postFetchTicketUrl = function () {
|
||||
//加载查询页之后,必须要加载一次联系人,否则妥妥地出票失败。这傻逼逻辑啊。。
|
||||
@ -389,7 +408,7 @@
|
||||
var def = new $.Deferred();
|
||||
ajax.sendGet("czxx/queryByTrainNo", "leftTicket/init", data, "json", function (json) {
|
||||
if (!json || !json.data || !json.data.data) {
|
||||
def.reject((parser.getError(json) || { message: "查询失败" }).message);
|
||||
def.reject((parser.getError(json) || {message: "查询失败"}).message);
|
||||
} else {
|
||||
def.resolve(json.data.data);
|
||||
}
|
||||
|
@ -180,7 +180,7 @@
|
||||
if (!time)
|
||||
return null;
|
||||
time = utility.format24hTo12h(time);
|
||||
return time ? { name: s.name, time: time.join("<br />") } : null;
|
||||
return time ? {name: s.name, time: time.join("<br />")} : null;
|
||||
});
|
||||
if (!times || !times.length) {
|
||||
cnt.hide();
|
||||
@ -190,7 +190,7 @@
|
||||
//去哪儿特价机票
|
||||
var url = 'http://flight.qunar.com/site/lplist.htm?dcity=' + encodeURIComponent(this.value.replace(/[东南西北]+$/i, "")) + '&acity=&ddate=' + $("#dep_date").val() + '&from=tejia_fi&drange=15&ex_track=auto_54881424';
|
||||
|
||||
cnt.find("ul").html(selltipTpl({ times: times, url: url }));
|
||||
cnt.find("ul").html(selltipTpl({times: times, url: url}));
|
||||
cnt.show();
|
||||
};
|
||||
$("#from_city").change(showSellTime);
|
||||
@ -229,7 +229,9 @@
|
||||
ui_result.resetStatus();
|
||||
//检查学生票是否对应
|
||||
if (cp.studentTicket && cp.passengers && cp.passengers.length) {
|
||||
if (_.some(cp.passengers, function (p) { return p.passenger_type !== '3'; })) {
|
||||
if (_.some(cp.passengers, function (p) {
|
||||
return p.passenger_type !== '3';
|
||||
})) {
|
||||
mp.confirm("确认", "您选择的是学生票,但是添加的联系人并不全是学生,将无法提交订单,确定继续查票吗?", ui_result.load);
|
||||
} else {
|
||||
//ui_result.load();
|
||||
@ -275,25 +277,25 @@
|
||||
$.showModalDialog("无法访问12306,可能是网络错误或证书错误,请直接访问12306试试!如果正常的话请回来刷新本页!", {
|
||||
image: "/images/cat.png",
|
||||
buttons: [
|
||||
{
|
||||
text: "打开12306官网",
|
||||
type: "primary",
|
||||
callback: function () {
|
||||
window.open("https://kyfw.12306.cn/otn/leftTicket/init");
|
||||
return false;
|
||||
{
|
||||
text: "打开12306官网",
|
||||
type: "primary",
|
||||
callback: function () {
|
||||
window.open("https://kyfw.12306.cn/otn/leftTicket/init");
|
||||
return false;
|
||||
}
|
||||
}, {
|
||||
text: "刷新重试",
|
||||
callback: function () {
|
||||
self.location.reload();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
text: "刷新重试",
|
||||
callback: function () {
|
||||
self.location.reload();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
],
|
||||
closeOnAction: false
|
||||
});
|
||||
});
|
||||
document.addEventListener("ipBlockError", function() {
|
||||
document.addEventListener("ipBlockError", function () {
|
||||
media.notify("IP被封警告", "检测到12306已封锁您的IP。如果频繁出现此问题请使用代理服务器或重启路由器 :-(");
|
||||
});
|
||||
})();
|
||||
@ -305,11 +307,14 @@
|
||||
port.track(param.trackTypes.OPEN_PAGE_INDEX);
|
||||
|
||||
//后台触发更新
|
||||
port.sendMessage({ action: "triggerUpdate" });
|
||||
port.sendMessage({action: "triggerUpdate"});
|
||||
|
||||
//服务器加速
|
||||
require("./ui-dnsspeeding.js");
|
||||
|
||||
//速度表
|
||||
require("./widget-queryspeedmeter.js");
|
||||
|
||||
//暂时屏蔽
|
||||
//$.showModalDialog("由于12306的验证码调整,请暂时使用官网购票。助手会回来的,感谢您的关注。这是12306的进步,请为12306点赞 :-)", {
|
||||
// image: "/images/cat.png",
|
||||
|
25
Web12306/js/ui/widget-queryspeedmeter.js
Normal file
25
Web12306/js/ui/widget-queryspeedmeter.js
Normal file
@ -0,0 +1,25 @@
|
||||
define(function (require, exports, module) {
|
||||
var queryTicket = require("../otn/queryticket.js");
|
||||
var utility = require("../otn/utility.js");
|
||||
var container = $("#speed-meter");
|
||||
|
||||
var refreshMeter = function () {
|
||||
container.removeClass();
|
||||
|
||||
var speed = queryTicket.averageQueryTime;
|
||||
if (speed == null || isNaN(speed)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var level = speed / 50;
|
||||
var star = level <= 2 ? 1 : level <= 6 ? 2 : level <= 10 ? 3 : level <= 14 ? 4 : 5;
|
||||
var cssClass = star === 1 ? "good" : star < 4 ? "normal" : "bad";
|
||||
|
||||
container.show();
|
||||
container.find("span:eq(0)").html(star);
|
||||
container.find("span:eq(1)").html(Math.round(speed));
|
||||
container.removeClass().addClass("visible speed-" + cssClass);
|
||||
};
|
||||
|
||||
setInterval(refreshMeter, 1000);
|
||||
});
|
@ -7,6 +7,28 @@
|
||||
|
||||
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
||||
};
|
||||
/**
|
||||
* 格式化数字显示
|
||||
* @param {number} number 要格式化的数字
|
||||
* @param {number} digits 要保留的数字位数
|
||||
*/
|
||||
exports.formatNumber = function (number, digits) {
|
||||
digits = digits || 2;
|
||||
|
||||
var str = '' + Math.round(number * (10 ^ digits)) / (10 ^ digits);
|
||||
var fc = digits;
|
||||
var idx = str.indexOf(".");
|
||||
if (idx != -1) fc = digits - str.length - idx - 1;
|
||||
else str += ".";
|
||||
|
||||
var ab = [];
|
||||
for (var i = 0; i < fc; i++) {
|
||||
ab.push("0");
|
||||
}
|
||||
|
||||
return str + ab.join("");
|
||||
|
||||
};
|
||||
//exports.addDays = function (date, days) {
|
||||
// var x = new Date();
|
||||
// x.setTime(date.getTime() - date.getTime() % (1000 * 3600 * 24) + 1000 * 3600 * 24 * days);
|
||||
@ -104,7 +126,7 @@
|
||||
seat = _.find(seatOrder, function (s) {
|
||||
var treg = _.find(trainFilter, function (t) {
|
||||
train = _.find(trainList, function (item) {
|
||||
return t.test(item.code) && (_.findWhere(item.tickets, { code: s }) || {}).count >= count;
|
||||
return t.test(item.code) && (_.findWhere(item.tickets, {code: s}) || {}).count >= count;
|
||||
});
|
||||
return typeof (train) != 'undefined';
|
||||
});
|
||||
@ -115,7 +137,7 @@
|
||||
_.find(trainFilter, function (t) {
|
||||
seat = _.find(seatOrder, function (s) {
|
||||
train = _.find(trainList, function (item) {
|
||||
return t.test(item.code) && (_.findWhere(item.tickets, { code: s }) || {}).count >= count;
|
||||
return t.test(item.code) && (_.findWhere(item.tickets, {code: s}) || {}).count >= count;
|
||||
});
|
||||
return typeof (train) != 'undefined';
|
||||
});
|
||||
@ -124,11 +146,11 @@
|
||||
}
|
||||
|
||||
if (seat)
|
||||
return { seat: seat, train: train };
|
||||
return {seat: seat, train: train};
|
||||
return null;
|
||||
};
|
||||
exports.getVcValidate = function (vc) {
|
||||
return vc + " " + new Date().toLocaleString() + " keyup " + JSON.stringify({ keyCode: vc.charCodeAt(vc.length - 1) });
|
||||
return vc + " " + new Date().toLocaleString() + " keyup " + JSON.stringify({keyCode: vc.charCodeAt(vc.length - 1)});
|
||||
};
|
||||
exports.parseTimeSpanToMinutes = function (value) {
|
||||
/// <summary>将“小时:分钟”格式的时间标签转换为分钟</summary>
|
||||
@ -144,10 +166,10 @@
|
||||
return (days > 0 ? days + "天" : "") + (hours > 0 ? hours + "小时" : "") + (minutes > 0 ? minutes + "分钟" : "");
|
||||
};
|
||||
|
||||
var encodeHTMLRules = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' },
|
||||
var encodeHTMLRules = {"&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/'},
|
||||
matchHTML = /&(?!#?\w+;)|<|>|"|'|\//g;
|
||||
exports.htmlEncode = function (str) {
|
||||
return str.replace(matchHTML, function(m) {
|
||||
return str.replace(matchHTML, function (m) {
|
||||
return encodeHTMLRules[m] || m;
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user