Comment data collection section
This commit is contained in:
parent
60c24d8a5e
commit
b6f6f65c63
@ -105,12 +105,15 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
|||||||
data[i]["from"] = {}
|
data[i]["from"] = {}
|
||||||
data[i]["to"] = {}
|
data[i]["to"] = {}
|
||||||
|
|
||||||
|
// Depature station name
|
||||||
var relation_from = relation.querySelector("td.station");
|
var relation_from = relation.querySelector("td.station");
|
||||||
data[i]["from"]["station"] = relation_from.innerText;
|
data[i]["from"]["station"] = relation_from.innerText;
|
||||||
|
|
||||||
|
// Arrival station name
|
||||||
var relation_to = relationend.querySelector("td.station");
|
var relation_to = relationend.querySelector("td.station");
|
||||||
data[i]["to"]["station"] = relation_to.innerText;
|
data[i]["to"]["station"] = relation_to.innerText;
|
||||||
|
|
||||||
|
// Departure time & current estimation
|
||||||
var relation_departure = relation.querySelector("td.time");
|
var relation_departure = relation.querySelector("td.time");
|
||||||
var relation_departure_list = relation_departure.firstChild.textContent.trim().split(" ");
|
var relation_departure_list = relation_departure.firstChild.textContent.trim().split(" ");
|
||||||
data[i]["from"]["time"] = relation_departure_list[1];
|
data[i]["from"]["time"] = relation_departure_list[1];
|
||||||
@ -120,6 +123,7 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
|||||||
data[i]["from"]["time_current"] = relation_departure_current.innerText.trim();
|
data[i]["from"]["time_current"] = relation_departure_current.innerText.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Arrival time & current estimation
|
||||||
var relation_arrival = relationend.querySelector("td.time");
|
var relation_arrival = relationend.querySelector("td.time");
|
||||||
var relation_arrival_list = relation_arrival.firstChild.textContent.trim().split(" ");
|
var relation_arrival_list = relation_arrival.firstChild.textContent.trim().split(" ");
|
||||||
data[i]["to"]["time"] = relation_arrival_list[1];
|
data[i]["to"]["time"] = relation_arrival_list[1];
|
||||||
@ -129,36 +133,44 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
|||||||
data[i]["to"]["time_current"] = relation_arrival_current.innerText.trim();
|
data[i]["to"]["time_current"] = relation_arrival_current.innerText.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Departure platform
|
||||||
var relation_platform = relation.querySelector("td.platform");
|
var relation_platform = relation.querySelector("td.platform");
|
||||||
data[i]["from"]["platform"] = relation_platform.innerText;
|
data[i]["from"]["platform"] = relation_platform.innerText;
|
||||||
|
|
||||||
|
// Arrival platform
|
||||||
var relation_to_platform = relationend.querySelector("td.platform");
|
var relation_to_platform = relationend.querySelector("td.platform");
|
||||||
data[i]["to"]["platform"] = relation_to_platform.innerText;
|
data[i]["to"]["platform"] = relation_to_platform.innerText;
|
||||||
|
|
||||||
|
// Travel products
|
||||||
var relation_products = relation.querySelector("td.products");
|
var relation_products = relation.querySelector("td.products");
|
||||||
data[i]["products"] = [];
|
data[i]["products"] = [];
|
||||||
|
|
||||||
|
// Fetch all products for this travel
|
||||||
var relation_trains = relation_products.querySelectorAll("span a");
|
var relation_trains = relation_products.querySelectorAll("span a");
|
||||||
relation_trains.forEach((train, j) => {
|
relation_trains.forEach((train, j) => {
|
||||||
data[i]["products"][j] = {};
|
data[i]["products"][j] = {};
|
||||||
|
|
||||||
|
// Prodcut details
|
||||||
data[i]["products"][j]["product"] = null;
|
data[i]["products"][j]["product"] = null;
|
||||||
data[i]["products"][j]["train_number"] = null;
|
data[i]["products"][j]["train_number"] = null;
|
||||||
data[i]["products"][j]["line_name"] = null;
|
data[i]["products"][j]["line_name"] = null;
|
||||||
|
|
||||||
var name_list = train.innerText.trim().replace(/ +/g, ' ').split(" ");
|
var name_list = train.innerText.trim().replace(/ +/g, ' ').split(" ");
|
||||||
|
|
||||||
// Train name in format "STB 12 (23561)"
|
// Product name in format "STB 12 (23561)"
|
||||||
if(name_list.length == 3 && name_list[2].charAt(0) == '(' && name_list[2].charAt(name_list[2].length-1) == ')') {
|
if(name_list.length == 3 && name_list[2].charAt(0) == '(' && name_list[2].charAt(name_list[2].length-1) == ')') {
|
||||||
data[i]["products"][j]["product"] = name_list[0];
|
data[i]["products"][j]["product"] = name_list[0];
|
||||||
data[i]["products"][j]["train_number"] = name_list[0] + " " + name_list[2].substring(1, name_list[2].length-1);
|
data[i]["products"][j]["train_number"] = name_list[0] + " " + name_list[2].substring(1, name_list[2].length-1);
|
||||||
data[i]["products"][j]["line_name"] = name_list[0] + " " + name_list[1];
|
data[i]["products"][j]["line_name"] = name_list[0] + " " + name_list[1];
|
||||||
}
|
}
|
||||||
|
// Product name in format "ICE 234"
|
||||||
else {
|
else {
|
||||||
data[i]["products"][j]["product"] = name_list[0];
|
data[i]["products"][j]["product"] = name_list[0];
|
||||||
data[i]["products"][j]["train_number"] = name_list[0] + " " + name_list[1];
|
data[i]["products"][j]["train_number"] = name_list[0] + " " + name_list[1];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Travel information
|
||||||
var relation_items = relation.querySelectorAll("td");
|
var relation_items = relation.querySelectorAll("td");
|
||||||
var relation_info = relation_items[relation_items.length-1];
|
var relation_info = relation_items[relation_items.length-1];
|
||||||
data[i]["info"] = relation_info.innerText;
|
data[i]["info"] = relation_info.innerText;
|
||||||
|
Loading…
Reference in New Issue
Block a user