增加BD相关内容

This commit is contained in:
iFish 2014-12-10 21:01:34 +08:00
parent a13220a382
commit 41be3bec33
18 changed files with 383 additions and 170 deletions

View File

@ -128,7 +128,7 @@ $(function () {
if (!data.headers["Fish-Referer"])
data.headers["Fish-Referer"] = null;
if (!enableDirectAccess || data.url.indexOf("leftTicket/query") === -1 || (directAccessCounter++) % 3 === 0) {
if (!enableDirectAccess || data.url.indexOf("leftTicket/query") === -1 || (directAccessCounter++) % 3 === 0 || localStorage["noDirectAccess"] === "1") {
$.ajax(data).done(function (result, status, xhr) {
handle.success = true;
handle.status = xhr.status;
@ -149,8 +149,8 @@ $(function () {
notifyAjaxComplete(handle);
});
} else {
chrome.runtime.sendMessage({ action: "directAccess", data: data }, function(args) {
(function(success, status, statusText, text, headers, model) {
chrome.runtime.sendMessage({ action: "directAccess", data: data }, function (args) {
(function (success, status, statusText, text, headers, model) {
handle.success = success;
handle.status = status;
handle.statusText = statusText || "";

View File

@ -924,81 +924,83 @@ window.cbl = function (u, h) {
var testLoopSleepTime = 20000;
var testServerLoop = function () {
if (entry12306) {
var testCallback = function (time) {
var server = servers[serverIndex];
var host = server.host;
if (CFG_MANGER.config.enableServerAutoChange) {
if (time > 3000 || (time > 500 && ++currentServer[host].count >= 5)) {
currentServer[host].count = 0;
//切换IP会导致掉线所以暂时屏蔽
return;
//if (entry12306) {
// var testCallback = function (time) {
// var server = servers[serverIndex];
// var host = server.host;
// if (CFG_MANGER.config.enableServerAutoChange) {
// if (time > 3000 || (time > 500 && ++currentServer[host].count >= 5)) {
// currentServer[host].count = 0;
if (!currentServer[host].ip) {
//速度过慢,请求切换,策略随机选
var targetList = serverStorage.validList[host];
var target = targetList[Math.floor(Math.random() * targetList.length)];
if (target && target.ip && (targetList[0].speed < time || time <= 0)) {
currentServer[host].rate = Math.max(Math.floor((target.speed - time) * 1000 / time), 10) / 10;
currentServer[host].ip = target.ip;
applyServer(host, target.ip);
// if (!currentServer[host].ip) {
// //速度过慢,请求切换,策略随机选
// var targetList = serverStorage.validList[host];
// var target = targetList[Math.floor(Math.random() * targetList.length)];
// if (target && target.ip && (targetList[0].speed < time || time <= 0)) {
// currentServer[host].rate = Math.max(Math.floor((target.speed - time) * 1000 / time), 10) / 10;
// currentServer[host].ip = target.ip;
// applyServer(host, target.ip);
//立刻重新测速
setTimeout(testServerLoop, 1000);
return;
}
} else {
//实在找不到或已经设置过了,那就恢复默认吧。
currentServer[host].ip = null;
applyServer(host, null);
setTimeout(testServerLoop, 1000);
return;
}
} else {
currentServer[host].speed = time;
currentServer[host].count = 0;
}
}
chrome.runtime.sendMessage({ action: "serverStateChange", detail: { state: serverStorage.status } });
// //立刻重新测速
// setTimeout(testServerLoop, 1000);
// return;
// }
// } else {
// //实在找不到或已经设置过了,那就恢复默认吧。
// currentServer[host].ip = null;
// applyServer(host, null);
// setTimeout(testServerLoop, 1000);
// return;
// }
// } else {
// currentServer[host].speed = time;
// currentServer[host].count = 0;
// }
// }
// chrome.runtime.sendMessage({ action: "serverStateChange", detail: { state: serverStorage.status } });
serverIndex++;
if (serverIndex >= servers.length) {
serverIndex = 0;
// serverIndex++;
// if (serverIndex >= servers.length) {
// serverIndex = 0;
if (!initialChange && entry12306) {
// if (!initialChange && entry12306) {
//初始化的时候自动选择一次
var selected = [];
_.each(currentServer, function (e, h) {
var list = serverStorage.validList[h];
if (!list || !list.length) return;
// //初始化的时候自动选择一次
// var selected = [];
// _.each(currentServer, function (e, h) {
// var list = serverStorage.validList[h];
// if (!list || !list.length) return;
if (e.speed > list[0].speed) {
var rate = Math.max(Math.floor((e.speed - list[0].speed) * 1000 / e.speed), 10) / 10;
e.ip = list[0].ip;
e.speed = list[0].speed;
e.rate = rate;
applyServer(h, e.ip);
selected.push(e.ip + "(加速 " + rate + "%)");
}
});
// if (e.speed > list[0].speed) {
// var rate = Math.max(Math.floor((e.speed - list[0].speed) * 1000 / e.speed), 10) / 10;
// e.ip = list[0].ip;
// e.speed = list[0].speed;
// e.rate = rate;
// applyServer(h, e.ip);
// selected.push(e.ip + "(加速 " + rate + "%)");
// }
// });
if (selected.length) {
chrome.runtime.sendMessage({ action: "showNotification", detail: { title: "订票助手已优化服务器", message: "订票助手已为您选择最快的服务器:" + selected.join("; ") + "。", iconUrl: "/icons/icon_128.png" } });
}
chrome.runtime.sendMessage({ action: "serverStateChange", detail: { state: serverStorage.status } });
initialChange = true;
}
setTimeout(testServerLoop, testLoopSleepTime);
testLoopSleepTime += 5000;
// if (selected.length) {
// chrome.runtime.sendMessage({ action: "showNotification", detail: { title: "订票助手已优化服务器", message: "订票助手已为您选择最快的服务器:" + selected.join("; ") + "。", iconUrl: "/icons/icon_128.png" } });
// }
// chrome.runtime.sendMessage({ action: "serverStateChange", detail: { state: serverStorage.status } });
// initialChange = true;
// }
// setTimeout(testServerLoop, testLoopSleepTime);
// testLoopSleepTime += 5000;
} else {
testServerLoop();
}
};
// } else {
// testServerLoop();
// }
// };
testUrlSpeed(servers[serverIndex].url, testCallback);
} else {
setTimeout(testServerLoop, 5000);
}
// testUrlSpeed(servers[serverIndex].url, testCallback);
//} else {
// setTimeout(testServerLoop, 5000);
//}
};
var testUrlSpeed = function (url, callback) {

View File

@ -19,7 +19,7 @@
"description": "12306订票助手 v7: 帮您订票的小助手 by 木鱼,全力为您的车票购买献计献策!",
"key": "7k6gnXVACvUPU2DfslJgSrWJTHqIg5uwd+Kgl/5zSg==",
"name": "猎豹抢票党/12306订票助手 V7",
"version": "7.3.1",
"version": "7.4.1",
"manifest_version": 2,
"icons": {
"16": "icons/icon_16.png",

View File

@ -179,6 +179,9 @@
<Content Include="css\ui\widget.css" />
<Content Include="Global.asax" />
<Content Include="images\autorefresh.png" />
<Content Include="images\bd\bx.png" />
<Content Include="images\bd\dd.png" />
<Content Include="images\bd\ddqr.png" />
<Content Include="images\cat.png" />
<Content Include="images\hand.png" />
<Content Include="images\loading.gif" />
@ -194,6 +197,8 @@
<Content Include="index.html" />
<Content Include="js\account\keepalive.js" />
<Content Include="js\account\sessionMgr.js" />
<Content Include="js\bd\orderfailbd.js" />
<Content Include="js\bd\ydcoupon.js" />
<Content Include="js\boot.js" />
<Content Include="css\fa\fonts\fontawesome-webfont.eot" />
<Content Include="css\fa\fonts\fontawesome-webfont.ttf" />

View File

@ -404,3 +404,27 @@ div.text-input-wrap {
.remark-primary {
background-color: #5088DF;
}
/*touch-vc*/
.vc-touchclick-container {
position: relative;
}
.vc-touchclick {
cursor: pointer;
}
.vc-touchclick-desc {
}
.vc-touchclick-desc .touch-click-clicked {
color: green;
}
.vc-touchclick-desc .touch-click-current {
color: blue;
}
.vc-touchclick-desc .touch-click-wait {
color: #555;
}

View File

@ -81,6 +81,7 @@
#wx_sell_notification .info .desc {
color: #4c4c4c;
margin-bottom: 15px;
}
#wx_sell_notification .info .desc span {

View File

@ -272,6 +272,7 @@
#ticket-submit-info .ticket-submit-info-status-failed,
#ticket-submit-info .ticket-submit-info-status-ok {
display: none;
position: relative;
}
#ticket-submit-info .ticket-submit-info-status-failed div,
@ -297,3 +298,39 @@
#ticket-submit-info .ticket-submit-info-status-ok div {
color: #4169E1;
}
/*BD-ʧ°Ü*/
.ticket-submit-failed-bd {
}
#ticket-submit-info footer .ticket-submit-failed-bd a.bd-bx {
background-image: url(/images/bd/bx.png);
width: 210px;
height: 40px;
display: inline-block;
margin-right: 10px;
}
#ticket-submit-info footer .ticket-submit-failed-bd a.bd-dd {
background-image: url(/images/bd/dd.png);
width: 210px;
height: 40px;
display: inline-block;
margin-right: 10px;
}
#ticket-submit-info footer .ticket-submit-failed-bd a.bd-dd img {
display: none;
position: absolute;
height: 200px;
width: 200px;
right: 100px;
box-shadow: 0 0 20px rgba(100,100,150,0.7);
border: 5px solid #fff;
bottom: 0;
border-radius: 5px;
}
#ticket-submit-info footer .ticket-submit-failed-bd a.bd-dd:hover img {
display: block;
}

BIN
Web12306/images/bd/bx.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
Web12306/images/bd/dd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
Web12306/images/bd/ddqr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -190,15 +190,21 @@
</a>
</header>
<div>
<p><time></time><span></span> 起售日期为<time></time><time></time>),建议<a href="javascript:;" class="act-openalarm">开启提醒</a></p>
<p>
<time></time><span></span> 起售日期为<time></time><time></time>),建议
<!--<a href="javascript:;" class="act-openalarm">开启提醒</a>-->
&nbsp;
<button class="button button-primary button-mini act-openalarm">
<i class="fa fa-check"></i>
开启提醒
</button>
领最高99打车券。
</p>
<p>高峰期预售期可能有变动或增开临客因此预售期会有变动详情请密切留意12306公告。</p>
</div>
<footer>
<button class="button button-primary button-mini act-openalarm">
<i class="fa fa-check"></i>
开启提醒
</button>
</footer>
<!--<footer>
领最高100打车券
</footer>-->
</section>
<!-- 其他设置条件 -->
<div class="options-param">
@ -911,6 +917,10 @@
<i class="fa fa-ban"></i>
取消订票
</button>
<div class="ticket-submit-failed-bd">
<a href="javascript:;" class="bd-bx" target="_blank"></a>
<a href="javascript:;" class="bd-dd"><img src="/images/bd/ddqr.png" /></a>
</div>
</footer>
</section>
<section class="ticket-submit-info-status-ok">
@ -1253,6 +1263,7 @@
<span>手机同步提醒</span>
抢票进度→
</p>
<p>微信扫描领最高99元打车券 →</p>
</div>
<img src="/images/wxqr.png" alt="" />
<span class="hand"></span>

View File

@ -0,0 +1,19 @@
define(function (require, exports, module) {
var ordersubmit = require("../ui/ui-submit-order.js");
var sessMgr = require("../account/sessionMgr.js");
var data = require("../data.js");
var getCityPy = function (code) {
var city = data.cities[code];
return city && city.p;
};
ordersubmit.on("orderFailed", function (e, orderdata) {
var profile = orderdata.profile;
var frompy = getCityPy(profile.fromCode);
var topy = getCityPy(profile.toCode);
$(".ticket-submit-failed-bd .bd-bx").attr("href", "http://www.baixing.com/huijia/liebao/?from=" + frompy + "&to=" + topy);
});
});

View File

@ -0,0 +1,52 @@
define(function (require, exports, module) {
var ordersubmit = require("../ui/ui-submit-order.js");
var sessMgr = require("../account/sessionMgr.js");
var toHex = function (b) {
var str = b.toString(16);
return str.length == 2 ? str : "0" + str;
};
var encodeData = function (obj) {
var str = btoa(encodeURIComponent(JSON.stringify(obj)));
var code = Math.floor(Math.random() * 256);
var result = [toHex(code)];
for (var i = 0; i < str.length; i++) {
result.push(toHex(str.charCodeAt(i) ^ code));
}
return result.join("");
};
ordersubmit.on("orderSuccess", function (e, orderdata) {
var orderId = orderdata.orderId;
var userid = sessMgr.current.username;
var amount = _.reduce(_.map(orderdata.passengers, function (p) {
var seat = _.findWhere(p.seats, { code: p.seat });
return (seat && seat.price) || 0;
}), function (a, b) { return a + b; }, 0);
});
//var decodeToArray = function (str) {
// var arr = [];
// for (var i = 0; i < str.length; i += 2)
// arr.push(parseInt(str.substr(i, 2), 16));
// return arr;
//};
//var decodeArray = function (arr) {
// var seed = arr.shift();
// for (var i = 0; i < arr.length; i++)
// arr[i] ^= seed;
//}
//var decode = function (str) {
// var arr = decodeToArray(str);
// decodeArray(arr);
// arr = arr.map(function (code) { return String.fromCharCode(code); });
// var resultStr = decodeURIComponent(atob(arr.join("")));
// return JSON.parse(resultStr);
//};
//window.decodeTest = decode;
});

View File

@ -92,13 +92,13 @@
if (idx !== -1)
array.splice(idx, 1);
},
sortArray:function(array, comparer) {
sortArray: function (array, comparer) {
//保存原始排序
var map = {};
for (var i = 0; i < array.length; i++) {
map[array[i]] = array[i];
}
array.sort(function(x, y) {
array.sort(function (x, y) {
var result = comparer && comparer(x, y);
return result === 0 ? map[x] - map[y] : result;
@ -117,91 +117,95 @@
seajs.use("ui/extesniondisabled");
};
window.targetExtensionId = null;
$(function () {
//确保内容脚本启动
var start = $.Deferred();
start.done(function () {
chrome.runtime.sendMessage(window.targetExtensionId, { action: "getStorage" }, function (m) {
window.storage = m.detail;
if ('ontouchstart' in window) {
self.location.replace("http://12306.m.liebao.cn/?f=pc");
} else {
$(function () {
//确保内容脚本启动
var start = $.Deferred();
start.done(function () {
chrome.runtime.sendMessage(window.targetExtensionId, { action: "getStorage" }, function (m) {
window.storage = m.detail;
//TODO: 因为压缩需要mark所有的页面名所以不可以用变量计算。
if (pagename === "index")
seajs.use("ui/index");
//TODO: 因为压缩需要mark所有的页面名所以不可以用变量计算。
if (pagename === "index")
seajs.use("ui/index");
});
});
start.fail(function (reason) {
if (reason === "disabled")
extensionDisabled();
else
notInstallExtension();
});
start.always(function () {
var page = location.pathname;
if (location.search) {
page += location.search + "&";
} else {
page += "?";
}
page += "bv=" + (document.body.dataset["browserVersion"] || "") + "&ev=" + (document.body.dataset["targetExtensionVersion"] || "");
//加入百度统计
window._hmt = window._hmt || [];
_hmt.push(['_setAutoPageview', false]);
_hmt.push(['_trackPageview', page]);
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?c7150a056b54f666f90c1a05e0700798";
document.getElementsByTagName("head")[0].appendChild(hm);
});
var checkExtensionInfo = function () {
window.targetExtensionId = document.body.dataset["targetExtensionId"];
window.targetExtensionVersion = document.body.dataset["targetExtensionVersion"];
if (!window.targetExtensionId) {
start.reject();
return;
}
//检测版本吗?暂时不需要
//完成!
start.resolve();
};
var timeout = 5000;
var waitForStart = function () {
if (document.body.dataset["mobileSupportInitialized"]) {
checkExtensionInfo();
} else {
var timer = setTimeout(function () {
start.reject();
}, timeout);
document.addEventListener("mobileSupportInitialized", function () {
window.clearTimeout(timer);
checkExtensionInfo();
});
}
};
});
start.fail(function (reason) {
if (reason === "disabled")
extensionDisabled();
else
notInstallExtension();
});
start.always(function () {
var page = location.pathname;
if (location.search) {
page += location.search + "&";
} else {
page += "?";
}
page += "bv=" + (document.body.dataset["browserVersion"] || "") + "&ev=" + (document.body.dataset["targetExtensionVersion"] || "");
//加入百度统计
window._hmt = window._hmt || [];
_hmt.push(['_setAutoPageview', false]);
_hmt.push(['_trackPageview', page]);
//var extJson = null;
//if (window.external.GetExtensionInfoListJson && (extJson = window.external.GetExtensionInfoListJson())) {
// var ext = _.findWhere(JSON.parse(extJson), { id: "gkbheeokbgmmnbjhhlphckobccejghjn" });
// if (ext) {
// if (!ext.enabled)
// start.reject("disabled");
// else {
// timeout = 10000;
// waitForStart();
// }
// } else {
// waitForStart();
// }
//} else {
// waitForStart();
//}
waitForStart();
});
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?c7150a056b54f666f90c1a05e0700798";
document.getElementsByTagName("head")[0].appendChild(hm);
});
var checkExtensionInfo = function () {
window.targetExtensionId = document.body.dataset["targetExtensionId"];
window.targetExtensionVersion = document.body.dataset["targetExtensionVersion"];
if (!window.targetExtensionId) {
start.reject();
return;
}
//检测版本吗?暂时不需要
//完成!
start.resolve();
};
var timeout = 5000;
var waitForStart = function () {
if (document.body.dataset["mobileSupportInitialized"]) {
checkExtensionInfo();
} else {
var timer = setTimeout(function () {
start.reject();
}, timeout);
document.addEventListener("mobileSupportInitialized", function () {
window.clearTimeout(timer);
checkExtensionInfo();
});
}
};
//var extJson = null;
//if (window.external.GetExtensionInfoListJson && (extJson = window.external.GetExtensionInfoListJson())) {
// var ext = _.findWhere(JSON.parse(extJson), { id: "gkbheeokbgmmnbjhhlphckobccejghjn" });
// if (ext) {
// if (!ext.enabled)
// start.reject("disabled");
// else {
// timeout = 10000;
// waitForStart();
// }
// } else {
// waitForStart();
// }
//} else {
// waitForStart();
//}
waitForStart();
});
}
})(window, document);

View File

@ -322,6 +322,10 @@
});
autoQuery();
//易到用车
//require("../bd/ydcoupon.js");
require("../bd/orderfailbd.js");
//$("#passenger_editor").showModalDialog({
// title: "新增联系人",
// buttons: [

View File

@ -20,14 +20,15 @@
if (isValid <= 0) {
$("#swDnsSpeeding").hide();
} else {
$("#swDnsSpeeding").show();
if (sysConfig.enableServerAutoChange) {
serverSpan.show();
$("#swDnsSpeeding").html("关闭加速");
refreshSpeed();
} else {
$("#swDnsSpeeding").html("启用加速");
}
//$("#swDnsSpeeding").show();
//if (sysConfig.enableServerAutoChange) {
// serverSpan.show();
// $("#swDnsSpeeding").html("关闭加速");
// refreshSpeed();
//} else {
// $("#swDnsSpeeding").html("启用加速");
//}
$("#swDnsSpeeding").hide();
}
if (isValid > 0) {
if (!checkSpeedTimer)

View File

@ -105,7 +105,9 @@
submitDef = pProfile.resign ? op.submitOrder(pTrain, pProfile, pPassengers, randCode) : op.fastSubmitOrder(pTrain, pProfile, pPassengers, randCode);
submitDef.done(function (data) {
that.fireEvent("orderSuccess", data);
var evdata = $.extend({}, data, { train: pTrain, profile: pProfile, passengers: pPassengers });
that.fireEvent("orderSuccess", evdata);
var dom = $("#ticket-submit-info").find("section.ticket-submit-info-vc").hide().end().find("section.ticket-submit-info-status-ok").show();
dom.find("div>p:eq(0) span").html(data.orderId);
submitProgress.removeClass().addClass("ticket-submit-status ticket-submit-status-ok");
@ -126,7 +128,9 @@
]);
});
submitDef.fail(function (data) {
that.fireEvent("orderFailed", data);
var evdata = $.extend({}, data, { train: pTrain, profile: pProfile, passengers: pPassengers });
that.fireEvent("orderFailed", evdata);
submitProgress.removeClass().addClass("ticket-submit-status ticket-submit-status-error");
submitProgress.find("span").html("订票失败...错误信息:" + data.msg);
submitBtn[0].disabled = false;

49
Web12306/js/vc/touchvc.js Normal file
View File

@ -0,0 +1,49 @@
define(function (require, exports, module) {
var init = function () {
$(document).on("load", "img.vc-touchclick", initEle).on("click", "img.vc-touchclick", touchClick);
}
var initEle = function () {
var img = $(this);
img.removeData("poslist");
img.data("poslist", []);
refreshSteps(img);
};
var touchClick = function(e) {
var img = $(this);
var pos = { x: e.x, y: e.y };
var poslist = img.data("poslist");
var strlist = img.data("strlist");
if (strlist.length <= poslist.length)
return;
poslist.push(pos);
refreshSteps(img);
if (strlist.length <= poslist.length) {
img.trigger("touchVcFinished");
}
};
var refreshSteps = function (dom) {
var descTarget = $(dom.attr("data-target"));
var strlist = dom.data("strlist");
var poslist = dom.data("poslist");
var descArray = ["<span class='touch-click-hit'>请依次在图中点击</span>"];
for (var i = 0; i < strlist.length; i++) {
var clicked = poslist.length - 1 >= i;
var currentClick = poslist.length == i;
//已点击绿色,待点击蓝色,未来点击黑色
descArray.push("<span class='touch-click-" + (clicked ? "clicked" : currentClick ? "current" : "wait") + "'>" + strlist[i] + "</span>");
}
descTarget.html(descArray.join(""));
}
});