-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfirmpage.js
80 lines (67 loc) · 1.85 KB
/
confirmpage.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
var _leaf_prevRandCodeVal;
var _leaf_passengerInfo = [];
var _leaf_inputFieldIds = ['passenger_name',
'passenger_id_type',
'passenger_id_no',
'phone_no',
];
function _leaf_inputFieldById(idx, filedidx)
{
return '#' + _leaf_inputFieldIds[filedidx] + '_' + idx;
}
function _leaf_collectPassengerInfo()
{
var i = 0;
var new_passengerInfo = [];
while(true){
i = i + 1;
if (! $(_leaf_inputFieldById(i, 0)).length) break;
var passengerRow = [];
for (var j = 0; j < 4; ++j) {
passengerRow[j] = $(_leaf_inputFieldById(i, j)).val();
}
new_passengerInfo[i - 1] = passengerRow;
}
_leaf_passengerInfo = new_passengerInfo;
chrome.extension.sendRequest({what:"savePassengers", passengers: JSON.stringify(_leaf_passengerInfo)}, function() {
//do nothing;
});
}
function _leaf_loadPassengerInfo()
{
chrome.extension.sendRequest({what:'passengers'}, function(resp) {
var passList = JSON.parse(resp.passengers);
for (var i = 1; i <= passList.length; ++i) {
if (i > 1) {
$('div.add-per span').click();
}
var passItem = passList[i - 1];
for (var j = 0; j < passItem.length; ++j) {
var targetInput = $(_leaf_inputFieldById(i, j));
targetInput.val(passItem[j]);
}
}
});
}
function pagehack()
{
var randCodeInput = $("#randCode");
randCodeInput.focus();
var randimg = $("#img_rand_code");
randimg.css("margin-top", "-40px");
randimg.css("margin-left", "163px");
randimg.css("height", "80px");
randimg.css("width", "300px");
injectJs('inject/confirm_pagehack.js');
$("#randCode").keyup( function (an) {
an = an || window.event;
if ($("#randCode").val().length == 4 && _leaf_prevRandCodeVal != $("#randCode").val()) {
_leaf_prevRandCodeVal = $("#randCode").val()
_leaf_collectPassengerInfo();
return;
}
_leaf_prevRandCodeVal = $("#randCode").val()
});
_leaf_loadPassengerInfo();
}
pagehack();