|
|
|
@ -17,7 +17,7 @@ function getMediaURL(path) {
|
|
|
|
|
* they will also be cleaned up and returned as undefined, because we can't link to them correctly
|
|
|
|
|
*/
|
|
|
|
|
function bahnParseTrainName(dirty_train_name) {
|
|
|
|
|
var name_list = dirty_train_name.split(" ");
|
|
|
|
|
var name_list = dirty_train_name.trim().replace(/ +/g, ' ').split(" ");
|
|
|
|
|
|
|
|
|
|
// Train 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) == ')') {
|
|
|
|
@ -32,35 +32,67 @@ function bahnParseTrainName(dirty_train_name) {
|
|
|
|
|
return dirty_train_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var observer = new MutationObserver((mutations, observer) => {
|
|
|
|
|
mutations.forEach((mutation) => {
|
|
|
|
|
if (mutation.type === 'childList') {
|
|
|
|
|
var target = mutation.target;
|
|
|
|
|
if (target.tagName === 'TD') {
|
|
|
|
|
var timetable = target.querySelector("td div.detailContainer table.result tbody");
|
|
|
|
|
var products = timetable.querySelectorAll("tr.first td.products");
|
|
|
|
|
products.forEach((product) => {
|
|
|
|
|
var train_name = bahnParseTrainName(product.querySelector("span a").innerText);
|
|
|
|
|
if(typeof train_name !== 'undefined') {
|
|
|
|
|
product.innerHTML = product.innerHTML + ' <a href="https://marudor.de/details/' + train_name + '" target="_blank"><img src="' + getMediaURL("marudor.svg") + '" style="height: 2em; vertical-align:middle;"></a>';
|
|
|
|
|
function domCreateLink(href) {
|
|
|
|
|
var link = document.createElement("a");
|
|
|
|
|
link.setAttribute("href", href);
|
|
|
|
|
return link;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function domCreateImage(src) {
|
|
|
|
|
var image = document.createElement("img");
|
|
|
|
|
image.setAttribute("src", src);
|
|
|
|
|
return image;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function domCreateButton(href, image_src) {
|
|
|
|
|
var link = domCreateLink(href);
|
|
|
|
|
var image = domCreateImage(image_src);
|
|
|
|
|
image.setAttribute("style", "height: 2em; vertical-align:middle;")
|
|
|
|
|
link.append(image);
|
|
|
|
|
return link;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function domCreateButtonMarudor(path) {
|
|
|
|
|
var button = domCreateButton("https://marudor.de" + path, getMediaURL("marudor.svg"));
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var connection_result_observer = new MutationObserver((mutations) => {
|
|
|
|
|
mutations.forEach((mutation) => {
|
|
|
|
|
if (mutation.type === 'childList') {
|
|
|
|
|
var target = mutation.target;
|
|
|
|
|
if (target.tagName === 'TD') {
|
|
|
|
|
var timetable = target.querySelector("td div.detailContainer table.result tbody");
|
|
|
|
|
|
|
|
|
|
var trains = timetable.querySelectorAll("tr.first td.products");
|
|
|
|
|
trains.forEach((train) => {
|
|
|
|
|
var train_names = train.querySelectorAll("span a");
|
|
|
|
|
train_names.forEach((train_name) => {
|
|
|
|
|
train_name_text = bahnParseTrainName(train_name.innerText);
|
|
|
|
|
if(typeof train_name_text !== 'undefined') {
|
|
|
|
|
var marudor_button = domCreateButtonMarudor("/details/" + train_name_text);
|
|
|
|
|
train_name.after(marudor_button);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
var stations = timetable.querySelectorAll("tr td.station");
|
|
|
|
|
stations.forEach((station) => {
|
|
|
|
|
var station_name = station.innerText;
|
|
|
|
|
station.innerHTML = station.innerHTML + ' <a href="https://marudor.de/' + station_name + '" target="_blank"><img src="' + getMediaURL("marudor.svg") + '" style="height: 2em; vertical-align:middle;"></a>';
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var stations = timetable.querySelectorAll("tr td.station");
|
|
|
|
|
stations.forEach((station) => {
|
|
|
|
|
var station_name = station.innerText;
|
|
|
|
|
var marudor_button = domCreateButtonMarudor("/" + station_name);
|
|
|
|
|
station.append(marudor_button);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var target = document.getElementById('resultsOverview');
|
|
|
|
|
|
|
|
|
|
if(typeof target !== 'undefined') {
|
|
|
|
|
observer.observe(target, {
|
|
|
|
|
connection_result_observer.observe(target, {
|
|
|
|
|
subtree: true,
|
|
|
|
|
childList: true
|
|
|
|
|
});
|
|
|
|
|