96 lines
3.5 KiB
JavaScript
Executable File
96 lines
3.5 KiB
JavaScript
Executable File
$(document).ready(function () {
|
|
setTimeout(function () {
|
|
ADis_Check_Call_Active();
|
|
}, 500);
|
|
});
|
|
|
|
function ADis_Check_Call_Active() {
|
|
if ($("h4:contains('Eigene Krankenhäuser')").length > 0 || $("h4:contains('Verbandskrankenhäuser')").length > 0) {
|
|
ADis_Collect_Hospitals();
|
|
}
|
|
}
|
|
|
|
// Krankenhaus auswählen
|
|
function ADis_Collect_Hospitals() {
|
|
if ($("h4:contains('Eigene Krankenhäuser')").length > 0) {
|
|
$("h4:contains('Eigene Krankenhäuser')").next("table").find("tbody").find("tr").each(function () {
|
|
var HospitalHref = $(this).find("a:contains('Anfahren')").attr("href");
|
|
var HospitalID = Number(parseInt($(this).find("a:contains('Anfahren')").attr("id").replace("btn_approach_", "")));
|
|
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
|
var HospitalFreeBeds = parseInt($(this).find("td").eq("2").text());
|
|
|
|
var HospitalValue = HospitalDistance * 450 * -1;
|
|
HospitalValue += 2000; // Own Hospitals are better :-)
|
|
if ($(this).find(".label:contains('Ja')").length > 0) {
|
|
HospitalValue += 2000;
|
|
}
|
|
|
|
if (HospitalFreeBeds > 0) {
|
|
Hospitals.push({
|
|
"id": HospitalID,
|
|
"value": HospitalValue,
|
|
"distance": HospitalDistance,
|
|
"href": HospitalHref
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
if ($("h4:contains('Verbandskrankenhäuser')").length > 0) {
|
|
$("h4:contains('Verbandskrankenhäuser')").next("table").find("tbody").find("tr").each(function () {
|
|
var HospitalHref = $(this).find("a").attr("href")
|
|
var HospitalID = Number(parseInt(HospitalHref.substr(HospitalHref.lastIndexOf("/") + 1)));
|
|
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
|
var HospitalFreeBeds = parseInt($(this).find("td").eq("2").text());
|
|
var HospitalTaxes = parseInt($(this).find("td").eq("3").text());
|
|
var HospitalSpecialDepartment = false;
|
|
|
|
// Add Button-ID to Alliance-Hospital
|
|
$(this).find("a").attr("id", "btn_approach_" + HospitalID.toString());
|
|
|
|
var HospitalValue = HospitalDistance * 450 * -1;
|
|
|
|
if ($(this).find(".label:contains('Ja')").length > 0) {
|
|
HospitalSpecialDepartment = true;
|
|
HospitalValue += 2000;
|
|
}
|
|
|
|
if (HospitalTaxes == 0) {
|
|
HospitalValue += 2000;
|
|
} else if (HospitalTaxes > 0 && HospitalTaxes <= 10) {
|
|
HospitalValue += 1000;
|
|
} else if (HospitalTaxes > 10 && HospitalTaxes <= 20) {
|
|
HospitalValue += 0;
|
|
} else {
|
|
HospitalValue -= 5000;
|
|
}
|
|
|
|
if (HospitalFreeBeds > 0 && HospitalSpecialDepartment) {
|
|
Hospitals.push({
|
|
"id": HospitalID,
|
|
"value": HospitalValue,
|
|
"taxes": HospitalTaxes,
|
|
"distance": HospitalDistance,
|
|
"href": HospitalHref
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
Hospitals.sort(function (a, b) {
|
|
return a.value - b.value;
|
|
});
|
|
|
|
Hospitals.reverse();
|
|
ADis_Send_Vehicle_To_Hospital()
|
|
}
|
|
|
|
// Krankenhaus einlieferung
|
|
function ADis_Send_Vehicle_To_Hospital() {
|
|
//var HospitalID = Hospitals[0].id;
|
|
var HospitalHref = Hospitals[0].href;
|
|
|
|
// TODO: tellParent("ADisMissionDone(" + window.name + "," + MissionID + ");");
|
|
document.location.href = document.location.origin + HospitalHref;
|
|
|
|
} |