-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubmithelper.js
113 lines (95 loc) · 3.53 KB
/
submithelper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*+ hidden data generator*/
// serialize all passenger information into a single string
function generatePassengerData(id) {
var value = $("#" + id + "_seat").val();
/* We default use not save contacts, so just skip this
if ($("#" + id + "_isSave")[0].checked) {
//不改签的不用验证"改签时,必须选择相同席别"
_seat_codes.push( $("#" + id + "_seat").val());
}
*/
//some fancy information
value += "," + $("#" + id + "_ticket").val(); //ticket count
value += "," + $("#" + id + "_name").val(); //passenger name
value += "," + $("#" + id + "_cardtype").val(); //passenger id card type
value += "," + $("#" + id + "_cardno").val(); //passenger id card number (ID)
value += "," + $("#" + id + "_mobileno").val(); //phone
//check if save person info for future use, I think 'N' will save some time for server
value += ",N";
/* original code: get from form
if ($("#" + id + "_isSave")[0].checked) {
value += "," + $("#" + id + "_isSave").val();
} else {
value += ",N";
}
*/
$("#" + id + "_p").val(value);
}
//Fill some god damn hidden areas
function toPassengerStringSplit(passenger) {
var pValue = passenger.passenger_name + ","
+ passenger.passenger_id_type_code + ","
+ passenger.passenger_id_no;
return pValue;
};
//it seems this hidden field is for back-capbility, we provide it either
function generateOldPassengerData(id) {
var passenger = $("#" + id).data("passenger");
if (passenger) {
$("#" + id + "_old").val(toPassengerStringSplit(passenger));
}
}
function generateHiddenDataForPassenger(id){
generatePassengerData(id);
generateOldPassengerData(id);
}
/*- hidden data generator*/
//there are some hidden areas needs to be fixed, e.g. #seat_type_code
function quickSubmitOrder()
{
$(".passenger_class").each(function() {
var id = $(this).attr("id");
generateHiddenDataForPassenger(id);
});
$("#confirmPassenger").target = "_self";
$("#confirmPassenger").submit();
}
//add the on-board-date by 1, this may be useful for rob the ticket by a accurate clock
//param add is the number of days you want to add
//this will modify all visible and hidden field of the order form
function incOrderDate(add)
{
alert ("This is not ready!!!");
}
//$("input:checkbox", $("#showPassengerFilter")).click();
var buttonStyle="height: 30px; background: none; background-color: #9EF; border: 4px solid #BBB; line-height: 22px; font-size: 14px; padding-left:3px; padding-right:3px; margin-right: 10px; cursor:pointer;";
$("<div/>").attr("style", "margin-right:20px; height:30px; padding:4px; float:right; width:500px; background-color:#EF9").append(
$("<button/>", {text:"Quick Submit", style: buttonStyle}).click(function(){
quickSubmitOrder();
})
).append(
$("<button/>", {text: "Hack: Order Next Day", style:buttonStyle}).click(function(){
incOrderDate(1);
quickSubmitOrder();
})
).appendTo( $("#rand").parent() );
function refreshCapachaImage() {
$("#img_rrand_code").attr("src","/otsweb/passCodeAction.do?rand=randp"+'&'+Math.random());
}
$("#rand").keydown(function (keyevent) {
if (keyevent.keyCode == 13) {
var randCode = $("#rand").val();
if (randCode && randCode.length == 4) {
quickSubmitOrder();
} else {
//refresh random code
console.log ("refresh random code when input is empty");
refreshCapachaImage();
}
return false;
}
});
$("#img_rrand_code").attr("src", chrome.extension.getURL("loading.gif"));
window.setTimeout(refreshCapachaImage, 1);
$("#rand").val("");
$("#rand").focus();