diff --git a/RwTicketAssistantV2/app/background.js b/RwTicketAssistantV2/app/background.js index 3e22109..8a5f4e2 100644 --- a/RwTicketAssistantV2/app/background.js +++ b/RwTicketAssistantV2/app/background.js @@ -1,5 +1,5 @@ var MANIFEST = chrome.runtime.getManifest(); -var INFOBAR = chrome.infobars || (chrome.experimental && chrome.experimental.infobars); +//var INFOBAR = chrome.infobars || (chrome.experimental && chrome.experimental.infobars); var isDebug = (compressFunc + '').indexOf("false") != -1; var bv = window.external.LiebaoGetVersion && window.external.LiebaoGetVersion() || /Chrome\/([\d\.]+)/i.exec(navigator.userAgent)[1]; var entry12306 = false; @@ -136,61 +136,61 @@ var notification = (function () { return new notify(); })(); -(function () { - var notifyId; - var tabid, message; - //未加载提醒 - var closeCallback = function (id) { - if (id === notifyId) { - notifyId = null; - } - }; - var clickCallback = function (id, idx) { - if (id === notifyId && idx === 0) { - chrome.tabs.update(tabid, { - url: chrome.extension.getURL(message.detail.url.indexOf("/otn") != -1 ? "/infobar/main.html?new" : "/infobar/main.html"), - selected: true - }, function () { }); - chrome.notifications.clear("notLoadMessage", function () { }); - } - }; - chrome.notifications.onClosed.addListener(closeCallback); - chrome.notifications.onButtonClicked.addListener(clickCallback); +//(function () { +// var notifyId; +// var tabid, message; +// //未加载提醒 +// var closeCallback = function (id) { +// if (id === notifyId) { +// notifyId = null; +// } +// }; +// var clickCallback = function (id, idx) { +// if (id === notifyId && idx === 0) { +// chrome.tabs.update(tabid, { +// url: chrome.extension.getURL(message.detail.url.indexOf("/otn") != -1 ? "/infobar/main.html?new" : "/infobar/main.html"), +// selected: true +// }, function () { }); +// chrome.notifications.clear("notLoadMessage", function () { }); +// } +// }; +// chrome.notifications.onClosed.addListener(closeCallback); +// chrome.notifications.onButtonClicked.addListener(clickCallback); - chrome.runtime.onMessage.addListener(function (m, sender, response) { - if (m.action && m.action === "notLoadTip") { - message = m; - tabid = sender.tab.id; - if (notifyId) { - chrome.notifications.update(notifyId, { - type: 'basic', - iconUrl: '/icons/icon_n.png', - title: '订票助手未启动', - message: '订票助手未加载,请点击工具栏『订票助手』图标并点击订票菜单来使用。', - buttons: [ - { title: '或点击这里启动订票助手', iconUrl: "/infobar/theme/plus_16.png" } - ] - }, function () { - }); - } else { - chrome.notifications.create('', { - type: 'basic', - iconUrl: '/icons/icon_n.png', - title: '订票助手未启动', - message: '订票助手未加载,请点击工具栏『订票助手』图标并点击订票菜单来使用。', - buttons: [ - { title: '或点击这里启动订票助手', iconUrl: "/infobar/theme/plus_16.png" } - ] - }, function (id) { - notifyId = id; - }); - } - setTimeout(function () { - closeCallback(notifyId); - }, 5000); - } - }); -})(); +// chrome.runtime.onMessage.addListener(function (m, sender, response) { +// if (m.action && m.action === "notLoadTip") { +// message = m; +// tabid = sender.tab.id; +// if (notifyId) { +// chrome.notifications.update(notifyId, { +// type: 'basic', +// iconUrl: '/icons/icon_n.png', +// title: '订票助手未启动', +// message: '订票助手未加载,请点击工具栏『订票助手』图标并点击订票菜单来使用。', +// buttons: [ +// { title: '或点击这里启动订票助手', iconUrl: "/infobar/theme/plus_16.png" } +// ] +// }, function () { +// }); +// } else { +// chrome.notifications.create('', { +// type: 'basic', +// iconUrl: '/icons/icon_n.png', +// title: '订票助手未启动', +// message: '订票助手未加载,请点击工具栏『订票助手』图标并点击订票菜单来使用。', +// buttons: [ +// { title: '或点击这里启动订票助手', iconUrl: "/infobar/theme/plus_16.png" } +// ] +// }, function (id) { +// notifyId = id; +// }); +// } +// setTimeout(function () { +// closeCallback(notifyId); +// }, 5000); +// } +// }); +//})(); //#region 系统配置处理 @@ -336,62 +336,62 @@ var CFG_MANGER = (function () { //#region 运行环境检测,以及自动处理启动 -(function checkRunModeAndBootStrap() { - localStorage["inforbarMode"] = INFOBAR ? "1" : "0"; - if (!INFOBAR) return; +//(function checkRunModeAndBootStrap() { +// localStorage["inforbarMode"] = INFOBAR ? "1" : "0"; +// if (!INFOBAR) return; - chrome.runtime.onMessage.addListener(function (msg, sender, resp) { - if (msg.action && msg.action == "isInforbarEnabled") { - resp(INFOBAR ? true : false); - } - }); +// chrome.runtime.onMessage.addListener(function (msg, sender, resp) { +// if (msg.action && msg.action == "isInforbarEnabled") { +// resp(INFOBAR ? true : false); +// } +// }); - function checkIfInfobarShown(tabid) { - var views = chrome.extension.getViews({ type: "infobar" }); - for (var i in views) { - var v = views[i]; - if (v.location.search == "?" + tabid) { - return true; - } - } - return false; - } +// function checkIfInfobarShown(tabid) { +// var views = chrome.extension.getViews({ type: "infobar" }); +// for (var i in views) { +// var v = views[i]; +// if (v.location.search == "?" + tabid) { +// return true; +// } +// } +// return false; +// } - var showInfobar = function (tabid, page, isOtn) { - //if (checkIfInfobarShown(tabid)) { - // INFOBAR.show({ - // tabId: tabid, - // height: 155 - // }); +// var showInfobar = function (tabid, page, isOtn) { +// //if (checkIfInfobarShown(tabid)) { +// // INFOBAR.show({ +// // tabId: tabid, +// // height: 155 +// // }); - // return; - //} +// // return; +// //} - //显示infobar - INFOBAR.show({ - tabId: tabid, - height: 155, - path: "/infobar/" + page + ".html?" + (isOtn ? "new" : "old") + tabid - }); - }; +// //显示infobar +// INFOBAR.show({ +// tabId: tabid, +// height: 155, +// path: "/infobar/" + page + ".html?" + (isOtn ? "new" : "old") + tabid +// }); +// }; - chrome.tabs.onUpdated.addListener(function (tabid, changeinfo, tab) { - if (changeinfo.status == "complete") { - if (/https?:\/\/(www|dynamic|kyfw)\.12306\.cn\/otn.*/i.test(tab.url)) { - showInfobar(tab.id, "main", true); - } - } - }); +// chrome.tabs.onUpdated.addListener(function (tabid, changeinfo, tab) { +// if (changeinfo.status == "complete") { +// if (/https?:\/\/(www|dynamic|kyfw)\.12306\.cn\/otn.*/i.test(tab.url)) { +// showInfobar(tab.id, "main", true); +// } +// } +// }); - //初始化infobar - /*chrome.tabs.query({ url: "*://kyfw.12306.cn/*" }, function (ta) { - $.each(ta, function () { - if (!checkIfInfobarShown(this.id)) { - showInfobar(this.id, true); - } - }); - });*/ -})(); +// //初始化infobar +// /*chrome.tabs.query({ url: "*://kyfw.12306.cn/*" }, function (ta) { +// $.each(ta, function () { +// if (!checkIfInfobarShown(this.id)) { +// showInfobar(this.id, true); +// } +// }); +// });*/ +//})(); //#endregion @@ -1195,7 +1195,7 @@ window.cbl = function (u, h) { (function () { var cv = parseInt(/Chrome\/(\d+)/i.exec(navigator.userAgent)[1]); - var updateurl = "http://www.fishlee.net/service/update2/44/" + (cv < 34 ? "44" : "60") + "/version_v6" + (INFOBAR ? "" : "_1") + ".json?" + Math.random(); + var updateurl = "http://www.fishlee.net/service/update2/44/" + (cv < 34 ? "44" : "60") + "/version_v6.json?" + Math.random(); var lastCheckUpdate = null; var hasUpdate = false, lastVersion = null, lastMessage = null, updateInfo = null; diff --git a/RwTicketAssistantV2/app/manifest.json b/RwTicketAssistantV2/app/manifest.json index de0bdce..c26dc43 100644 --- a/RwTicketAssistantV2/app/manifest.json +++ b/RwTicketAssistantV2/app/manifest.json @@ -1,34 +1,6 @@ { "content_security_policy": "script-src 'self' https://hm.baidu.com; object-src 'self';", "content_scripts": [ - { - "all_frames": true, - "exclude_globs": [ ], - "exclude_matches": [ ], - "include_globs": [ ], - "js": [ "libs/jquery.js", "libs/underscore/underscore.js", "contentscripts/framework.js", "contentscripts/morweb/12306.js" ], - "matches": [ "http://dynamic.12306.cn/otsweb/*", "https://dynamic.12306.cn/otsweb/*" ], - "run_at": "document_end" - }, - { - "all_frames": true, - "exclude_globs": [ ], - "exclude_matches": [ ], - "include_globs": [ ], - "js": [ "libs/jquery.js", "libs/underscore/underscore.js", "contentscripts/kyfw/12306_pre.js" ], - "matches": [ "http://*.12306.cn/otn/*", "https://*.12306.cn/otn/*" ], - "run_at": "document_start" - }, - { - "all_frames": true, - "exclude_globs": [ ], - "exclude_matches": [ ], - "include_globs": [ ], - "js": [ "libs/jquery.js", "libs/underscore/underscore.js", "contentscripts/framework.js", "contentscripts/kyfw/12306.js" ], - "css": [ "contentscripts/kyfw/12306.css" ], - "matches": [ "http://*.12306.cn/otn/*", "https://*.12306.cn/otn/*" ], - "run_at": "document_end" - }, { "all_frames": true, "exclude_globs": [ ], @@ -37,15 +9,6 @@ "js": [ "libs/jquery.js", "12306/mobileproxy.js" ], "matches": [ "http://test.fishlee.net/*", "http://dev.fishlee.net/*", "http://app.fishlee.net/*", "http://12306.liebao.cn/*" ], "run_at": "document_end" - }, - { - "all_frames": false, - "exclude_globs": [ ], - "exclude_matches": [ ], - "include_globs": [ ], - "css": [ "contentscripts/morweb/12306_style.css" ], - "matches": [ "http://www.12306.cn/mormhweb/kyfw/*" ], - "run_at": "document_end" } ], "browser_action": { @@ -65,7 +28,7 @@ "128": "icons/icon_128.png" }, "homepage_url": "http://www.fishlee.net/", - "permissions": [ "management", "tabs", "http://*.12306.cn/*", "https://*.12306.cn/*", "http://*.fishlee.net/*", "http://*.liebao.cn/*", "notifications", "webRequest", "webRequestBlocking", "http://*.fishlee.net/*", "http://*.ijinshan.com/*", "*://*/*", "infobars" ], + "permissions": [ "management", "tabs", "http://*.12306.cn/*", "https://*.12306.cn/*", "http://*.fishlee.net/*", "http://*.liebao.cn/*", "notifications", "webRequest", "webRequestBlocking", "http://*.fishlee.net/*", "http://*.ijinshan.com/*", "*://*/*" ], "update_url": "http://www.fishlee.net/service/update2/44/44/update_lb.xml", "background": { "page": "background.html" diff --git a/TrainInfomationProviderService/Web/Controllers/TransitController.cs b/TrainInfomationProviderService/Web/Controllers/TransitController.cs index a2a1ba1..0fab48e 100644 --- a/TrainInfomationProviderService/Web/Controllers/TransitController.cs +++ b/TrainInfomationProviderService/Web/Controllers/TransitController.cs @@ -11,7 +11,6 @@ using TrainInfomationProviderService.TrainInfo.Entities; namespace TrainInfomationProviderService.Web.Controllers { - [AllowOriginFilter(@"(https?://.*?\.(fishlee\.net|liebao\.cn)|chrome-extension://.*)")] public class TransitController : Controller { #region Overrides of Controller @@ -24,6 +23,7 @@ namespace TrainInfomationProviderService.Web.Controllers { base.OnAuthorization(filterContext); + filterContext.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*"); if (!TrainInfoSearchProvider.Instance.IsReady) filterContext.Result = Json(new { ret = false, msg = "service not ready." }, JsonRequestBehavior.AllowGet); } @@ -119,6 +119,8 @@ namespace TrainInfomationProviderService.Web.Controllers { from = s.First.FromStation.Code, to = s.First.ToStation.Code, + fe = s.First.IsBegin, + ae = s.First.IsEnd, train = new { id = s.First.Train.Id, @@ -131,6 +133,8 @@ namespace TrainInfomationProviderService.Web.Controllers second = new { from = s.Second.FromStation.Code, + fe = s.Second.IsBegin, + ae = s.Second.IsEnd, to = s.Second.ToStation.Code, train = new { @@ -148,6 +152,7 @@ namespace TrainInfomationProviderService.Web.Controllers var data = new { + @base = result.Date.ToString(), cities, corder = result.CityOrder, lines, diff --git a/Web12306/Web12306.csproj b/Web12306/Web12306.csproj index f986195..5fe4c45 100644 --- a/Web12306/Web12306.csproj +++ b/Web12306/Web12306.csproj @@ -195,6 +195,8 @@ + + diff --git a/Web12306/css/base.css b/Web12306/css/base.css index 17cd3e6..eb2d154 100644 --- a/Web12306/css/base.css +++ b/Web12306/css/base.css @@ -181,7 +181,7 @@ a:active { display: block; color: #fff; cursor: pointer; - } + } .header-bar .user-nav li.selected > a { color: #f17206; @@ -348,3 +348,30 @@ div.text-input-wrap { color: #6f7379; display: inline-block; } + +.text-align-center { + text-align: center; +} + +.remark { + padding: 5px; + background: rgb(102, 102, 102); + color: #fff; + border-radius: 3px; + font-size: 12px; + vertical-align: 10%; + font-weight: normal; + margin-left: 5px; + margin-right: 5px; +} + +.remark-mini { + padding: 0 4px; +} + +.remark-warning { + background-color: #C56063; +} +.remark-primary { + background-color: #5088DF; +} diff --git a/Web12306/css/ui/date-popup.css b/Web12306/css/ui/date-popup.css index 7cedb66..4816369 100644 --- a/Web12306/css/ui/date-popup.css +++ b/Web12306/css/ui/date-popup.css @@ -10,22 +10,26 @@ display: none; } -#dateSelector:hover { - display: block; -} + #dateSelector:hover { + display: block; + } -#dateSelector.open { - display: block; -} + #dateSelector.open { + display: block; + } -#dateSelector.open:hover { - display: block; -} + #dateSelector.open:hover { + display: block; + } -#dateSelector .month-first, #dateSelector .month-second { - float: left; -} + #dateSelector .month-first, #dateSelector .month-second { + float: left; + } -#dateSelector .month-second { - border-left: 1px solid #d1d1d1; -} \ No newline at end of file + #dateSelector .month-second { + border-left: 1px solid #d1d1d1; + } + + #dateSelector .date-thismonth { + font-weight: bold; + } diff --git a/Web12306/css/ui/date-selector.css b/Web12306/css/ui/date-selector.css index 6398731..00ee687 100644 --- a/Web12306/css/ui/date-selector.css +++ b/Web12306/css/ui/date-selector.css @@ -258,7 +258,6 @@ .date-selector .date-commonavailable { color: #d8a15e; background-color: #FFF1E0; - font-weight: bold; } .date-selector .date-notavailable { @@ -271,3 +270,6 @@ background: none; color: #ccc; } + .date-selector .date-thismonth { + font-weight: bold; + } \ No newline at end of file diff --git a/Web12306/css/ui/index-search-base.css b/Web12306/css/ui/index-search-base.css index dd07f6d..37f0733 100644 --- a/Web12306/css/ui/index-search-base.css +++ b/Web12306/css/ui/index-search-base.css @@ -281,7 +281,7 @@ button#btnResetOptions { position: absolute; right: 10px; - bottom: 0; + bottom: 3px; } .search-traintypes { diff --git a/Web12306/css/ui/options-param.css b/Web12306/css/ui/options-param.css index 477ca2c..fd52a0e 100644 --- a/Web12306/css/ui/options-param.css +++ b/Web12306/css/ui/options-param.css @@ -9,13 +9,14 @@ margin-bottom: 10px; } -.options-param >dl { - margin: 0; -} - .options-param > dl:nth-child(1) { - margin-top: 5px; + .options-param > dl { + margin: 0; } + .options-param > dl:nth-child(1) { + margin-top: 5px; + } + .options-param dt { height: 36px; line-height: 36px; @@ -117,6 +118,14 @@ color: #ff6a00; } + .options-param .options-seat-type ul li:last-child { + float: none; + clear: both; + border-top: 1px dotted #ccc; + display: block; + width: 100%; + } + .options-param .options-train-selectorwarp { position: relative; } diff --git a/Web12306/css/ui/query-result.css b/Web12306/css/ui/query-result.css index 3a86dc9..1197a47 100644 --- a/Web12306/css/ui/query-result.css +++ b/Web12306/css/ui/query-result.css @@ -178,6 +178,11 @@ border-top: 1px solid #cccccc; } + .result .train-list-func { + text-align: center; + line-height: 60px; + } + /*购票建议*/ #suggestion { display: none; @@ -275,6 +280,7 @@ line-height: 30px; font-weight: bold; text-indent: 10px; + background: linear-gradient(to bottom, #efefef, #d9d9d9); } #oncetrainsit > header a { @@ -283,6 +289,16 @@ font-weight: normal; } + #oncetrainsit > header > ul { + float: right; + overflow: hidden; + font-weight: normal; + } + + #oncetrainsit > header > ul > li { + float: right; + } + #oncetrainsit > footer { padding: 10px; } @@ -298,13 +314,21 @@ } #oncetrainsit th { - border-bottom: 1px solid #cccccc; padding: 5px; font-weight: normal; } - #oncetrainsit td { + #oncetrainsit tr:nth-child(6n+5), + #oncetrainsit tr:nth-child(6n+6), + #oncetrainsit tr:nth-child(6n+7) { + background-color: #FFF9E9; + } + + #oncetrainsit .ticket-container td { border-bottom: 1px solid #f8f8f8; + padding-left: 5px; + padding-right: 5px; + vertical-align: top; } #oncetrainsit tr.recommand th { @@ -313,32 +337,35 @@ #oncetrainsit tr.header th { font-weight: bold; + background-color: #f9f9f9; + border-bottom: 1px solid #cccccc; } - #oncetrainsit tr.header th:nth-child(n+2) { + #oncetrainsit tr.header th:nth-child(n+2) { + border-left: 1px solid #cccccc; + } + + #oncetrainsit tr.sub th:nth-child(6) { + border-left: 1px solid #cccccc; + font-weight: bold; + font-size: 130%; + } + + #oncetrainsit tr.sub th:nth-child(1) { + font-weight: bold; + font-size: 130%; + } + + #oncetrainsit tr.sub th:nth-child(11) { border-left: 1px solid #cccccc; } - #oncetrainsit tr.sub th { + #oncetrainsit tr.sub th:nth-child(3), + #oncetrainsit tr.sub th:nth-child(8) { + color: #ff6a00; + font-size: 120%; } - #oncetrainsit tr.sub th:nth-child(2), - #oncetrainsit tr.sub th:nth-child(4), - #oncetrainsit tr.sub th:nth-child(7), - #oncetrainsit tr.sub th:nth-child(9), - #oncetrainsit tr.sub th:nth-child(11) { - border-bottom: none; - } - - #oncetrainsit tr.sub th:nth-child(1) { - } - #oncetrainsit tr.sub th:nth-child(6) { - border-left: 1px solid #cccccc; - } - #oncetrainsit tr.sub th:nth-child(11) { - border-left: 1px solid #cccccc; - } - #oncetrainsit tr.row td { line-height: 40px; border-bottom: 1px solid #cccccc; @@ -350,14 +377,54 @@ line-height: 40px; } - #oncetrainsit tr.ticket-container td:nth-child(n+2) { - border-left: 1px solid #cccccc; - } + #oncetrainsit tr.ticket-container td:nth-child(n+2) { + border-left: 1px solid #cccccc; + } - #oncetrainsit table .button { - padding: 0 2px; + #oncetrainsit .button { + padding: 0 4px; + font-size: 90%; } #oncetrainsit .remark { text-align: center; } + + #oncetrainsit tr.catalog th { + background: linear-gradient(to bottom, #fff, #f9f9f9); + border-bottom: 1px solid #cccccc; + text-align: left; + font-weight: normal; + } + + #oncetrainsit .ae, #oncetrainsit .fe { + color: red; + } + + #oncetrainsit .ae:after, + #oncetrainsit .fe:after { + content: '终'; + color: white; + display: inline-block; + background: #FF9310; + border-radius: 5px; + padding: 2px 3px; + font-weight: normal; + font-size: 12px; + margin-left: 4px; + line-height: 12px; + vertical-align: 10%; + } + + #oncetrainsit .fe:after { + content: '始'; + } + + #oncetrainsit .btn-ticket-block { + margin-right: 5px; + font-weight: normal; + } + + #oncetrainsit time { + font-weight: normal; + } diff --git a/Web12306/css/ui/widget-ticketsubmit.css b/Web12306/css/ui/widget-ticketsubmit.css index a4c7674..ced2ff0 100644 --- a/Web12306/css/ui/widget-ticketsubmit.css +++ b/Web12306/css/ui/widget-ticketsubmit.css @@ -281,7 +281,6 @@ padding-top: 10px; font-size: 12px; margin-top: 5px; - text-shadow: 0 0 1px rgba(200, 50, 50, 0.4); } #ticket-submit-info .ticket-submit-info-status-failed div p, @@ -297,5 +296,4 @@ #ticket-submit-info .ticket-submit-info-status-ok div { color: #4169E1; - text-shadow: 0 0 1px rgba(50, 50, 200, 0.4); } diff --git a/Web12306/index.html b/Web12306/index.html index c222c27..05efbef 100644 --- a/Web12306/index.html +++ b/Web12306/index.html @@ -117,7 +117,7 @@
  • - +
  • @@ -133,37 +133,37 @@
  • @@ -213,6 +213,14 @@ {{=it.getName(seat)}}x{{~}} + +
    @@ -354,42 +362,6 @@
    -
    -
    更多选项:
    -
    -

    - - - - - - - -

    -
    -
    出行计划:
    @@ -412,7 +384,27 @@ - + + + + +
    @@ -510,77 +502,152 @@ -
    + @@ -615,24 +682,6 @@ 发/到站 余票信息 - {{?!it.auto&&it.enableAuto&&!it.notInSellTime}} - - - 没有符合要求的车次和席别 - - - - {{??!it.inAutoRefresh&&!it.notInSellTime}} - - - 点击“显示更多选项”并设置您需要的席别和车次以开启刷票模式。 - - - {{?}} {{~it.available:t:index}} @@ -694,6 +743,16 @@ {{?}} + + + + + +
    diff --git a/Web12306/js/account/sessionMgr.js b/Web12306/js/account/sessionMgr.js index 82d6ba7..45d3b31 100644 --- a/Web12306/js/account/sessionMgr.js +++ b/Web12306/js/account/sessionMgr.js @@ -110,7 +110,7 @@ //备份当前的查询,并取代为默认的查询 var cp = that.currentProfile; if (cp) { - cp.passengers = null; //不保留乘客 + cp.passengers = null; //不保留乘客 } var profile = storage.obj("12306_user_" + dispname) || { hasNotVerifyedPassenger: false, dispname: dispname, passengers: [], savedProfile: { list: [] }, currentProfile: {}, rawPassenger: [], options: { soundPrompt: true } }; @@ -129,7 +129,7 @@ } } //fix passenger issue - profile.currentProfile.passengers = _.filter(profile.currentProfile.passengers || [], function(p) { + profile.currentProfile.passengers = _.filter(profile.currentProfile.passengers || [], function (p) { return p.passenger_name || false; }); @@ -189,8 +189,7 @@ d1 = new $.Deferred(); d1.resolve(passengers); - } - else { + } else { //that.once("passengerLoaded", function () { // callback(passengers); //}); @@ -222,6 +221,10 @@ passengers: [], hideNoSeat: false }; + this.forceProfile = { + autoSubmitEnabled: true, + autoWaitToSell: false + }; Object.defineProperty(this, "current", { get: function () { @@ -260,7 +263,7 @@ get: function () { return session && session.currentProfile; }, set: function (value) { - session.currentProfile = $.extend({}, JSON.parse(JSON.stringify(that.defaultProfile)), value); + session.currentProfile = $.extend({}, JSON.parse(JSON.stringify(that.defaultProfile)), value, JSON.parse(JSON.stringify(that.forceProfile))); that.fireEvent("currentProfileChanged"); that.save(); } diff --git a/Web12306/js/data.js b/Web12306/js/data.js index ca94942..fec8706 100644 --- a/Web12306/js/data.js +++ b/Web12306/js/data.js @@ -12,6 +12,10 @@ exports.citynameMap = _.mapObject(exports.cities, function (c) { return c.n; }); + exports.getCityName = function(code) { + var city = null; + return (city = exports.cities[code]) && city.n; + }; exports.findSimilarStation = function (name) { var extractname = null; //查找最接近的站点 diff --git a/Web12306/js/otn/orderprocess.js b/Web12306/js/otn/orderprocess.js index 3cab552..0d4ab85 100644 --- a/Web12306/js/otn/orderprocess.js +++ b/Web12306/js/otn/orderprocess.js @@ -130,10 +130,10 @@ def.reject({ msg: (parser.getError(json) || { message: "未知错误" }).message }); } else if (json.data.isRelogin) { def.reject({ msg: "登录状态异常,请重新登录。" }); - //TODO: 警告!这里对余票不足不做出错处理! - //} else if (json.data.op_2 === "true") { - // def.resolve({ success: true }); - // def.reject({ msg: "余票不足,无法提交订单。请重试或重新刷新。" }); + //TODO: 警告!这里对余票不足不做出错处理! + //} else if (json.data.op_2 === "true") { + // def.resolve({ success: true }); + // def.reject({ msg: "余票不足,无法提交订单。请重试或重新刷新。" }); } else { def.resolve({ success: true }); } @@ -173,7 +173,10 @@ }; var submitOrder = function () { - def.notify({ msg: "正在提交订单..." }); + //def.notify({ msg: "正在提交订单..." }); + //def.resolve({ orderId: "EXXXXXXXXXXXXXXXXX" }); + //def.reject({ msg: "測試失敗" }); + //return; var url = "confirmPassenger/confirmSingleForQueueAsys"; var data = { @@ -207,7 +210,7 @@ passenger[0].seat, passenger.length, train.byAuto ? 1 : 0, - train.suggest ? 1 : 0 + train.suggest || 0 ]); } }, function () { @@ -375,7 +378,7 @@ passenger[0].seat, passenger.length, train.byAuto ? 1 : 0, - train.suggest ? 1 : 0 + train.suggest||0 ]); } }, function () { diff --git a/Web12306/js/otn/trainstationsuggest.js b/Web12306/js/otn/trainstationsuggest.js index 7016297..c59774b 100644 --- a/Web12306/js/otn/trainstationsuggest.js +++ b/Web12306/js/otn/trainstationsuggest.js @@ -313,9 +313,7 @@ setQueryResult: function (result, queryCount) { registerSameStation(result); //改签或学生票,忽略 - //TODO 屏蔽 - return; - if (cp.reisgn || cp.studentTicket) + if (cp.resign || cp.studentTicket) return; ctx.TSS.setQueryResult(result, queryCount); diff --git a/Web12306/js/platform/encode.js b/Web12306/js/platform/encode.js new file mode 100644 index 0000000..db8752f --- /dev/null +++ b/Web12306/js/platform/encode.js @@ -0,0 +1,113 @@ +define(function (require, exports, module) { + function bin216(s) { + var i, l, o = "", + n; + s += ""; + b = ""; + for (i = 0, l = s.length; i < l; i++) { + b = s.charCodeAt(i); + n = b.toString(16); + o += n.length < 2 ? "0" + n : n; + } + return o; + }; + var Base32 = new function () { + var delta = 0x9E3779B8; + + function longArrayToString(data, includeLength) { + var length = data.length; + var n = (length - 1) << 2; + if (includeLength) { + var m = data[length - 1]; + if ((m < n - 3) || (m > n)) return null; + n = m; + } + for (var i = 0; i < length; i++) { + data[i] = String.fromCharCode(data[i] & 0xff, data[i] >>> 8 & 0xff, data[i] >>> 16 & 0xff, data[i] >>> 24 & 0xff); + } + if (includeLength) { + return data.join('').substring(0, n); + } else { + return data.join(''); + } + }; + + function stringToLongArray(string, includeLength) { + var length = string.length; + var result = []; + for (var i = 0; i < length; i += 4) { + result[i >> 2] = string.charCodeAt(i) | string.charCodeAt(i + 1) << 8 | string.charCodeAt(i + 2) << 16 | string.charCodeAt(i + 3) << 24; + } + if (includeLength) { + result[result.length] = length; + } + return result; + }; + this.encrypt = function (string, key) { + if (string == "") { + return ""; + } + var v = stringToLongArray(string, true); + var k = stringToLongArray(key, false); + if (k.length < 4) { + k.length = 4; + } + var n = v.length - 1; + var z = v[n], + y = v[0]; + var mx, e, p, q = Math.floor(6 + 52 / (n + 1)), + sum = 0; + while (0 < q--) { + sum = sum + delta & 0xffffffff; + e = sum >>> 2 & 3; + for (p = 0; p < n; p++) { + y = v[p + 1]; + mx = (z >>> 5 ^ y << 2) + (y >>> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z); + z = v[p] = v[p] + mx & 0xffffffff; + } + y = v[0]; + mx = (z >>> 5 ^ y << 2) + (y >>> 3 ^ z << 4) ^ (sum ^ y) + (k[p & 3 ^ e] ^ z); + z = v[n] = v[n] + mx & 0xffffffff; + } + return longArrayToString(v, false); + }; + }; + var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + + function encode32(input) { + input = escape(input); + var output = ""; + var chr1, chr2, chr3 = ""; + var enc1, enc2, enc3, enc4 = ""; + var i = 0; + do { + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } + output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); + chr1 = chr2 = chr3 = ""; + enc1 = enc2 = enc3 = enc4 = ""; + } while (i < input.length); + return output; + }; + + var exp = { + encode: function (key, value) { + return encode32(bin216(Base32.encrypt(value, key))); + }, + createEncodeStr: function (key, value) { + //keyVlues[0] + ",-," + encode32(bin216(Base32.encrypt(keyVlues[1], keyVlues[0]))) + ":::" + 'myversion' + ",-," + window.helperVersion + return key + ",-," + exp.encode(key, value) + ":::" + 'myversion' + ",-,undefined"; + } + }; + return exp; +}); diff --git a/Web12306/js/ui/index.js b/Web12306/js/ui/index.js index f5b6abe..0c226f1 100644 --- a/Web12306/js/ui/index.js +++ b/Web12306/js/ui/index.js @@ -227,10 +227,12 @@ if (_.some(cp.passengers, function (p) { return p.passenger_type !== '3'; })) { mp.confirm("确认", "您选择的是学生票,但是添加的联系人并不全是学生,将无法提交订单,确定继续查票吗?", ui_result.load); } else { - ui_result.load(); + //ui_result.load(); + autorefresh.start(); } } else { - ui_result.load(); + //ui_result.load(); + autorefresh.start(); } //track @@ -300,6 +302,26 @@ //服务器加速 require("./ui-dnsspeeding.js"); + //自动查询 + var lastAutoQueryKey; + var autoQuery = function () { + var cp = sessMgr.currentProfile; + if (!cp) + return; + + if (cp.fromCode && cp.toCode && cp.depDate) { + var key = cp.fromCode + cp.toCode + cp.depDate + cp.studentTicket; + if (key !== lastAutoQueryKey) { + lastAutoQueryKey = key; + ui_result.load(); + } + } + }; + sessMgr.on("save", function () { + autoQuery(); + }); + autoQuery(); + //$("#passenger_editor").showModalDialog({ // title: "新增联系人", // buttons: [ diff --git a/Web12306/js/ui/ui-autorefresh.js b/Web12306/js/ui/ui-autorefresh.js index 908fab9..21e0b8a 100644 --- a/Web12306/js/ui/ui-autorefresh.js +++ b/Web12306/js/ui/ui-autorefresh.js @@ -9,6 +9,7 @@ var trainSuggest = require("../otn/trainstationsuggest.js"); var port = require("../platform/extensionPort.js"); var utility = require("../utility.js"); + var onceTransit = require("./ui-oncetrainsitquery.js"); sessMgr.on("sessionChanged", function () { session = sessMgr.current; @@ -130,8 +131,11 @@ query.events.on("processTrains", function (e, d) { isAutoRefreshBlock = false; processTrains(d); - if (inAutoRefresh) + + if (inAutoRefresh) { trainSuggest.setQueryResult(d, refreshCount); + d.showTransit = onceTransit.setQueryResult(d, refreshCount); + } if (!d.noAction) { if (!d.auto && (d.nextTime && inAutoRefresh)) { @@ -169,8 +173,8 @@ that.updateDisplay(); $("#result>table").addClass("auto-refresh"); location.hash = "#result"; - trainSuggest.isSuggestLoopDisabled = false; trainSuggest.clearQueryResultCache(); + onceTransit.clearQueryResultCache(); //track var cp = sessMgr.currentProfile; @@ -223,6 +227,7 @@ sessMgr.currentProfile.depDate = $("#dep_date").val(); //currentSelectedDate = null; trainSuggest.clearQueryResultCache(); + onceTransit.clearQueryResultCache(); $("tr.train-needauto").show(); //隐藏监控 diff --git a/Web12306/js/ui/ui-autosubmitform.js b/Web12306/js/ui/ui-autosubmitform.js index f1c1e04..d5d7d77 100644 --- a/Web12306/js/ui/ui-autosubmitform.js +++ b/Web12306/js/ui/ui-autosubmitform.js @@ -5,6 +5,7 @@ var data = require("../data.js"); var passenger = require("../otn/passenger.js"); var port = require("../platform/extensionPort.js"); + var login = require("./ui-login.js"); require("./widget_modalDialog.js"); @@ -33,6 +34,11 @@ performSearch(); }).fail(function (msg) { mp.showMessagePopup("error", "加载联系人失败:" + msg); + + if (msg.indexOf("登录") !== -1) { + login.showLoginDialog(); + } + uiDlg.removeClass("loading"); }); }; @@ -521,7 +527,7 @@ if (!cp || !cp.dateloop) return; var idx = _.indexOf(cp.dateloop, d); - if (idx == -1) + if (idx === -1) return; cp.dateloop.splice(idx, 1); sessmgr.save(); @@ -558,19 +564,18 @@ isRecommand: function (seat) { return _.indexOf(recommand, seat) != -1; }, getName: data.toSeatTypeName })); - dropDown = container.find("ul"); dropDown.mousedown(function (e) { e.stopPropagation(); e.preventDefault(); }).click(function () { input[0].focus(); - }); + }).append($("
  • ").append($("#opt_seat_first, #opt_seat_tb").show())); }; var initProfile = function () { cp = sessmgr.currentProfile; container.find("span.optional-block").remove(); - dropDown.find(":checkbox").prop("checked", false); + dropDown.find(":checkbox:not([data-profile-key])").prop("checked", false); if (!cp || !cp.selectedSeatType) return; container.append(listTpl({ @@ -606,7 +611,7 @@ return; var idx = _.indexOf(cp.selectedSeatType, code); - if (idx == -1) + if (idx === -1) return; cp.selectedSeatType.splice(idx, 1); @@ -614,7 +619,7 @@ container.find(">span[data-code='" + code + "']").remove(); dropDown.find(":checkbox[value='" + code + "']").prop("checked", false); }; - container.on("change", ":checkbox", function () { + container.on("change", ":checkbox:not([data-profile-key])", function () { if (this.checked) exports.addSeat(this.value); else exports.removeSeat(this.value); diff --git a/Web12306/js/ui/ui-oncetrainsitquery.js b/Web12306/js/ui/ui-oncetrainsitquery.js new file mode 100644 index 0000000..7c02520 --- /dev/null +++ b/Web12306/js/ui/ui-oncetrainsitquery.js @@ -0,0 +1,424 @@ +define(function (require, exports, module) { + var data = require("../data.js"); + var sessmgr = require("../account/sessionMgr.js"); + var query = require("../otn/queryticket.js"); + var utility = require("../utility.js"); + var cachedSuggest = JSON.parse(localStorage['trainTransit'] || '{"key":"", "data":null}'); + var loadTime = 1000; + var mp = require("./widget_message_popup.js"); + + //DOM + var listContainer = $("#oncetrainsit"); + var listTemplate = listContainer.find(">script").doT(); + var listTarget = listContainer.find(">section"); + + var cp = sessmgr.currentProfile; + sessmgr.on("currentProfileChanged", function () { + cp = sessmgr.currentProfile; + }); + + var isInQuery = false; + var startQueryLimit = data.startTrainStationSuggestQueryLimit; + var isSuggestLoopDisabled = false; + var isSuggestReported = false; + + //当前查询结果 + var currentResult = null; + var forceShowSuggestion = false; + var showlevel = 1; + var currentTransit; + var queryQueue, queryKeyQueue; + var queryLoopTimer = null; + var lastLoopKey = null; + + var calculateTimeForCompare = function (trainClass, minutes) { + var rate = 1.0; + switch (trainClass) { + case 'G': + rate = 1.0; + break; + case 'D': + rate = 0.71428; + break; + case 'Z': + rate = 0.45714; + break; + case 'T': + rate = 0.4; + break; + default: + rate = 0.28571; + break; + } + + return Math.floor(rate * minutes); + }; + + var setQueryResult = function (result, queryCount) { + currentResult = result; + var cacheKey = cp.fromCode + cp.toCode + cp.depDate; + if (!isAutoShowTransit()) + return false; + + + if (cachedSuggest.key === cacheKey) { + if (cachedSuggest.data === null) + return true; + + //load result; + isInQuery = true; + + var cdata = _.clone(cachedSuggest.data); + prepareData(cdata); + renderTransitResult(cdata); + } else { + //判断检测等级 + //1-自动检测换乘,要求车次在4趟以下,无始发终到 + //2-不建议换乘,在上述条件以外 + + var url = "http://12306.fishlee.net/tt/tor?date=" + cp.depDate + "&from=" + cp.fromCode + "&to=" + cp.toCode + "&maxAge=" + getCalcBasedTime(); + var dlg = forceShowSuggestion ? mp.showMessagePopup("loading", "查询换乘中,请稍等...") : null; + $.get(url).done(function (resp) { + if (!resp || !resp.ret) { + dlg.setState("error", (resp && resp.msg) || "咱的服务器计算不过来了,请等等服务器..."); + dlg.delayClose(); + isInQuery = false; + return; + } + cachedSuggest.key = cacheKey; + cachedSuggest.data = _.clone(resp.data); + localStorage['trainTransit'] = JSON.stringify(cachedSuggest); + + if (!resp.data) + return; + + prepareData(resp.data); + renderTransitResult(resp.data); + if (dlg) + dlg.close(); + }).fail(function () { + if (dlg) { + dlg.setState("error", "咱的服务器计算不过来了,请等等服务器..."); + dlg.delayClose(); + isInQuery = false; + } + }); + isInQuery = true; + } + + return true; + }; + + var prepareData = function (result) { + //城市 + var corder = result.corder; + var line; + + result.corderName = []; + for (var j = 0; j < corder.length; j++) { + var city = data.cities[corder[j]]; + if (!city) { + corder.splice(j, 1); + j--; + } else { + result.corderName.push(city.n); + } + } + //推荐线路 + result.recommandLines = _.map(result.toplines, function (index) { return result.lines[index]; }); + //线路 + var lines = result.lines; + for (var i = 0; i < lines.length; i++) { + line = lines[i]; + line.first.fromName = data.getCityName(line.first.from); + line.first.toName = data.getCityName(line.first.to); + line.second.fromName = data.getCityName(line.second.from); + line.second.toName = data.getCityName(line.second.to); + + if (!line.second.fromName || !line.second.toName || !line.first.fromName || !line.first.toName) { + lines.splice(i, 1); + i--; + continue; + } + + //时间 + line.first.leftShort = /\s(\d+:\d+)/.exec(line.first.left) && RegExp.$1; + line.first.arriveShort = /\s(\d+:\d+)/.exec(line.first.arrive) && RegExp.$1; + line.first.days = utility.getDaysDifference(line.first.left, line.first.arrive); + line.first.elapsedStr = utility.formatMinutesToShortStr(line.first.elapsed); + + line.second.leftShort = /\s(\d+:\d+)/.exec(line.second.left) && RegExp.$1; + line.second.arriveShort = /\s(\d+:\d+)/.exec(line.second.arrive) && RegExp.$1; + line.second.leftDays = utility.getDaysDifference(line.first.left, line.second.left); + line.second.arriveDays = utility.getDaysDifference(line.first.left, line.second.arrive); + line.second.elapsedStr = utility.formatMinutesToShortStr(line.second.elapsed); + + line.totalTimeStr = utility.formatMinutesToShortStr(line.total); + line.waitTimeStr = utility.formatMinutesToShortStr(line.wait); + } + + //过滤推荐线路 + for (var k = 0; k < result.recommandLines.length; k++) { + line = result.recommandLines[k]; + if (!line.second.fromName || !line.second.toName || !line.first.fromName || !line.first.toName) { + result.recommandLines.splice(k, 1); + k--; + } + } + } + + var renderTransitResult = function (result) { + if (result) { + currentTransit = result; + + if (forceShowSuggestion) { + listContainer.slideDown(); + } + } + + if (showlevel == 1) + currentTransit.showLines = currentTransit.recommandLines; + else if (showlevel == 2) { + currentTransit.showLines = _.where(currentTransit.lines, { ne: false }); + if (!currentTransit.showLines || !currentTransit.showLines.length) + currentTransit.showLines = currentTransit.lines; + } + else currentTransit.showLines = currentTransit.lines; + + var html = listTemplate(currentTransit, { + u: utility, + d: data, + l: showlevel + }); + + listTarget.html(html); + + queryQueue = _.groupBy(_.flatten(_.map(currentTransit.showLines, function (line) { return [line.first, line.second]; })), function (seg) { + seg.key = seg.from + "," + seg.fromName + "," + seg.to + "," + seg.toName + "," + seg.left.split(' ')[0]; + seg.queryData = seg.key.split(','); + seg.queryData.push(false); + seg.queryData.push(false); + seg.queryData.push(true); + seg.queryData.push(true); + seg.queryData.push(false); + seg.target = null; + + return seg.key; + }); + queryKeyQueue = _.keys(queryQueue); + loadTime = 1000; + lastLoopKey = null; + startQueryTimer(); + }; + + var getCalcBasedTime = function () { + var times = _.map(currentResult.original, function (t) { + return calculateTimeForCompare(t.code[0], utility.parseTimeSpanToMinutes(t.elapsedTime.total)); + }); + + return times.length ? (_.max(times) + _.min(times)) / 2 : 999999; + }; + + var isAutoShowTransit = function () { + if (forceShowSuggestion) + return true; + + //无效数据,或车次数大于4 + if (!currentResult || !currentResult.original || currentResult.original.length >= 4) { + return false; + } + //如果存在始发终到车 + if (_.some(currentResult.original, function (x) { + return x.from.endpoint && x.to.endpoint; + })) + return false; + + return true; + }; + + var closeTransitSuggest = function () { + clearQueryTimer(); + isSuggestLoopDisabled = true; + listContainer.slideUp(); + }; + + var clearQueryTimer = function () { + if (!queryLoopTimer) + return; + + clearInterval(queryLoopTimer); + queryLoopTimer = null; + }; + + var startQueryTimer = function () { + if (queryLoopTimer) + return; + + queryLoopTimer = setTimeout(queryLoop, loadTime); + }; + + var queryLoop = function () { + if (!queryKeyQueue || !queryKeyQueue.length) + return; + + var key = queryKeyQueue.shift(); + var trains = queryQueue[key]; + queryKeyQueue.push(key); + lastLoopKey = lastLoopKey || key; + + var date = trains[0].queryData[4]; + var trainCodes = _.groupBy(trains, function (x) { + return x.train.code; + }); + + var processResponse = function (loaded, result) { + queryLoopTimer = null; + + _.each(_.keys(trainCodes), function (code) { + var ele = listTarget.find("tr.ticket-container td[data-date='" + date + "'][data-traincode='" + code + "']"); + ele.empty(); + if (!loaded) { + ele.append("查询发生错误"); + } else if (result.notInSellTime) { + ele.append("当日车次不在预售期"); + //从列表中移除,这个车次之后不用再查了。 + delete queryQueue[key]; + queryKeyQueue.pop(); + } else if (result.selltime) { + ele.append("" + utility.format + ""); + } else { + //显示余票信息 + var train = _.findWhere(result.original, { code: code }); + if (!train) { + //车次不存在,可能是过程中会自动变号的车次 + ele.closest("tr").prevUntil(".header, .ticket-container").andSelf().remove(); + + //从列表中移除 + var args = _.clone(trainCodes[code]); + args.unshift(trains); + queryQueue[key] = _.without.apply(this, args); + + console.log("中转站查询:找不到车次 " + code + ", 查询信息:" + key); + + //从缓存的信息中移除。 + var matchedLines = _.filter(currentTransit.lines, function (line) { + return _.some(trainCodes[code], function (t) { return t === line.first || t === line.second; }); + }); + delete trainCodes[code]; + if (matchedLines && matchedLines.length) { + matchedLines.unshift(currentTransit.lines); + currentTransit.lines = _.without.apply(this, matchedLines); + + matchedLines[0] = currentTransit.recommandLines; + currentTransit.recommandLines = _.without.apply(this, matchedLines); + } + } else if (train.limitSellInfo) { + //限售信息 + ele.append("" + train.limitSellInfo + ""); + delete trainCodes[code]; + } else if (train.selltime) { + ele.append("" + utility.formatSellDate(train.limitSellInfo) + ""); + } else if (train.available < 1) { + ele.append("本车次暂无可售票"); + } else { + _.each(trainCodes[code], function (t) { + t.secureStr = train.secureStr; + t.rtrain = train; + }); + //显示车次车票 + var tickets = []; + _.each(data.seatDisplayOrder, function (seat) { + var seatinfo = train.ticketMap[seat]; + //不显示无票以及没有的席别 + if (!seatinfo || !seatinfo.count) return; + + var selected = cp && $.inArray(seat, cp.selectedSeatType) !== -1; + tickets.push(""); + }); + ele.append(tickets.join("")); + } + } + }); + + if (!_.keys(trainCodes).length && queryQueue[key]) { + //已经没有车次了。。移除 + delete queryQueue[key]; + queryKeyQueue.pop(); + } + } + + query.queryTicket.apply(this, trains[0].queryData) + .done(function () { + processResponse(true, this); + }).fail(function () { + processResponse(false); + }).always(function () { + if (queryKeyQueue[0] === lastLoopKey) { + loadTime = 5000; + + if (listContainer.find("table tr").length > 1) { + listContainer.slideDown(); + queryLoopTimer = setTimeout(queryLoop, loadTime); + } + } else { + queryLoopTimer = setTimeout(queryLoop, loadTime); + } + }); + }; + + listContainer.on("change", "input[name=tt_level]", function () { + showlevel = listContainer.find("input[name=tt_level]:checked").val(); + renderTransitResult(); + }); + listContainer.find(">header>a").click(closeTransitSuggest); + + var ctx = { + setQueryResult: function (result, queryCount) { + if (cp.resign || cp.studentTicket || isSuggestLoopDisabled) + return false; + if ((queryCount < startQueryLimit && !forceShowSuggestion) || isInQuery || isSuggestLoopDisabled) + return isInQuery; + + return setQueryResult(result, queryCount); + }, + clearQueryResultCache: function () { + isSuggestLoopDisabled = false; + isSuggestReported = false; + isInQuery = false; + forceShowSuggestion = false; + clearQueryTimer(); + }, + findTrain: function (secstr) { + var train = _.findWhere(_.flatten(_.map(_.values(currentTransit.lines), function (t) { return [t.first, t.second]; })), { secureStr: secstr }); + return train && train.rtrain; + } + }; + Object.defineProperty(ctx, "isInSuggestQuery", { + get: function () { + return isInQuery; + }, + set: function (value) { + isInQuery = value; + } + }); + Object.defineProperty(ctx, "isSuggestLoopDisabled", + { + get: function () { + return isSuggestLoopDisabled; + }, + set: function (value) { + isSuggestLoopDisabled = value; + } + }); + Object.defineProperty(ctx, "forceTransit", + { + get: function () { + return forceShowSuggestion; + }, + set: function (value) { + forceShowSuggestion = value; + } + }); + + return ctx; +}); diff --git a/Web12306/js/ui/ui-submit-order.js b/Web12306/js/ui/ui-submit-order.js index e39d96c..dd922a6 100644 --- a/Web12306/js/ui/ui-submit-order.js +++ b/Web12306/js/ui/ui-submit-order.js @@ -97,7 +97,7 @@ pPassengers[0].seat, pPassengers.length, pTrain.byAuto ? 1 : 0, - pTrain.suggest ? 1 : 0 + pTrain.suggest || 0 ]); submitBtn[0].disabled = true; @@ -122,7 +122,7 @@ pPassengers[0].seat, pPassengers.length, pTrain.byAuto ? 1 : 0, - pTrain.suggest ? 1 : 0 + pTrain.suggest || 0 ]); }); submitDef.fail(function (data) { @@ -151,7 +151,7 @@ pPassengers[0].seat, pPassengers.length, pTrain.byAuto ? 1 : 0, - pTrain.suggest ? 1 : 0 + pTrain.suggest || 0 ]); }); submitDef.progress(function (data) { diff --git a/Web12306/js/ui/ui-trainlist.js b/Web12306/js/ui/ui-trainlist.js index 2d480e8..416062e 100644 --- a/Web12306/js/ui/ui-trainlist.js +++ b/Web12306/js/ui/ui-trainlist.js @@ -15,6 +15,7 @@ var utility = require("../utility.js"); var port = require("../platform/extensionPort.js"); var media = require("../platform/media.js"); + var transmit = require("./ui-oncetrainsitquery.js"); //引入过滤 require("../otn/trainfilter.js").init(); @@ -39,7 +40,8 @@ $("#result").html(tpl(data, { param: param, parser: parser, - utility: utility + utility: utility, + cp: sessMgr.currentProfile })); }; this.resetStatus = function () { @@ -165,17 +167,20 @@ __.load(); }); //监听订票请求 - $(document).on("click", "a.ticket-block", function () { + $(document).on("click", ".ticket-block, .btn-ticket-block", function() { var id = this.dataset.traincode; var seatcode = this.dataset.seatcode; var train; var cp = sessMgr.currentProfile; - var bySuggest = false; if (this.dataset.suggest) { train = trainSuggest.findTrain(this.dataset.sec); - train.suggest = true; - bySuggest = true; + train.suggest = 1; + } else if (this.dataset.transmit) { + train = transmit.findTrain(this.dataset.sec); + if (!train) + return; + train.suggest = 2; } else { train = _.findWhere(queryResult.original, { id: id }); } @@ -188,9 +193,9 @@ var pas = _.first(cp.passengers || [], pcount); seatcode = seatcode === "0" ? (train.ticketMap['1'] ? "1" : "O") : seatcode; - pas.forEach(function (p) { p.seat = seatcode; }); + pas.forEach(function(p) { p.seat = seatcode; }); if (cp.submitStuAsCommon && !cp.studentTicket) { - pas.forEach(function (p) { if (p.passenger_type == "3") p.passenger_type = "1"; }); + pas.forEach(function(p) { if (p.passenger_type == "3") p.passenger_type = "1"; }); } train.byAuto = true; __.dispatchEvent("requireSubmitOrder", { @@ -209,6 +214,10 @@ // ]); //} + }).on("click", "#btn_start_transit", function () { + transmit.clearQueryResultCache(); + transmit.forceTransit = true; + transmit.setQueryResult(queryResult); }); }; init(); diff --git a/Web12306/js/ui/widget_datebar.js b/Web12306/js/ui/widget_datebar.js index 76c103f..aef2e25 100644 --- a/Web12306/js/ui/widget_datebar.js +++ b/Web12306/js/ui/widget_datebar.js @@ -30,7 +30,7 @@ var that = this; var today = utility.addDays(new Date(), 0); var date = null; - var maxdays = utility.addDays(today, 30); + var maxdays = utility.maxDate; var currentHightDate = today; ev.apply(this); diff --git a/Web12306/js/ui/widget_datedropdown.js b/Web12306/js/ui/widget_datedropdown.js index 9a082a6..0598ce8 100644 --- a/Web12306/js/ui/widget_datedropdown.js +++ b/Web12306/js/ui/widget_datedropdown.js @@ -32,7 +32,11 @@ var cell = cells.eq(i); cell.html(dateTmp.getDate()); cell.removeClass(); - if (dateTmp.getMonth() !== thismonth || dateTmp.getTime() < minTime) { + + if (dateTmp.getMonth() === thismonth) { + cell.addClass("date-thismonth"); + } + if (/*dateTmp.getMonth() !== thismonth || */dateTmp.getTime() < minTime) { cell.addClass("date-notavailable"); }else if (dateTmp.getTime() === currentDate.getTime()) { cell.addClass("date-current"); diff --git a/Web12306/js/utility.js b/Web12306/js/utility.js index 6cea298..dc1c5ff 100644 --- a/Web12306/js/utility.js +++ b/Web12306/js/utility.js @@ -5,9 +5,7 @@ d = new Date(d + ''); } - var x = new Date(); - x.setTime(d.getTime() - d.getTime() % (1000 * 3600 * 24)); - return x; + return new Date(d.getFullYear(), d.getMonth(), d.getDate()); }; //exports.addDays = function (date, days) { // var x = new Date(); @@ -22,7 +20,6 @@ date = exports.toDate(date); return new Date(date.getFullYear(), date.getMonth() + offset, date.getDate()); }; - exports.toDate = function (date) { if (date instanceof Date) return date; @@ -77,10 +74,7 @@ exports.getDaysDifference = function (date1, date2) { /// 获得date1到date2之间隔了多少天 - var time1 = Math.floor(exports.toDate(date1).getTime() / 1000 / 60 / 60 / 24); - var time2 = Math.floor(exports.toDate(date2).getTime() / 1000 / 60 / 60 / 24); - - return time2 - time1; + return Math.floor((exports.trimToDay(exports.toDate(date2)).getTime()-exports.trimToDay(exports.toDate(date1)).getTime()) / 1000 / 60 / 60 / 24); } exports.format24hTo12h = function (str) { /// 将24小时制式时间转换为12小时制式 @@ -130,7 +124,19 @@ exports.getVcValidate = function (vc) { return vc + " " + new Date().toLocaleDateString() + " keyup " + JSON.stringify({ keyCode: vc.charCodeAt(vc.length - 1) }); }; + exports.parseTimeSpanToMinutes = function (value) { + /// 将“小时:分钟”格式的时间标签转换为分钟 + return /0*(\d+)\s*:\s*0*(\d+)/.exec(value) ? (parseInt(RegExp.$1, 10) * 60 + parseInt(RegExp.$2)) : 0; + }; + exports.formatMinutesToShortStr = function (minutes) { + /// 将分钟格式化为时间字符串 + var days = Math.floor(minutes / 1440); + var hours = Math.floor(minutes % 1440 / 60); + minutes = minutes % 60; + + return (days > 0 ? days + "天" : "") + (hours > 0 ? hours + "小时" : "") + (minutes > 0 ? minutes + "分钟" : ""); + }; $.fn.toBase64Data = function () { var arr = []; this.each(function () { diff --git a/build.cmd b/build.cmd index 378b318..d51b389 100644 --- a/build.cmd +++ b/build.cmd @@ -20,16 +20,16 @@ rem copy tools\onInstall_openWelcome.js deploy\air\js\background\onInstall.js /Y rem "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "--pack-extension=%~dp0deploy" "--pack-extension-key=%~dp0src_lb.pem" rem ren deploy.crx 12306Ʊ(Աר)_򿪻ӭҳ.crx -BuildTools\SourceFileUtility.exe deploy\manifest.json ", ""infobars""" ", ""experimental""" -BuildTools\SourceFileUtility.exe deploy\manifest.json ".1""," ".0""," -"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "--pack-extension=%~dp0deploy" "--pack-extension-key=%~dp0src_lb.pem" -ren deploy.crx 12306Ʊ(Աר)_B29.crx +rem BuildTools\SourceFileUtility.exe deploy\manifest.json ", ""infobars""" ", ""experimental""" +rem BuildTools\SourceFileUtility.exe deploy\manifest.json ".1""," ".0""," +rem "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "--pack-extension=%~dp0deploy" "--pack-extension-key=%~dp0src_lb.pem" +rem ren deploy.crx 12306Ʊ(Աר)_B29.crx -BuildTools\SourceFileUtility.exe deploy\manifest.json ", ""experimental""" "" -BuildTools\SourceFileUtility.exe deploy\manifest.json "44/44/update_lb.xml" "44/44/update_chrome.xml" -"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "--pack-extension=%~dp0deploy" "--pack-extension-key=%~dp0src_lb.pem" -ren deploy.crx 12306Ʊ_Chrome.crx +rem BuildTools\SourceFileUtility.exe deploy\manifest.json ", ""experimental""" "" +rem BuildTools\SourceFileUtility.exe deploy\manifest.json "44/44/update_lb.xml" "44/44/update_chrome.xml" +rem "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "--pack-extension=%~dp0deploy" "--pack-extension-key=%~dp0src_lb.pem" +rem ren deploy.crx 12306Ʊ_Chrome.crx rem experimental