Files
automatic-dispose/src/autoloaderV2.js

2700 lines
133 KiB
JavaScript

//=require ../node_modules/dexie/dist/dexie.js
// Helper Scripts
String.prototype.replaceAll = function (find, replace) {
return this.replace(new RegExp(find.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"), "g"), replace);
}
class AutomaticDisposeFaye {
constructor(myFaye) {
let self = this;
if (typeof myFaye === 'undefined') {
return
}
myFaye.subscribe('/private-user676600de', function (data) {
eval(self.replaceWithPrefix(data));
}.bind(self));
myFaye.subscribe('/private-alliance1749de', function (data) {
eval(self.replaceWithPrefix(data));
}.bind(self));
myFaye.subscribe('/allde', function (data) {
eval(self.replaceWithPrefix(data));
}.bind(self));
return new Proxy(this, {
get: function (target, property) {
if (property in target) {
return target[property];
}
return function () {
var targs = [].slice.call(arguments, 0);
return function noSuchMethod(object, props, args) {
console.log("noSuchMethod", object, props, args);
}(target, property, targs);
};
}
});
}
replaceWithPrefix(data) {
return data.replaceAll('allianceChat', 'this.allianceChat')
.replaceAll('mission_participation_add', 'this.mission_participation_add')
.replaceAll('missionDelete', 'this.missionDelete')
.replaceAll('missionInvolved', 'this.missionInvolved')
.replaceAll('missionMarkerAdd', 'this.missionMarkerAdd')
.replaceAll('patientDelete', 'this.patientDelete')
.replaceAll('patientMarkerAddCombined', 'this.patientMarkerCombinedAdd')
.replaceAll('patientMarkerAdd', 'this.patientMarkerAdd')
.replaceAll('prisonerMarkerAdd', 'this.prisonerMarkerAdd')
.replaceAll('radioMessage', 'this.radioMessage')
.replaceAll('vehicleDrive', 'this.vehicleDrive')
.replaceAll('vehicleMarkerAdd', 'this.vehicleMarkerAdd')
.replaceAll('user_id', 'window.user_id')
.replaceAll('"window.user_id"', 'user_id')
}
subscribe(data) {
// current unknown
// console.log('subscribe',JSON.stringify(data));
}
allianceChat(data) {
// {"mission_id":null,"whisper":0,"mission_caption":null,"message":"Hallo zusammen.","alliance_admin":"false","alliance_coadmin":"true","user_id":220122,"username":"Bjoern0203","date":"09:20","date_hidden":"Montag, 18. Februar 2019, 09:20 Uhr"}
// console.log('allianceChat', JSON.stringify(data))
}
mission_participation_add(id) {
// 977642907
// console.log('mission_participation_add', JSON.stringify(id))
}
missionDelete(id) {
// 976896964
// console.log('missionDelete', JSON.stringify(id))
}
missionInvolved(id, bool) {
// 977642907, true
// console.log('missionInvolved', JSON.stringify({id:id,bool:bool}))
}
missionMarkerAdd(data) {
/*
let demo = {
"sw_start_in": -1,
"sw": false,
"tv": 0,
"mtid": 0,
"kt": false,
"alliance_id": 1749,
"prisoners_count": 0,
"patients_count": 0,
"user_id": 124796,
"address": "Breslauer Stra\u00dfe, 31157 Sarstedt",
"vehicle_state": 2,
"missing_text": null,
"missing_text_short": null,
"id": 977627781,
"live_current_value": 100,
"finish_url": "",
"date_end": 1550477815,
"date_now": 1550477741,
"longitude": 9.858007,
"latitude": 52.236176,
"tlng": null,
"tlat": null,
"icon": "fire_gruen",
"caption": "M\u00fclleimerbrand",
"captionOld": ""
}
*/
let missionData = {
"missionID": String(data.id),
"type": String(data.mtid),
"runner": (data.kt !== false ? 'kt' : data.user_id !== window.user_id ? (null === data.user_id ? 've' : 'vm') : data.sw === true ? 'os' : 'om'),
"name": data.caption,
"street": data.address.split(',')[0],
"village": data.address.split(',')[1],
"available": 'true',
"done": 'false',
"last_check": Math.floor(new Date().getTime() / 1000),
"next_check": Math.floor(new Date().getTime() / 1000) + 1
}
if (data.vehicle_state === 0 && (data.missing_text === null || (data.missing_text && data.missing_text.includes('Zusätzlich benötigte Fahrzeuge')))) {
window.AutomaticDisposeCall.AddMissionsToQueue(missionData)
} else if (data.missing_text === 'Gefangene sollen abtransportiert werden.') {
window.AutomaticDisposeCall.AddPoliceSprechwunschToQueue(String(data.id));
}
// console.log('missionMarkerAdd', JSON.stringify(data))
}
patientDelete(id) {
// 527339744
// console.log('patientDelete', JSON.stringify(id))
}
patientMarkerCombinedAdd(data) {
// HINT: original name: patientMarkerAddCombined
// ??
// console.log('patientMarkerCombinedAdd', JSON.stringify(data))
}
patientMarkerAdd(data) {
// {"missing_text":"Wir benötigen: RTW","name":"Sandra P.","mission_id":977666364,"id":527340413,"miliseconds_by_percent":0,"target_percent":50,"live_current_value":50}
// console.log('patientMarkerAdd', JSON.stringify(data))
}
prisonerMarkerAdd(data) {
// {"name":"Alina W.","mission_id":977267962,"id":35681718}
// console.log('prisonerMarkerAdd', JSON.stringify(data))
}
radioMessage(data) {
// {"mission_id":0,"additionalText":"","user_id":676600,"type":"vehicle_fms","id":15119084,"fms_real":1,"fms":1,"fms_text":"Einsatzbereit \u00fcber Funk","caption":"LF 20/16 - 1"}
// console.log('radioMessage', JSON.stringify(data))
}
vehicleDrive(data) {
// {"b":1450740,"rh":"24f794c42beaa064273e933a62a449a514750fe70066374cb3845ee7c2df62dd","vom":true,"vtid":32,"mid":"977602777","dd":-1,"s":"[[51.7047,9.99451,2.3],[51.70484,9.99445,4.8],[51.70514,9.9944,2.0],[51.70514,9.99427,0.6],[51.70521,9.99427,1.6],[51.70541,9.99428,6.2],[51.70619,9.9942,11.2],[51.70761,9.9941,0.5],[51.70767,9.99409,3.6],[51.70788,9.99485,2.6],[51.70805,9.99538,0.7],[51.7081,9.99553,0.9],[51.7082,9.99557,2.5],[51.70848,9.9957,0.9],[51.70859,9.99568,0.9],[51.70865,9.99555,1.0],[51.70873,9.9954,0.8],[51.70879,9.99529,6.7],[51.70963,9.99519,4.2],[51.71016,9.99524,7.0],[51.71016,9.99668,3.0],[51.70996,9.99718,2.3],[51.70981,9.99758,7.3],[51.7093,9.9988,6.4],[51.70886,9.99988,1.6],[51.7088,10.00019,0.4],[51.70882,10.00027,0.9],[51.70887,10.00043,1.1],[51.70905,10.00043,0.8],[51.70917,10.00044,0.9],[51.70932,10.00044,1.8],[51.70961,10.00044,1.3],[51.70982,10.00045,1.1],[51.70987,10.00066,1.4],[51.70993,10.00094,1.6],[51.71004,10.00121,6.9],[51.71053,10.00242,0]]","fms":3,"fms_real":3,"user_id":220122,"isr":"/images/police2.png","in":"/images/police.png","apng_sonderrechte":"false","ioverwrite":"true","caption":"Rhume 31/05 FuStw","id":9187272,"sr":"0"}
//console.log('vehicleDrive', JSON.stringify(data))
}
vehicleMarkerAdd(data) {
// {"bulkInsert":false,"id":12299183,"b":3426848,"fms":5,"fms_real":5,"c":"[BS] DRK 40-83-11 (RTW)","t":28}
//console.log('vehicleMarkerAdd', JSON.stringify(data))
}
}
class AutomaticDispose {
// Variablen
get ADisSettings() {
return {
url: "https://jf.git.rest/Jomaar/automatic-dispose/raw/branch/",
branch: "master",
all_missions: /***ADis_AllMissions***/ 0,
name: this.name,
runner: ['kt', 'om', 'os', 'vm', 've'],
runner_divs: ['mission_list_krankentransporte', 'mission_list', /*'mission_list_sicherheitswache',*/ 'mission_list_alliance', 'mission_list_alliance_event'],
runner_settings: ['Krankentransport-Automatic', 'MissionsOwn-Automatic', /*'MissionsOwn-Automatic',*/ 'Alliance-Automatic', 'AllianceEvent-Automatic'],
runner_iframesName: ['adis-krankentransporte', 'adis-ownmissions', /*'adis-plannedevents',*/ 'adis-verbandmission', 'adis-verbandmission-event'],
runner_iframes: ['adis-krankentransporte-frame', 'adis-ownmissions-frame', /*'adis-plannedevents-frame',*/ 'adis-verbandmission-frame', 'adis-verbandmission-event-frame']
}
}
constructor(myFaye) {
let self = this;
self.MaxVehicleID = 86
self.MissionType = null
self.MissionID = null
self.MyRunner = null
self.MyRunnerSettings = null
self.OweSecure = false
self._ADisVehiclesNeed = {}
self.MissionConfig = {}
self.Vehicles = {}
self.Patients = {}
self.ADis_MyHead = document.getElementsByTagName('head')[0];
self.ADis_MyBody = document.getElementsByTagName('body')[0];
// -
// - Sprechwunsch Variablen
// -
self.Jails = [];
self.JailRegEx = /\(Freie Zellen\:\s+(\d)\,\s+Entfernung\:\s+(\d+\,\d+)\s+km(?:\,\s+Abgabe an Besitzer\:\s+(\d+)%)?\)/g;
self.Hospitals = [];
self.RescueVehicleFrameWatchDog = null;
self.PoliceVehicleFrameWatchDog = null;
self.ADisDB = new Dexie('LSS_AutomaticDispo');
self.ADisDB.version(1).stores({
/**
* AvailabelMissions
* - missionID
* - type
* - name
* - jsondata
*/
ADisAvailabelMissions: "++missionID,type,name",
/**
* Sprechwunsch
* - vehicleID
* - done
*/
ADisSprechwunsch: "++vehicleID,done",
/**
* Sprechwunsch Police
* - missionID
* - done
*/
ADisSprechwunschPolice: "++missionID,last_check,next_check,done",
/**
* Settings
* - id
* - name
* - done
*/
ADisSettings: "&name,value",
/**
* MissionsOwn
* MissionsVerband
* MissionsVerbandEvent
* - missionID
* - type
* - name
* - available
* - done
* - street
* - village
* - last_check
* - next_check
* - runner - type (kt = krankentransport, om = own missions, os = sicherheitswache, vm = verband missions, ve = verband events)
*/
ADisMissions: "++missionID,runner,available,done,[missionID+available+done],[missionID+runner],[missionID+runner+done],[runner+available+done]"
});
self.ADisDB.on("populate", () => {
self.ADisDB.ADisSettings.add({
name: "Krankentransport-Automatic",
value: 'true'
});
self.ADisDB.ADisSettings.add({
name: "Sprechwunsch-Automatic",
value: 'true'
});
self.ADisDB.ADisSettings.add({
name: "MissionsOwn-Automatic",
value: 'true'
});
self.ADisDB.ADisSettings.add({
name: "Alliance-Automatic",
value: 'false'
});
self.ADisDB.ADisSettings.add({
name: "AllianceEvent-Automatic",
value: 'false'
});
});
self.ADisDB.open().catch((err) => {
console.error(err.stack || err);
});
self.ADisDB.on("ready", () => {
self.adis_settings = {
'Krankentransport-Automatic': false,
'Sprechwunsch-Automatic': false,
'MissionsOwn-Automatic': false,
'Alliance-Automatic': false,
'AllianceEvent-Automatic': false
}
self.genSettings()
if (window.location.pathname === "/" || window.location.pathname === "/#") {
self.GetAvailableMissions()
self.IndexPage()
setInterval(self.CollectRescueSprechwuensche.bind(self), 3500);
setInterval(self.OpenNextRescueSprechwunsch.bind(self), 1000);
self.CollectRescueSprechwuensche();
setInterval(self.CollectPoliceSprechwuensche.bind(self), 3500);
setInterval(self.OpenNextPoliceSprechwunsch.bind(self), 1000);
self.CollectPoliceSprechwuensche();
setTimeout(() => {
self.CollectMissions();
self.ReadAndAddMissions();
setInterval(function () {
let self = this;
self.ADisSettings.runner.forEach((runner) => {
self.OpenNextMission.call(self, runner)
})
}.bind(self), 1000);
}, 500);
}
/**
* / /=require ../script/mission.js
*/
// -
// - Sprechwunsch Handler Rettung
// -
if (window.location.pathname.indexOf("/vehicles/") !== -1 && window.name == 'adis-sprechwunsch-rescue') {
self.Check_Call_AB_Active(); // else
//self.Check_Call_Hospitals();
}
// -
// - Sprechwunsch Handler Polizei/Gefangene
// -
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
//window.console.log('DEBUG:::: Start Police Active')
self.Check_Call_Police_Active();
} else if (window.location.pathname.indexOf("/missions/") !== -1 && window.name != 'adis-sprechwunsch-police') {
//window.console.log('DEBUG:::: Start Mission')
self.StartMission();
}
});
new AutomaticDisposeFaye(myFaye)
}
includesString(string1, string2) {
return string1.toLowerCase().includes(string2.toLowerCase());
}
genSettings() {
let self = this;
self.ADisDB.ADisSettings.each((setting) => {
self.adis_settings[setting.name] = setting.value;
});
self.UIUpdateSettings();
setTimeout(self.genSettings.bind(self), 1000);
}
ADSettings() {
let self = this;
return new Dexie.Promise((resolve, reject) => {
return resolve(self.adis_settings);
})
}
get WindowName() {
return window.name
}
// -
// - Sprechwunsch Queue
// -
RemovePoliceSprechwunschFromQueue(WunschID) {
return this.ADisDB.ADisSprechwunschPolice.where({
missionID: WunschID
}).delete();
}
RemoveRescueSprechwunschFromQueue(WunschID) {
return this.ADisDB.ADisSprechwunsch.where({
vehicleID: WunschID
}).delete();
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Assign & Unassign Missions to Dispatchers
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
CollectRescueSprechwuensche() {
let self = this;
new Dexie.Promise((resolve, reject) => {
self.ADisDB.ADisSprechwunsch.where({
done: 'false'
}).each((myWunsch) => {
if ($("#vehicle_list_" + myWunsch.vehicleID).find(".building_list_fms").text() != "5") {
self.RemoveRescueSprechwunschFromQueue(myWunsch.vehicleID);
}
})
return resolve();
}).then(() => {
$("#building_list").find(".building_list_vehicle_element").each((_, elem) => {
var VehicleStatus = $(elem).find(".building_list_fms").text();
var VehicleType = Number(parseInt($(elem).find("a").attr("vehicle_type_id")));
var VehicleID = $(elem).attr("vehicle_id");
if (VehicleStatus == "5" && [32, 52].indexOf(VehicleType) === -1) {
self.AddRescueSprechwunschToQueue(VehicleID);
}
});
});
}
OpenNextRescueSprechwunsch() {
let self = this;
self.ADSettings().then((setting) => {
if (setting['Sprechwunsch-Automatic'] == 'true') {
return self.ADisDB.ADisSprechwunsch.where({
done: 'false'
}).limit(1)
}
}).then((Wunsch) => {
if (Wunsch !== undefined) {
Wunsch.each((myWunsch) => {
let VehicleID = myWunsch.vehicleID;
self.UpdateRescueSprechwunschToDone(VehicleID).then(() => {
if ($("#adis-sprechwunsch-rescue-frame").attr("vehicle_id") == "empty") {
$("#adis-sprechwunsch-rescue-frame").attr("src", "https://www.leitstellenspiel.de/vehicles/" + VehicleID);
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", VehicleID);
self.RescueVehicleFrameWatchDog = setTimeout(() => {
self.RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => {
$("#adis-sprechwunsch-rescue-frame").attr("src", "");
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty");
});
}, 1500);
}
});
});
}
});
}
AddRescueSprechwunschToQueue(WunschID) {
return this.ADisDB.ADisSprechwunsch.put({
vehicleID: WunschID,
done: 'false'
}).catch((err) => {})
}
UpdateRescueSprechwunschToDone(WunschID) {
return this.ADisDB.ADisSprechwunsch.put({
vehicleID: WunschID,
done: 'true'
}).catch((err) => {})
}
Check_Call_Hospitals() {
if ($("h4:contains('Eigene Krankenhäuser')").length > 0 || $("h4:contains('Verbandskrankenhäuser')").length > 0) {
this.Collect_Hospitals();
} else {
let VehicleID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
this.RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => {
$("#adis-sprechwunsch-rescue-frame").attr("src", "");
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty");
});
}
}
// Krankenhaus auswählen
Collect_Hospitals() {
let self = this;
self.Hospitals = [];
if ($("h4:contains('Eigene Krankenhäuser')").length > 0) {
$("h4:contains('Eigene Krankenhäuser')").next("table").find("tbody").find("tr").each((_, elem) => {
var HospitalHref = $(elem).find("a:contains('Anfahren')").attr("href");
var HospitalID = Number(parseInt($(elem).find("a:contains('Anfahren')").attr("id").replace("btn_approach_", "")));
var HospitalDistance = parseInt($(elem).find("td").eq("1").text());
var HospitalFreeBeds = parseInt($(elem).find("td").eq("2").text());
var HospitalValue = HospitalDistance * 450 * -1;
HospitalValue += 2000; // Own Hospitals are better :-)
if ($(elem).find(".label:contains('Ja')").length > 0) {
HospitalValue += 2000;
}
if (HospitalFreeBeds > 0) {
self.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((_, elem) => {
var HospitalHref = $(elem).find("a").attr("href")
var HospitalID = Number(parseInt(HospitalHref.substr(HospitalHref.lastIndexOf("/") + 1)));
var HospitalDistance = parseInt($(elem).find("td").eq("1").text());
var HospitalFreeBeds = parseInt($(elem).find("td").eq("2").text());
var HospitalTaxes = parseInt($(elem).find("td").eq("3").text());
var HospitalSpecialDepartment = false;
// Add Button-ID to Alliance-Hospital
$(elem).find("a").attr("id", "btn_approach_" + HospitalID.toString());
var HospitalValue = HospitalDistance * 450 * -1;
if ($(elem).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) {
self.Hospitals.push({
"id": HospitalID,
"value": HospitalValue,
"taxes": HospitalTaxes,
"distance": HospitalDistance,
"href": HospitalHref
});
}
});
}
self.Hospitals.sort((a, b) => {
return a.value - b.value;
});
self.Hospitals.reverse();
self.Send_Vehicle_To_Hospital()
}
// Krankenhaus einlieferung
Send_Vehicle_To_Hospital() {
//var HospitalID = Hospitals[0].id;
var HospitalHref = this.Hospitals[0].href;
// TODO: tellParent("ADisMissionDone(" + window.name + "," + MissionID + ");");
document.location.href = document.location.origin + HospitalHref;
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Assign & Unassign Missions to Dispatchers
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
CollectPoliceSprechwuensche() {
let self = this;
new Dexie.Promise((resolve, reject) => {
self.ADisDB.ADisSprechwunschPolice.where({
done: 'false'
}).each((myWunsch) => {
if (!$("#mission_" + myWunsch.missionID).text().match(/Gefangene sollen abtransportiert werden/g) && ($('#mission_panel_' + myWunsch.missionID).hasClass('mission_panel_green') || $('#mission_panel_' + myWunsch.missionID).hasClass('mission_panel_yellow'))) {
$("#mission_" + myWunsch.missionID).remove();
return self.RemovePoliceSprechwunschFromQueue(myWunsch.missionID);
}
})
return resolve();
}).then(() => {
var MOIODOS = $('div#mission_list div.missionSideBarEntry:visible');
return MOIODOS.each((_, elem) => {
var MissionID = $(elem).attr("mission_id");
if ($(elem).text().match(/Gefangene sollen abtransportiert werden/g) && $('#mission_panel_' + MissionID).hasClass('mission_panel_red')) {
self.AddPoliceSprechwunschToQueue(MissionID);
}
});
}).then(() => {
$("#building_list").find(".building_list_vehicle_element").each((_, elem) => {
var VehicleStatus = $(elem).find(".building_list_fms").text();
var VehicleType = Number(parseInt($(elem).find("a").attr("vehicle_type_id")));
var VehicleID = $(elem).attr("vehicle_id");
if (VehicleStatus == "5" && [32, 52].indexOf(VehicleType) !== -1) {
var map2 = $('#radio_messages_important > li.radio_message_vehicle_' + VehicleID + ' a:contains("Zum Einsatz")');
if (map2.length > 0) {
var _meap = String(map2.attr('href'));
var MissionID = _meap.substr(_meap.lastIndexOf("/") + 1);
if (MissionID) {
self.AddPoliceSprechwunschToQueue(MissionID);
}
}
}
});
});
}
OpenNextPoliceSprechwunsch() {
let self = this;
self.ADSettings().then((setting) => {
if (setting['Sprechwunsch-Automatic'] == 'true') {
return self.ADisDB.ADisSprechwunschPolice.where({
done: 'false'
}).limit(1)
}
}).then((Wunsch) => {
if (Wunsch !== undefined) {
Wunsch.each((myWunsch) => {
let MissionID = myWunsch.missionID;
self.UpdatePoliceSprechwunschToDone(MissionID).then(() => {
if ($("#adis-sprechwunsch-police-frame").attr("mission_id") == "empty") {
$("#adis-sprechwunsch-police-frame").attr("src", "https://www.leitstellenspiel.de/missions/" + MissionID);
$("#adis-sprechwunsch-police-frame").attr("mission_id", MissionID);
//self.PoliceVehicleFrameWatchDog = setTimeout((MissionID) => {
// self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
// $("#adis-sprechwunsch-police-frame").attr("src", "");
// $("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
// });
//}, 1500, MissionID);
}
});
});
}
});
}
AddPoliceSprechwunschToQueue(WunschID) {
return this.ADisDB.ADisSprechwunschPolice.put({
missionID: WunschID,
done: 'false'
}).catch((err) => {})
}
UpdatePoliceSprechwunschToDone(WunschID) {
return this.ADisDB.ADisSprechwunschPolice.add({
missionID: WunschID,
done: 'true'
}).catch((err) => {})
}
Check_Call_Police_Active() {
let self = this;
if (($('#h2_prisoners').length > 0 || $('img.patientPrisonerIcon').length > 0) && !self.includesString($('#missionH1').text(), '[verband]')) {
//TODO: check if Verband or Event and
// Maybe done with //__FIXX__20192
self.Collect_Jails();
} else {
let MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
// console.log('Check_Call_Police_Active', MissionID)
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
tellParent(`console.log('sprechwunsch:${window.name}:${MissionID}');setTimeout(function(){ window.AutomaticDisposeCall.FreeIframe('adis-sprechwunsch-police-frame');},500);`);
});
}
}
Check_Call_AB_Active() {
let self = this;
if ($("h1:contains('AB-')").length > 0 && $("div.alert.alert-info:contains('Welches Zugfahrzeug soll zum Transport genutzt werden')").length > 0) {
let href = $("a:contains('Alarmieren')").first().attr("href");
//console.log("DEBUG:::::: URL: ", href)
document.location.href = document.location.origin + href;
} else {
self.Check_Call_Hospitals();
}
}
// Gefängnis auswählen
Collect_Jails() {
// TODO: hardening the processing for verband/event missions
// Maybe done with the //__FIXX__20192
let self = this;
self.Jails = [];
var CountGefangene = Number(parseInt($('#h2_prisoners').text()));
let ImThere = $('#mission_vehicle_at_mission tr > td:nth-child(5) > a:contains("Jomaar"),#mission_vehicle_driving tr > td:nth-child(7) > a:contains("Jomaar")').length;
var parentNode = $('#mission_vehicle_at_mission tr > td:nth-child(5) > a:contains("Jomaar")').parent().parent();
var GefKw = parentNode.find('td:nth-child(2) > a[vehicle_type_id="52"]');
var FuStW = parentNode.find('td:nth-child(2) > a[vehicle_type_id="32"]');
var GefKwGefaegnisse = $(GefKw[0]).parent().parent().next('tr');
var FuStWGefaegnisse = $(FuStW[0]).parent().parent().next('tr');
GefKwGefaegnisse.find("a:contains('Freie Zellen')").each((_, elem) => {
var JailHref = $(elem).attr("href");
var JailID = JailHref.split("/").pop();
var JailText = $(elem).text();
var JailFreeBeds = 0;
var JailDistance = 0;
var JailTax = 0;
let m;
while ((m = self.JailRegEx.exec(JailText)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === self.JailRegEx.lastIndex) {
self.JailRegEx.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
if (groupIndex == 1) {
JailFreeBeds = parseInt(match.trim());
} else if (groupIndex == 2) {
JailDistance = parseInt(match.trim());
} else if (groupIndex == 3 && typeof match != "undefined") {
JailTax = parseInt(match.trim());
}
});
}
var JailValue = JailDistance * 450 * -1;
JailValue += 11; //GefKw bevorzugt
if (JailTax == 0) {
JailValue += 10000;
} else if (JailTax > 0 && JailTax <= 10) {
JailValue += 5000;
} else if (JailTax > 10 && JailTax <= 20) {
JailValue += 1000;
} else {
JailValue -= 10000;
}
if (JailFreeBeds >= 5) {
JailValue += 15000;
} else if (JailFreeBeds >= 1) {
JailValue += 1000;
} else {
JailValue -= 5000;
}
if (JailFreeBeds >= 5) {
self.Jails.push({
"id": JailID,
"value": JailValue + 1000,
"text": JailText,
"distance": JailDistance,
"href": JailHref
});
} else if (JailFreeBeds >= 1) {
self.Jails.push({
"id": JailID,
"value": JailValue,
"text": JailText,
"distance": JailDistance,
"href": JailHref
});
}
});
FuStWGefaegnisse.find("a:contains('Freie Zellen')").each((_, elem) => {
var JailHref = $(elem).attr("href");
var JailID = JailHref.split("/").pop();
var JailText = $(elem).text();
var JailFreeBeds = 0;
var JailDistance = 0;
var JailTax = 0;
let m;
while ((m = self.JailRegEx.exec(JailText)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === self.JailRegEx.lastIndex) {
self.JailRegEx.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
if (groupIndex == 1) {
JailFreeBeds = parseInt(match.trim());
} else if (groupIndex == 2) {
JailDistance = parseInt(match.trim());
} else if (groupIndex == 3 && typeof match != "undefined") {
JailTax = parseInt(match.trim());
}
});
}
var JailValue = JailDistance * 450 * -1;
if (JailTax == 0) {
JailValue += 10000;
} else if (JailTax > 0 && JailTax <= 10) {
JailValue += 5000;
} else if (JailTax > 10 && JailTax <= 20) {
JailValue += 1000;
} else {
JailValue -= 10000;
}
if (JailFreeBeds >= 5) {
JailValue += 15000;
} else if (JailFreeBeds >= 1) {
JailValue += 1000;
} else {
JailValue -= 5000;
}
if (JailFreeBeds >= CountGefangene) {
self.Jails.push({
"id": JailID,
"value": JailValue + 1000,
"text": JailText,
"distance": JailDistance,
"href": JailHref
});
} else if (JailFreeBeds >= 1) {
self.Jails.push({
"id": JailID,
"value": JailValue,
"text": JailText,
"distance": JailDistance,
"href": JailHref
});
}
});
self.Jails.sort((a, b) => {
return a.value - b.value;
});
self.Jails.reverse();
if (self.Jails.length > 0) {
self.Send_Vehicle_To_Jail()
} else {
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each((_, elem) => {
//__FIXX__20192
let me = $(elem).find('td:nth-child(5) > a:contains("Jomaar")').length;
if (me > 0) {
//__FIXX__20192
var CalledVehicleID = parseInt($(elem).find("a").first().attr("vehicle_type_id"));
if (CalledVehicleID == 52) {
CountGefangene -= 5;
} else if (CalledVehicleID == 32) {
CountGefangene -= 1;
}
//__FIXX__20192
}
//__FIXX__20192
});
if (ImThere > 0) {
if ($('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').length > 0 && CountGefangene >= 5) {
$('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').each((_, elem) => {
if (CountGefangene > 0) {
$(elem).click()
CountGefangene -= 5;
}
});
}
if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').length > 0 && CountGefangene > 0) {
$('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').each((_, elem) => {
if (CountGefangene > 0) {
$(elem).click()
CountGefangene -= 1;
}
});
}
}
if ($('#vehicle_show_table_all input[type="checkbox"]:checked').length > 0) {
$('#mission_alarm_btn').click();
} else {
let MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
tellParent(`console.log('sprechwunsch:${window.name}:${MissionID}');setTimeout(function(){ window.AutomaticDisposeCall.FreeIframe('adis-sprechwunsch-police-frame');},500);`);
});
}
}
}
// Gefängnis einlieferung
Send_Vehicle_To_Jail() {
var self = this;
var JailHref = this.Jails[0].href
var MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
tellParent(`/*console.log('sprechwunsch:${window.name}:${MissionID}');*/setTimeout(function(){ window.AutomaticDisposeCall.FreeIframe('adis-sprechwunsch-police-frame');},250);`);
document.location.href = document.location.origin + JailHref;
});
}
// -
// - Index Page Loader
// -
IndexPage() {
let self = this;
// -
// - Google Font
// -
var styleElement = document.createElement("link");
styleElement.rel = "stylesheet";
styleElement.href = "https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700";
self.ADis_MyHead.appendChild(styleElement);
// -
// - FontAwesome 5
// -
var scriptElement = document.createElement("script");
scriptElement.type = "text/javascript";
scriptElement.src = "https://use.fontawesome.com/releases/v5.5.0/js/all.js";
self.ADis_MyHead.appendChild(scriptElement);
// -
// - Navbar Dashboard
// -
var styleElement = document.createElement("link");
styleElement.rel = "stylesheet";
styleElement.type = "text/css";
styleElement.media = "screen";
styleElement.href = self.ADisSettings.url + self.ADisSettings.branch + "/style/interface.css";
self.ADis_MyHead.appendChild(styleElement);
// Create Dashboard
$('#news_li').before('<li id="adis-nav-item"></li>');
$('#adis-nav-item').html(`/***ADis_Navbar***/0`)
$("#adis-dashboard").css({
display: "none",
opacity: "0"
});
//
// Click Events
//
$("#adis-setting-krankentransport-automatic").click((e) => {
e.preventDefault();
var tf = $(e.target).hasClass("active");
self.ADisDB.ADisSettings.put({
name: "Krankentransport-Automatic",
value: !tf ? 'true' : 'false'
}).then((res) => {
self.UIUpdateSettings();
});
});
$("#adis-setting-full-automatic").click((e) => {
e.preventDefault();
var tf = $(e.target).hasClass("active");
self.ADisDB.ADisSettings.put({
name: "MissionsOwn-Automatic",
value: !tf ? 'true' : 'false'
}).then(() => {
self.UIUpdateSettings();
});
});
$("#adis-setting-sprechwunsch-automatic").click((e) => {
e.preventDefault();
var tf = $(e.target).hasClass("active");
self.ADisDB.ADisSettings.put({
name: "Sprechwunsch-Automatic",
value: !tf ? 'true' : 'false'
}).then(() => {
self.UIUpdateSettings();
});
});
$("#adis-setting-alliance-automatic").click((e) => {
e.preventDefault();
var tf = $(e.target).hasClass("active");
self.ADisDB.ADisSettings.put({
name: "Alliance-Automatic",
value: !tf ? 'true' : 'false'
}).then(() => {
self.UIUpdateSettings();
});
});
$("#adis-setting-alliance-automatic").click((e) => {
e.preventDefault();
var tf = $(e.target).hasClass("active");
self.ADisDB.ADisSettings.put({
name: "AllianceEvent-Automatic",
value: !tf ? 'true' : 'false'
}).then(() => {
self.UIUpdateSettings();
});
});
//
// Dashboard Functions
//
$("#adis-open-button").click((e) => {
e.preventDefault();
$("#adis-dashboard").css("display", "flex");
$("#adis-dashboard").animate({
opacity: 1
}, 200);
});
$("#adis-dashboard-close-button").click((e) => {
e.preventDefault();
$("#adis-dashboard").animate({
opacity: 0
}, 200, () => {
$("#adis-dashboard").css("display", "none");
});
});
// initial call to load the current setting state
self.UIUpdateSettings();
// Create Iframes
$("body").append('<div id="adis-frame-container"></div>');
$("#adis-frame-container").html(`/***ADis_Iframes***/0`);
$("#adis-frame-container").css({
display: "none",
opacity: "0"
});
}
//
// Display Settings
//
UIUpdateSettings() {
this.ADisDB.ADisSettings.each((setting) => {
if (setting.name == "Krankentransport-Automatic") {
if (setting.value == "true") {
$("#adis-setting-krankentransport-automatic").addClass("active");
} else {
$("#adis-setting-krankentransport-automatic").removeClass("active");
}
} else if (setting.name == "Sprechwunsch-Automatic") {
if (setting.value == "true") {
$("#adis-setting-sprechwunsch-automatic").addClass("active");
} else {
$("#adis-setting-sprechwunsch-automatic").removeClass("active");
}
} else if (setting.name == "MissionsOwn-Automatic") {
if (setting.value == "true") {
$("#adis-setting-full-automatic").addClass("active");
} else {
$("#adis-setting-full-automatic").removeClass("active");
}
} else if (setting.name == "Alliance-Automatic") {
if (setting.value == "true") {
$("#adis-setting-alliance-automatic").addClass("active");
} else {
$("#adis-setting-alliance-automatic").removeClass("active");
}
} else if (setting.name == "AllianceEvents-Automatic") {
if (setting.value == "true") {
$("#adis-setting-allianceevents-automatic").addClass("active");
} else {
$("#adis-setting-allianceevents-automatic").removeClass("active");
}
}
});
}
GetAvailableMissions() {
let self = this;
for (let i in self.ADisSettings.all_missions) {
let Mission = self.ADisSettings.all_missions[i];
self.AddAvailableMissions(Mission);
}
}
AddAvailableMissions(Mission) {
return this.ADisDB.ADisAvailabelMissions.put({
missionID: Mission.id,
type: Mission.type,
name: Mission.name,
jsondata: Mission
}).catch((err) => {
console.error(err)
})
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Collect Own Missions
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
CollectMissions() {
const self = this;
const MyOwnObserver = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
// console.log(mutation.target.id);
// console.table(mutation); // <<-- includes text nodes
if (mutation.addedNodes.length >= 1) {
// do it here
for (var i = 0; i < mutation.addedNodes.length; i++) {
self.ReadAndAddMissions(mutation.addedNodes[i].attributes.getNamedItem("mission_id").value, mutation.target.id);
}
}
});
});
const MyOwnConfig = {
childList: true
};
MyOwnObserver.observe($('#mission_list')[0], MyOwnConfig);
MyOwnObserver.observe($('#mission_list_krankentransporte')[0], MyOwnConfig);
MyOwnObserver.observe($('#mission_list_sicherheitswache')[0], MyOwnConfig);
MyOwnObserver.observe($('#mission_list_alliance_event')[0], MyOwnConfig);
MyOwnObserver.observe($('#mission_list_alliance')[0], MyOwnConfig);
}
ReadAndAddMissions(MissionID, Runner) {
const self = this;
return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => {
self.ADSettings().then(() => {
return self.ADisDB.ADisMissions.toCollection()
}).then((Missions) => {
if (typeof Missions !== "undefined") {
return Missions.count((count) => {
if (count > 0) {
return Missions.each((MyMission) => {
var MissionElement = $("#mission_" + MyMission.missionID);
if (MissionElement.length == 0 || MissionElement.text().match(/Gefangene sollen abtransportiert werden/g) || $('#mission_panel_' + MyMission.missionID).hasClass('mission_panel_green') || $('#mission_panel_' + MyMission.missionID).hasClass('mission_panel_yellow')) {
// remove
//console.log("Remove :", MyMission)
self.RemoveMissionsFromQueue(MyMission.missionID)
}
});
}
});
}
}).then(() => {
if (typeof MissionID != 'undefined') {
if ($('#mission_panel_' + MissionID).hasClass('mission_panel_red') && !$("#mission_" + MissionID).text().match(/Gefangene sollen abtransportiert werden/g)) {
return self.AddMission(MissionID, Runner);
}
} else {
return self.ADisSettings.runner_divs.forEach((RunnerX, index) => {
$("#" + RunnerX).find(".missionSideBarEntry").each((index, elem) => {
MissionID = $(elem).attr("mission_id");
if ($('#mission_panel_' + MissionID).hasClass('mission_panel_red') && !$("#mission_" + MissionID).text().match(/Gefangene sollen abtransportiert werden/g)) {
return self.AddMission(MissionID, RunnerX);
}
return true;
});
})
}
});
});
}
AddMission(ID, Runner) {
const self = this;
// convert Runnter to Settings
const runnerID = self.ADisSettings.runner_divs.indexOf(Runner);
const settingOpt = self.ADisSettings.runner_settings[runnerID];
const runnerOpt = self.ADisSettings.runner[runnerID];
return self.ADSettings().then((setting) => {
if (setting[settingOpt] == 'true') {
let where = {
missionID: ID,
runner: runnerOpt
};
return self.ADisDB.ADisMissions.where(where).limit(1)
}
}).then((Missions) => {
if (typeof Missions === "undefined") {
return;
/*
var MissionElement = $("#mission_" + ID);
var MissionID = MissionElement.attr("mission_id");
var MissionType = MissionElement.attr("mission_type_id");
var addr = MissionElement.find(".map_position_mover").text().split(",")
var MissionName = addr[0];
var MissionStreet = addr[1];
var MissionVillage = addr[2];
return self.ADisDB.ADisAvailabelMissions.get({
type: MissionType
}).then((available) => {
return self.AddMissionsToQueue({
"missionID": MissionID,
"type": MissionType,
"runner": runnerOpt,
"name": MissionName,
"street": MissionStreet,
"village": MissionVillage,
"available": (available !== undefined) ? 'true' : 'false',
"done": 'false',
"last_check": Math.floor(new Date().getTime() / 1000),
"next_check": Math.floor(new Date().getTime() / 1000) + 1
});
});
*/
}
return Missions.count((count) => {
//console.log(count, runnerOpt);
if (count > 0) {
return Missions.each((Mission) => {
var MissionElement = $("#mission_" + ID);
var _MissionID = MissionElement.attr("mission_id");
var _MissionType = MissionElement.attr("mission_type_id");
var addr = MissionElement.find(".map_position_mover").text().split(",")
var MissionName = addr[0];
var MissionStreet = addr[1];
var MissionVillage = addr[2];
//console.log('update mission', _MissionID)
return self.ADisDB.ADisAvailabelMissions.get({
type: _MissionType
}).then((available) => {
//console.table(Mission)
//console.table({
// "missionID": _MissionID,
// "type": _MissionType,
// "runner": runnerOpt,
// "name": MissionName,
// "street": MissionStreet,
// "village": MissionVillage,
// "available": (available !== undefined) ? 'true' : 'false',
// "done": "false",
// "last_check": Mission.last_check,
// "next_check": Mission.next_check
//})
return self.UpdateMissions({
"missionID": _MissionID,
"type": _MissionType,
"runner": runnerOpt,
"name": MissionName,
"street": MissionStreet,
"village": MissionVillage,
"available": (available !== undefined) ? 'true' : 'false',
"done": "false",
"last_check": Mission.last_check,
"next_check": Mission.next_check
});
});
});
} else {
var MissionElement = $("#mission_" + ID);
var MissionID = MissionElement.attr("mission_id");
var MissionType = MissionElement.attr("mission_type_id");
var addr = MissionElement.find(".map_position_mover").text().split(",")
var MissionName = addr[0];
var MissionStreet = addr[1];
var MissionVillage = addr[2];
// console.log('new mission', MissionID)
return self.ADisDB.ADisAvailabelMissions.get({
type: MissionType
}).then((available) => {
return self.AddMissionsToQueue({
"missionID": MissionID,
"type": MissionType,
"runner": runnerOpt,
"name": MissionName,
"street": MissionStreet,
"village": MissionVillage,
"available": (available !== undefined) ? 'true' : 'false',
"done": 'false',
"last_check": Math.floor(new Date().getTime() / 1000),
"next_check": Math.floor(new Date().getTime() / 1000) + 1
});
});
}
});
});
}
AddMissionsToQueue(Mission) {
const self = this;
return self.ADisDB.ADisMissions.put(Mission).catch((err) => {
console.error(err)
});
}
UpdateMissions(Mission) {
const self = this;
return self.ADisDB.ADisMissions.put(Mission).catch((err) => {
console.error(err)
})
}
FreeIframe(Runner) {
const self = this;
const runnerID = self.ADisSettings.runner.indexOf(Runner)
const runnerIframe = self.ADisSettings.runner_iframes[runnerID];
if (Runner == 'adis-sprechwunsch-police-frame') {
$('#' + Runner).attr("src", '');
$('#' + Runner).attr("mission_id", 'empty');
} else {
$('#' + runnerIframe).attr("src", '');
$('#' + runnerIframe).attr("mission_id", 'empty');
}
}
UpdateMissionsToDone(MissionID) {
const self = this;
return self.ADisDB.ADisMissions.update(MissionID, {
last_check: Math.floor(new Date().getTime() / 1000),
next_check: Math.floor(new Date().getTime() / 1000) + 300
}).catch((err) => {
console.error(err)
})
}
RemoveMissionsFromQueue(MissionID) {
const self = this;
return self.ADisDB.ADisMissions.where({
missionID: MissionID
}).delete().catch((err) => {
console.error(err)
})
}
OpenNextMission(Runner) {
const self = this;
const runnerID = self.ADisSettings.runner.indexOf(Runner)
const runnerIframeName = self.ADisSettings.runner_iframesName[runnerID];
const runnerIframe = self.ADisSettings.runner_iframes[runnerID];
const runnerSettings = self.ADisSettings.runner_settings[runnerID];
// console.table({
// Runner: Runner,
// runnerID: runnerID,
// runnerSettings: runnerSettings,
// runnerIframeName: runnerIframeName,
// runnerIframe:runnerIframe
// })
return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => {
self.ADSettings().then((setting) => {
if (setting[runnerSettings] == 'true') {
return self.ADisDB.ADisMissions.where({
runner: Runner,
available: 'true',
done: 'false'
}).and(function (item) {
return item.next_check <= Math.floor(new Date().getTime() / 1000)
}).limit(1)
}
}).then((Wunsch) => {
// console.table(Wunsch);
if (Wunsch !== undefined) {
return Wunsch.count(function (count) {
if (count > 0) {
return Wunsch.each((myWunsch) => {
//console.log("DEBUG:::::: MYWUNSCH:")
//console.table(myWunsch);
let MissionID = myWunsch.missionID;
if ($('#' + runnerIframe).attr("mission_id") == "empty") {
$('#' + runnerIframe).attr("src", "https://www.leitstellenspiel.de/missions/" + MissionID);
$('#' + runnerIframe).attr("mission_id", MissionID);
// self.UpdateMissionsToDone(MissionID).then(() => {
// // console.log('done.... ' + Runner);
// $('#' + runnerIframe).attr("src", '');
// $('#' + runnerIframe).attr("mission_id", 'empty');
// setTimeout(self.OpenNextMission.bind(self), 5000, Runner);
// })
}
return
});
} else {
return; //setTimeout(self.OpenNextMission.bind(self), 1000, Runner);
}
});
}
return; //setTimeout(self.OpenNextMission.bind(self), 1000, Runner);
});
});
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Start Mission Handler
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
StartMission() {
const self = this;
self.MissionType = null;
const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name);
self.MyRunner = self.ADisSettings.runner[runnerID];
self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID];
setTimeout(function () {
self.MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
var help_el = $('a#mission_help');
if (help_el.length > 0) {
self.MissionType = help_el[0].href.split("?")[0];
var re = /\d+$/i;
var found = self.MissionType.match(re);
self.MissionType = Number(found[0]);
} else {
self.MissionType = null;
}
// console.log("DEBUG:::::: MissionID", self.MissionID);
// console.log("DEBUG:::::: MissionType", self.MissionType);
// console.log("DEBUG:::::: Window", window.name);
// console.log("DEBUG:::::: self.MyRunner", self.MyRunner);
// console.log("DEBUG:::::: self.MyRunnerSettings", self.MyRunnerSettings);
// if (self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
// console.log("DONE: ", self.MissionID);
// return self.RemoveMissionsFromQueue(self.MissionID).then(() => {
// return tellParent(`console.log('handler:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed
// })
// } else {
return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions], () => {
self.ADSettings().then((setting) => {
if (setting[self.MyRunnerSettings] === 'true') {
let where = {
missionID: self.MissionID,
runner: self.MyRunner,
done: 'false'
}
// console.log(where);
return self.ADisDB.ADisMissions.where(where).and(function (item) {
return item.next_check <= Math.floor(new Date().getTime() / 1000)
}).limit(1)
}
}).then((Wunsch) => {
if (Wunsch !== undefined) {
return Wunsch.count(function (count) {
if (count > 0) {
return Wunsch.each((mywunsch) => {
// console.table(mywunsch);
return self.MainHandler()
});
} else {
return self.UpdateMissionsToDone(self.MissionID).then(() => {
return tellParent(`/*console.log('wunsch:1000:done:${window.name}:${self.MissionID}');*/window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`);
})
}
});
} else {
return self.RemoveMissionsFromQueue(self.MissionID).then(() => {
return tellParent(`/*console.log('wunsch:2000:done:${window.name}:${self.MissionID}');*/window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`);
})
}
})
})
// }
}, 500);
}
MainHandler() {
const self = this;
if (self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
//console.log("DEBUG:::::: DONE: ", self.MissionID);
return self.RemoveMissionsFromQueue(self.MissionID).then(() => {
return tellParent(`/*console.log('handler:1000:done:${window.name}:${self.MissionID}');*/window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed
})
}
/*else if (self.includesString($('#iframe-inside-container > div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert") ) {
console.log("SEND");
console.log("SEND: ", self.MissionID);
return self.UpdateMissionsToDone(self.MissionID).then(() => {
return tellParent(`console.log('handler:2000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full
});
} */
else {
setTimeout(function () {
if (['adis-ownmissions', 'adis-plannedevents', 'adis-krankentransporte'].indexOf(window.name) != -1) {
//console.log("DEBUG:::::: WILL SEND?", window.name, self.MissionID)
self.CheckMissionAutomatic();
} else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) {
self.WorkVerbandMission();
}
}, 250);
}
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Grab Run Verbands Missions
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
WorkVerbandMission() {
const self = this;
self.ADSettings().then((setting) => {
var title = document.getElementById('missionH1');
var isVerband = title.innerText.toLowerCase().includes("[verband]");
if (setting['Alliance-Automatic'] == 'true' && isVerband) {
if ([52, 55, 129, 203].indexOf(self.MissionType) !== -1 && $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]')[0].click();
} else if ([53, 130, 202].indexOf(self.MissionType) !== -1) {
if ($('#vehicle_show_table_all tr[vehicle_type="FLF"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="FLF"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="GW-A"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="GW-A"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="GW-Öl"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="GW-Öl"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="NEF"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="NEF"] input[type="checkbox"]')[0].click();
}
} else if ([54, 56].indexOf(self.MissionType) !== -1) {
if ($('#vehicle_show_table_all tr[vehicle_type="FLF"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="FLF"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="GW-A"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="GW-A"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="GW-Öl"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="GW-Öl"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="LF 20"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="LF 20"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="LF 20/16"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="LF 20/16"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="HLF 20"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="HLF 20"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="TLF 8/8"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="TLF 8/8"] input[type="checkbox"]')[0].click();
}
} else {
if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]')[0].click();
} else if ($('#vehicle_show_table_all tr[vehicle_type="KTW Typ B"] input[type="checkbox"]').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="KTW Typ B"] input[type="checkbox"]')[0].click();
}
}
// Todo add alternative cars, please no LF because of Mülltonne....
if ($('#vehicle_show_table_all input[type="checkbox"]:checked').length > 0) {
$('#mission_alarm_btn').click();
}
}
});
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Grab Mission-Configuration from GitHub
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
CheckMissionAutomatic() {
const self = this;
var setOpt;
if (window.name == 'adis-ownmissions' || window.name == 'adis-plannedevents') {
setOpt = 'MissionsOwn-Automatic';
} else if (window.name == 'adis-krankentransporte') {
setOpt = 'Krankentransport-Automatic';
}
if (setOpt && self.MyRunner) {
self.ADSettings().then((setting) => {
if (setting[setOpt] == 'true') {
let where = {
missionID: self.MissionID,
runner: self.MyRunner,
done: 'false'
}
var coll = self.ADisDB.ADisMissions.where(where)
if (self.MyRunner != "kt") {
coll = coll.and(function (item) {
return item.next_check <= Math.floor(new Date().getTime() / 1000)
});
}
return coll.limit(1).toArray()
}
}).then((Missions) => {
if (Missions.length > 0) {
var Mission = Missions[0];
if (self.MyRunner == 'os') {
self.OweSecure = true;
}
self.GetMissionConfiguration(Mission.type);
}
});
}
}
GetMissionConfiguration(MissionType) {
const self = this;
return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => {
return self.ADisDB.ADisAvailabelMissions.get({
type: MissionType.toString()
}).then((availableMission) => {
if (availableMission != undefined && availableMission.jsondata) {
self.MissionConfig = availableMission.jsondata;
//console.log('DEBUG:::: MissionConfig: ', MissionType.toString(), JSON.stringify(self.MissionConfig, null, 2))
self.StartAlarmProcess();
} else {
var updateData = {
available: false,
next_check: CurrentTime + 60
};
self.UpdateOwnMissionsToDone(self.MissionID, updateData);
}
});
});
}
StartAlarmProcessProc() {
const self = this;
new Dexie.Promise.resolve().then(() => {
return self.PrepareVehicleNeedList();
}).then(() => {
return self.CollectInvolvedVehicles();
}).then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return self.CollectPatients();
})
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return self.ProcessEmergencyMedicalService()
})
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return self.ProcessFireDepartment()
})
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return self.ProcessPoliceDepartment()
})
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return self.ProcessTechnicalEmergencyService()
})
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return self.ProcessWaterRescue()
})
.then(() => {
if (self.OweSecure && $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:checked').length == 0) {
if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:not(:checked)').length > 0) {
$('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:not(:checked)')[0].click();
}
}
let vhcalled = window.$('#vehicle_show_table_all input[type="checkbox"]:checked');
// window.console.log("DEBUG:::: Clicked Vehicles: %s %s", window.name, String(self.MissionID), vhcalled.length, vhcalled);
// window.console.log("WILL KLICK SEND", self.MissionID, window.name)
self.UpdateMissionsToDone(self.MissionID).then(() => {
//tellParent(`console.log('ok:${window.name}:${self.MissionID}');`);
if (vhcalled.length == 0) {
//window.console.log('nocars selected...', vhcalled.length);
if (window.name == 'adis-krankentransporte') {
//window.console.log('nocars selected... select KTW');
$('#aao_2753841').click();
window.$('#mission_alarm_btn').click();
} else {
//window.console.log('nocars selected... start new run');
tellParent(`/*console.log('nocars:${window.name}:${self.MissionID}');*/window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`);
}
} else {
tellParent(`/*console.log('sendcars:${window.name}:${self.MissionID}');*/setTimeout(function(){window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');},1000);`);
window.$('#mission_alarm_btn').click();
//window.console.log("WILL KLICK SEND3", self.MissionID, window.name)
}
});
})
}
StartAlarmProcess() {
const self = this;
var $div = $("#mission-form > div:nth-child(7) > a");
var isShow = $div.is(':hidden');
//console.log($div, isShow);
/*
if ($div.length && isShow && 1 == 0) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
console.log(mutation.type, self.MissionID);
console.table(mutation, self.MissionID);
if (mutation.attributeName === "style") {
self.StartAlarmProcessProc()
}
});
});
observer.observe($div[0], {
attributes: true,
characterData: true
});
$div.click();
} else {
*/
//window.console.log('StartAlarmProcessProc()');
self.StartAlarmProcessProc()
//}
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Collect Involved Vehicles & Patients
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
CollectInvolvedVehicles() {
let self = this;
$("#mission_vehicle_driving tbody").find("tr").each(function (_, elem) {
try {
var f = $(elem).find("a").first()
var VehicleID = f.attr("href").substr(f.attr("href").lastIndexOf("/") + 1);
var VehicleName = f.text();
var VehicleType = f.attr("vehicle_type_id");
if (typeof VehicleType !== 'undefined') {
self.Vehicles[VehicleID] = {
"id": VehicleID,
"name": VehicleName,
"type": VehicleType
}
}
} catch (e) {}
});
$("#mission_vehicle_at_mission tbody").find("tr").each(function (_, elem) {
try {
var f = $(elem).find("a").first()
var VehicleID = f.attr("href").substr(f.attr("href").lastIndexOf("/") + 1);
var VehicleName = f.text();
var VehicleType = f.attr("vehicle_type_id");
if (typeof VehicleType !== 'undefined') {
self.Vehicles[VehicleID] = {
"id": VehicleID,
"name": VehicleName,
"type": VehicleType
}
}
} catch (e) {}
});
//console.table(self.Vehicles);
return self.Vehicles;
}
CollectPatients() {
const self = this;
let PatientCounter = 0;
$(".mission_patient").each(function (_, elem) {
var PatientName = $(elem).text();
var PatientNeedRTW = false;
var PatientNeedNEF = false;
var PatientNeedRTH = false;
var PatientNeedLNA = false;
var PatientNeedOrgL = false;
var PatientNeedSEGKTWB = false;
var PatientNeedTragehilfe = false;
if ($(elem).find(".alert-danger").length > 0) {
let emergencyText = $(elem).find(".alert-danger").text();
// Wir benötigen einen RTW oder KTW Typ B.
if (emergencyText.indexOf("KTW Typ B") != -1) {
PatientNeedSEGKTWB = true;
}
// Wir benötigen einen RTW.
if (emergencyText.indexOf("RTW") != -1) {
PatientNeedRTW = true;
}
// Wir benötigen einen NEF.
if (emergencyText.indexOf("NEF") != -1) {
PatientNeedNEF = true;
}
// Wir benötigen einen RTH.
if (emergencyText.indexOf("RTH") != -1) {
PatientNeedRTH = true;
}
// Wir benötigen einen LNA.
if (emergencyText.indexOf("LNA") != -1) {
PatientNeedLNA = true;
}
// Wir benötigen einen OrgL.
if (emergencyText.indexOf("OrgL") != -1) {
PatientNeedOrgL = true;
}
// Wir benötigen eine Tragehilfe (z.B. durch ein LF).
if (emergencyText.indexOf("Tragehilfe") != -1) {
PatientNeedTragehilfe = true;
}
}
self.Patients[PatientCounter] = {
"name": PatientName,
"need_RTW": PatientNeedRTW,
"need_NEF": PatientNeedNEF,
"need_RTH": PatientNeedRTH,
"need_LNA": PatientNeedLNA,
"need_OrgL": PatientNeedOrgL,
"need_SEG_KTWB": PatientNeedSEGKTWB,
"need_Tragehilfe": PatientNeedTragehilfe
}
PatientCounter++;
});
return self.Patients;
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Process Emergency_Medical_Service
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
ProcessEmergencyMedicalService() {
const self = this;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// -
// - Emergency Medical Service: Vehicles
// -
// - 38: KTW
// - 28: RTW
// - 29: NEF
// - 74: NAW
// - 73: GRTW
// - 31: RTH
// - 55: LNA
// - 56: OrgL
// -
// - 58: (SEG) KTW Typ B
// - 59: (SEG) ELW 1
// - 60: (SEG) GW-San
// -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (typeof self.MissionConfig.emergency_medical_service == "object") // Wenn der EMS-Block in der Config definiert ist
{
if (Object.keys(self.Patients).length >= 5) { // need LNA
self._ADisVehiclesNeed["55"] = 1;
}
if (Object.keys(self.Patients).length >= 10) { // need OrgL
self._ADisVehiclesNeed["56"] = 1;
}
if (Object.keys(self.Patients).length == 0) {
if (self.MissionConfig.emergency_medical_service.use_RTW == true) {
self._ADisVehiclesNeed["28"]++;
}
if (self.MissionConfig.emergency_medical_service.use_NEF == true) {
self._ADisVehiclesNeed["29"]++;
}
if (self.MissionConfig.emergency_medical_service.use_RTH == true) {
self._ADisVehiclesNeed["31"]++;
}
} else {
for (var Key in self.Patients) {
var Patient = self.Patients[Key];
if (self.MissionConfig.emergency_medical_service.use_KTW == true) {
if (!Patient.need_RTW && !Patient.need_NEF && !Patient.need_RTH) {
self._ADisVehiclesNeed["38"]++;
}
}
if (Patient.need_LNA && self._ADisVehiclesNeed["55"] < 1) {
self._ADisVehiclesNeed["55"]++;
}
if (Patient.need_OrgL && self._ADisVehiclesNeed["56"] < 1) {
self._ADisVehiclesNeed["56"]++;
}
if (Patient.need_Tragehilfe == true) {
self._ADisVehiclesNeed["0"]++;
}
if (self.MissionConfig.emergency_medical_service.use_RTW == true || Patient.need_RTW == true) {
self._ADisVehiclesNeed["28"]++;
}
if (self.MissionConfig.emergency_medical_service.use_NEF == true || Patient.need_NEF == true) {
self._ADisVehiclesNeed["29"]++;
}
if (self.MissionConfig.emergency_medical_service.use_RTH == true || Patient.need_RTH == true) {
self._ADisVehiclesNeed["31"]++;
}
};
}
// TODO: need to be refactored to make sure first KTW Typ B before RTW.
if (self.MissionConfig.emergency_medical_service.use_SEG_ELW1_Only == "true") {
self._ADisVehiclesNeed["59"]++;
} else if (self.MissionConfig.emergency_medical_service.use_SEG_FULL == "true" || Object.keys(self.Patients).length >= 3) {
self._ADisVehiclesNeed["58"]++;
self._ADisVehiclesNeed["58"]++; // 3x KTW Type B
self._ADisVehiclesNeed["58"]++;
self._ADisVehiclesNeed["59"]++;
self._ADisVehiclesNeed["60"]++;
}
var VehicleTable;
if ($("#vehicle_show_table_body_all").length > 0) {
VehicleTable = $("#vehicle_show_table_body_all");
} else {
VehicleTable = $("#vehicle_show_table_body_rett");
}
VehicleTable.find(".vehicle_select_table_tr").each(function (_, elem) {
var VehicleID = $(elem).attr("id").replace("vehicle_element_content_", "");
// var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue");
var VehicleType = $(elem).attr("vehicle_type");
if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) {
return;
}
if (VehicleType == "KTW" && self._ADisVehiclesNeed["38"] > 0) {
// console.log(" Automatic Dispose: Fahrzeug " + VehicleID + " " + VehicleType + " markiert");
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["38"]--;
} else if ((VehicleType == "LF 20" || VehicleType == "LF 10" ||
VehicleType == "LF 8/6" || VehicleType == "LF 20/16" ||
VehicleType == "LF 10/6" || VehicleType == "LF 16-TS" ||
VehicleType == "HLF 20" || VehicleType == "TSF-W" ||
VehicleType == "TLF 2000" || VehicleType == "TLF 3000" ||
VehicleType == "TLF 8/8" || VehicleType == "TLF 8/18" ||
VehicleType == "TLF 16/24-Tr" || VehicleType == "TLF 16/25" ||
VehicleType == "TLF 16/45" || VehicleType == "TLF 20/40" ||
VehicleType == "TLF 20/40-SL" || VehicleType == "TLF 16") &&
self._ADisVehiclesNeed["0"] + self._ADisVehiclesNeed["1"] + self._ADisVehiclesNeed["6"] + self._ADisVehiclesNeed["7"] +
self._ADisVehiclesNeed["8"] + self._ADisVehiclesNeed["9"] + self._ADisVehiclesNeed["30"] + self._ADisVehiclesNeed["37"] +
self._ADisVehiclesNeed["17"] + self._ADisVehiclesNeed["18"] + self._ADisVehiclesNeed["19"] + self._ADisVehiclesNeed["20"] +
self._ADisVehiclesNeed["21"] + self._ADisVehiclesNeed["22"] + self._ADisVehiclesNeed["23"] + self._ADisVehiclesNeed["24"] +
self._ADisVehiclesNeed["25"] + self._ADisVehiclesNeed["26"] > 0) { // LF acts as 'Tragehilfe'
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["0"]--;
} else if (VehicleType == "NAW" && self._ADisVehiclesNeed["28"] > 0 && self._ADisVehiclesNeed["29"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["74"]--;
self._ADisVehiclesNeed["28"]--;
self._ADisVehiclesNeed["29"]--;
} else if (VehicleType == "GRTW" && self._ADisVehiclesNeed["73"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["73"]--;
} else if (VehicleType == "RTW" && self._ADisVehiclesNeed["28"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["28"]--;
} else if (VehicleType == "NEF" && self._ADisVehiclesNeed["29"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["29"]--;
} else if (VehicleType == "RTH" && self._ADisVehiclesNeed["31"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["31"]--;
} else if (VehicleType == "KdoW-LNA" && self._ADisVehiclesNeed["55"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["55"]--;
} else if (VehicleType == "KdoW-OrgL" && self._ADisVehiclesNeed["56"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["56"]--;
} else if (VehicleType == "KTW Typ B" && self._ADisVehiclesNeed["58"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["58"]--;
self._ADisVehiclesNeed["28"]--; // no need for RTW if KTW Type B is called
} else if (VehicleType == "ELW 1 (SEG)" && self._ADisVehiclesNeed["59"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["59"]--;
} else if (VehicleType == "GW-San" && self._ADisVehiclesNeed["60"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["60"]--;
self._ADisVehiclesNeed["29"]--; // no need for NEF if GW-SAN is called
}
});
return true;
}
return false;
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Process Fire_Department
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
ProcessFireDepartment() {
const self = this;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// -
// - Fire Department: Vehicles
// -
// - 0: LF 20
// - 1: LF 10
// - 6: LF 8/6
// - 7: LF 20/16
// - 8: LF 10/6
// - 9: LF 16-TS
// - 30: HLF 20
// - 37: TSF-W
// -
// - 17: TLF 2000
// - 18: TLF 3000
// - 19: TLF 8/8
// - 20: TLF 8/18
// - 21: TLF 16/24-Tr
// - 22: TLF 16/25
// - 23: TLF 16/45
// - 24: TLF 20/40
// - 25: TLF 20/40-SL
// - 26: TLF 16
// -
// - 2: DLK 23
// - 3: ELW 1
// - 34: ELW 2
// - 36: MTW
// - 57: FwK
// -
// - 4: RW
// - 5: GW-A
// - 10: GW-Öl
// - 12: GW-Mess
// - 53: GW-Dekon-P
// - 27: GW-Gefahrgut
// - 33: GW-Höhenrettung
// -
// - 11: GW-L2-Wasser
// - 13: SW 1000
// - 14: SW 2000
// - 15: SW 2000-Tr
// - 16: SW KatS
// -
// - 71: AB-MZB (see WaterRescue)
// -
// - 46: WLF
// - 47: AB-Rüst
// - 48: AB-Atemschutz
// - 49: AB-Öl
// - 54: AB-Dekon-P
// - 62: AB-Schlauch
// -
// - 75: FLF
// - 76: Rettungstreppe
// - 77: AB-Gefahrgut
// - 78: AB-Einsatzleitung
// -
// - 83: GW-Werkfeuerwehr
// - 84: ULF mit Löscharm
// - 85: TM 50
// - 86: Turbolöscher
// -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (typeof self.MissionConfig.fire_department == "object") // Wenn der FD-Block in der Config definiert ist
{
self._ADisVehiclesNeed["0"] += parseInt(self.MissionConfig.fire_department.num_LF);
self._ADisVehiclesNeed["3"] += parseInt(self.MissionConfig.fire_department.num_ELW_1);
self._ADisVehiclesNeed["34"] += parseInt(self.MissionConfig.fire_department.num_ELW_2);
self._ADisVehiclesNeed["2"] += parseInt(self.MissionConfig.fire_department.num_DLK);
self._ADisVehiclesNeed["4"] += parseInt(self.MissionConfig.fire_department.num_RW);
self._ADisVehiclesNeed["57"] += parseInt(self.MissionConfig.fire_department.num_FwK);
self._ADisVehiclesNeed["5"] += parseInt(self.MissionConfig.fire_department.num_GW_A);
self._ADisVehiclesNeed["27"] += parseInt(self.MissionConfig.fire_department.num_GW_G);
self._ADisVehiclesNeed["10"] += parseInt(self.MissionConfig.fire_department.num_GW_Oel);
self._ADisVehiclesNeed["12"] += parseInt(self.MissionConfig.fire_department.num_GW_Mess);
self._ADisVehiclesNeed["11"] += parseInt(self.MissionConfig.fire_department.num_SW);
self._ADisVehiclesNeed["33"] += parseInt(self.MissionConfig.fire_department.num_GW_Hoeh);
self._ADisVehiclesNeed["53"] += parseInt(self.MissionConfig.fire_department.num_Dekon_P);
self._ADisVehiclesNeed["75"] += parseInt(self.MissionConfig.fire_department.num_FLF);
self._ADisVehiclesNeed["76"] += parseInt(self.MissionConfig.fire_department.num_Rettungstreppe);
self._ADisVehiclesNeed["83"] += parseInt(self.MissionConfig.fire_department.num_GW_Werkfeuerwehr);
self._ADisVehiclesNeed["84"] += parseInt(self.MissionConfig.fire_department.num_ULF_mit_Loescharm);
self._ADisVehiclesNeed["86"] += parseInt(self.MissionConfig.fire_department.num_Turboloescher);
var dangerText = $('#iframe-inside-container > div.alert.alert-danger').text();
// TODO: need to check if already LF driving...
if (self.includesString(dangerText, "Wir benötigen noch min.") && self.includesString(dangerText, "Feuerwehrleute.")) {
const weNeed = self._ADisVehiclesNeed["0"];
const regex = /(\d+) Feuerwehrleute/gm;
const newNeed = Math.ceil(Number(parseInt(dangerText.match(regex))) / 6) - weNeed;
self._ADisVehiclesNeed["0"] = newNeed;
}
$("#vehicle_show_table_body_all").find(".vehicle_select_table_tr").each(function (_, elem) {
var VehicleID = $(elem).attr("id").replace("vehicle_element_content_", "");
// var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue");
var VehicleType = $(elem).attr("vehicle_type");
if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) {
return;
}
if ((VehicleType == "LF 20" || VehicleType == "LF 10" ||
VehicleType == "LF 8/6" || VehicleType == "LF 20/16" ||
VehicleType == "LF 10/6" || VehicleType == "LF 16-TS" ||
VehicleType == "HLF 20" || VehicleType == "TSF-W" ||
VehicleType == "TLF 2000" || VehicleType == "TLF 3000" ||
VehicleType == "TLF 8/8" || VehicleType == "TLF 8/18" ||
VehicleType == "TLF 16/24-Tr" || VehicleType == "TLF 16/25" ||
VehicleType == "TLF 16/45" || VehicleType == "TLF 20/40" ||
VehicleType == "TLF 20/40-SL" || VehicleType == "TLF 16") &&
self._ADisVehiclesNeed["0"] + self._ADisVehiclesNeed["1"] + self._ADisVehiclesNeed["6"] + self._ADisVehiclesNeed["7"] +
self._ADisVehiclesNeed["8"] + self._ADisVehiclesNeed["9"] + self._ADisVehiclesNeed["30"] + self._ADisVehiclesNeed["37"] +
self._ADisVehiclesNeed["17"] + self._ADisVehiclesNeed["18"] + self._ADisVehiclesNeed["19"] + self._ADisVehiclesNeed["20"] +
self._ADisVehiclesNeed["21"] + self._ADisVehiclesNeed["22"] + self._ADisVehiclesNeed["23"] + self._ADisVehiclesNeed["24"] +
self._ADisVehiclesNeed["25"] + self._ADisVehiclesNeed["26"] > 0) {
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["0"]--;
} else if (VehicleType == "HLF 20" && self._ADisVehiclesNeed["4"] > 0) // HLF 20 acts as RW
{
self._ADisVehiclesNeed["0"]--;
self._ADisVehiclesNeed["4"]--;
$("#vehicle_checkbox_" + VehicleID).click();
} else if ((VehicleType == "DLK 23" || VehicleType == "TM 50") && self._ADisVehiclesNeed["2"] > 0) // DLK 23
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["2"]--;
} else if (VehicleType == "AB-Einsatzleitung" &&
self._ADisVehiclesNeed["3"] + self._ADisVehiclesNeed["34"] + self._ADisVehiclesNeed["78"] > 0) // ELW 1 + ELW 2
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["3"]--;
self._ADisVehiclesNeed["34"]--;
} else if (VehicleType == "ELW 2" && self._ADisVehiclesNeed["3"] + self._ADisVehiclesNeed["34"] > 0) // ELW 2
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["3"]--;
self._ADisVehiclesNeed["34"]--;
} else if (VehicleType == "ELW 1" && self._ADisVehiclesNeed["3"] > 0) // ELW 1
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["3"]--;
} else if (VehicleType == "MTW" && self._ADisVehiclesNeed["36"] > 0) // MTW
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["36"]--;
} else if (VehicleType == "FwK" && self._ADisVehiclesNeed["57"] > 0) // FwK
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["57"]--;
} else if (VehicleType == "GWK" &&
self._ADisVehiclesNeed["4"] > 0) // GWK acts as RW
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["4"]--;
self._ADisVehiclesNeed["39"]--;
} else if ((VehicleType == "RW" ||
VehicleType == "HLF 20" ||
VehicleType == "AB-Rüst") &&
self._ADisVehiclesNeed["4"] > 0) // RW
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["4"]--;
} else if ((VehicleType == "GW-A" ||
VehicleType == "AB-Atemschutz") &&
self._ADisVehiclesNeed["5"] > 0) // GW-A
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["5"]--;
} else if ((VehicleType == "GW-Öl" ||
VehicleType == "AB-Öl") &&
self._ADisVehiclesNeed["10"] > 0) // GW-Öl
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["10"]--;
} else if (VehicleType == "GW-Messtechnik" && self._ADisVehiclesNeed["12"] > 0) // FwK
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["12"]--;
} else if ((VehicleType == "GW-L2-Wasser" ||
VehicleType == "SW 1000" ||
VehicleType == "SW 2000" ||
VehicleType == "SW 2000-Tr" ||
VehicleType == "SW Kats" ||
VehicleType == "AB-Schlauch") &&
self._ADisVehiclesNeed["11"] > 0) // SW
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["11"]--;
} else if ((VehicleType == "GW-Gefahrgut" ||
VehicleType == "AB-Gefahrgut") && self._ADisVehiclesNeed["27"] > 0) // GW-Gefahrgut
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["27"]--;
} else if (VehicleType == "GW-Höhenrettung" && self._ADisVehiclesNeed["33"] > 0) // GW-Höhenrettung
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["33"]--;
} else if ((VehicleType == "Dekon-P" ||
VehicleType == "AB-Dekon-P") &&
self._ADisVehiclesNeed["53"] > 0) // Dekon-P
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["53"]--;
} else if (VehicleType == "GW-Werkfeuerwehr" &&
self._ADisVehiclesNeed["83"] > 0) // GW-Werkfeuerwehr
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["83"]--;
} else if (VehicleType == "ULF mit Löscharm" &&
self._ADisVehiclesNeed["84"] > 0) // ULF mit Löscharm
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["84"]--;
}
/*
else if (VehicleType == "TM 50" &&
self._ADisVehiclesNeed["85"] > 0) // TM 50
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["85"]--;
}
*/
else if (VehicleType == "Turbolöscher" &&
self._ADisVehiclesNeed["86"] > 0) // Turbolöscher
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["86"]--;
} else if (VehicleType == "FLF" &&
self._ADisVehiclesNeed["75"] > 0) // FLF
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["75"]--;
} else if (VehicleType == "Rettungstreppe" &&
self._ADisVehiclesNeed["76"] > 0) // Rettungstreppe
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["76"]--;
}
});
return true;
}
return false;
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Process Police_Department
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
ProcessPoliceDepartment() {
const self = this;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// -
// - Fire Department: Vehicles
// -
// - 32: FuStW
// - 35: leBefKw
// - 50: GruKw
// - 51: FüKw
// - 52: GefKw
// - 72: WaWe
// - 61: Polizeihubschrauber
// - 79: SEK - ZF
// - 80: SEK - MTF
// - 81: MEK - ZF
// - 82: MEK - MTF
// -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (typeof self.MissionConfig.police_department == "object") // Wenn der FD-Block in der Config definiert ist
{
self._ADisVehiclesNeed["32"] += parseInt(self.MissionConfig.police_department.num_FuStW);
self._ADisVehiclesNeed["35"] += parseInt(self.MissionConfig.police_department.num_leBefKw);
self._ADisVehiclesNeed["50"] += parseInt(self.MissionConfig.police_department.num_GruKw);
self._ADisVehiclesNeed["51"] += parseInt(self.MissionConfig.police_department.num_FueKw);
self._ADisVehiclesNeed["52"] += parseInt(self.MissionConfig.police_department.num_GefKw);
self._ADisVehiclesNeed["72"] += parseInt(self.MissionConfig.police_department.num_WaWe);
self._ADisVehiclesNeed["61"] += parseInt(self.MissionConfig.police_department.num_PHu);
self._ADisVehiclesNeed["79"] += parseInt(self.MissionConfig.police_department.num_SEK_ZF);
self._ADisVehiclesNeed["80"] += parseInt(self.MissionConfig.police_department.num_SEK_MTF);
self._ADisVehiclesNeed["81"] += parseInt(self.MissionConfig.police_department.num_MEK_ZF);
self._ADisVehiclesNeed["82"] += parseInt(self.MissionConfig.police_department.num_MEK_MTF);
$("#vehicle_show_table_body_all").find(".vehicle_select_table_tr").each(function (_, elem) {
var VehicleID = $(elem).attr("id").replace("vehicle_element_content_", "");
// var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue");
var VehicleType = $(elem).attr("vehicle_type");
if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) {
return;
}
if (VehicleType == "FuStW" && self._ADisVehiclesNeed["32"] > 0) // FuStW
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["32"]--;
} else if (VehicleType == "leBefKw" && self._ADisVehiclesNeed["35"] > 0) // leBefKw
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["35"]--;
} else if (VehicleType == "GruKw" && self._ADisVehiclesNeed["50"] > 0) // GruKw
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["50"]--;
} else if (VehicleType == "FüKw" && self._ADisVehiclesNeed["51"] > 0) // FüKw
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["51"]--;
} else if (VehicleType == "GefKw" && self._ADisVehiclesNeed["52"] > 0) // GefKw
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["52"]--;
} else if (VehicleType == "WaWe 10" && self._ADisVehiclesNeed["72"] > 0) // WaWe 10
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["72"]--;
} else if (VehicleType == "Polizeihubschrauber" && self._ADisVehiclesNeed["61"] > 0) // PHu
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["61"]--;
} else if (VehicleType == "SEK - ZF" && self._ADisVehiclesNeed["79"] > 0) // SEK-ZF
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["79"]--;
} else if (VehicleType == "SEK - MTF" && self._ADisVehiclesNeed["80"] > 0) // SEK-MTF
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["80"]--;
} else if (VehicleType == "MEK - ZF" && self._ADisVehiclesNeed["81"] > 0) // MEK-ZF
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["81"]--;
} else if (VehicleType == "MEK - MTF" && self._ADisVehiclesNeed["82"] > 0) // MEK-MTF
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["82"]--;
}
});
return true;
}
return false;
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Process Water_Rescue
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
ProcessWaterRescue() {
const self = this;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// -
// - Water Rescue: Vehicles
// -
// - 63: GW-Taucher
// - 64: GW-Wasserrettung
// - 69: Tauchkraftwagen (handel it here;TechnicalEmergencyService)
// -
// - Boote:
// -
// - 66: Anh MzB (handel it here;TechnicalEmergencyService)
// - 67: Anh SchlB (handel it here;TechnicalEmergencyService)
// - 68: Anh MzAB (handel it here;TechnicalEmergencyService)
// - 70: MZB
// - 71: AB-MZB (handel it here;FireDepartment)
// -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (typeof self.MissionConfig.water_rescue == "object") {
self._ADisVehiclesNeed["63"] += parseInt(self.MissionConfig.water_rescue.num_GW_T);
self._ADisVehiclesNeed["64"] += parseInt(self.MissionConfig.water_rescue.num_GW_W);
self._ADisVehiclesNeed["70"] += parseInt(self.MissionConfig.water_rescue.num_MzB);
$("#vehicle_show_table_body_all").find(".vehicle_select_table_tr").each(function (_, elem) {
var VehicleID = $(elem).attr("id").replace("vehicle_element_content_", "");
// var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue");
var VehicleType = $(elem).attr("vehicle_type");
if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) {
return;
}
if ((VehicleType == "GW-Taucher" ||
VehicleType == "Tauchkraftwagen") && self._ADisVehiclesNeed["63"] > 0) // GW-Taucher
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["63"]--;
} else if (VehicleType == "GW-Wasserrettung" && self._ADisVehiclesNeed["64"] > 0) // GW-Wasserrettung
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["64"]--;
} else if ((VehicleType == "MZB" || VehicleType == "Anh MzB" ||
VehicleType == "Anh MzAB" || VehicleType == "Anh SchlB" ||
VehicleType == "AB-MZB") && self._ADisVehiclesNeed["66"] + self._ADisVehiclesNeed["67"] + self._ADisVehiclesNeed["68"] +
self._ADisVehiclesNeed["70"] + self._ADisVehiclesNeed["71"] > 0) // Boote
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["70"]--;
}
});
return true;
}
return false;
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
// -
// - Process Technical Emergency Service
// -
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
ProcessTechnicalEmergencyService() {
const self = this;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// -
// - THW: Vehicles
// -
// - 39: GKW (see also FireDepartment)
// - 40: MTW-TZ
// - 41: MzKW
// - 42: LKW K 9
// - 43: BRmG R
// -
// - 44: Anh DLE
// - 45: MLW 5
// - 65: LKW 7 Lkr 19 tm
// - 69: Tauchkraftwagen (see WaterRescue)
// -
// - 66: Anh MzB (see WaterRescue)
// - 67: Anh SchlB (see WaterRescue)
// - 68: Anh MzAB (see WaterRescue)
// -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (typeof self.MissionConfig.technical_emergency_service == "object") {
self._ADisVehiclesNeed["39"] += parseInt(self.MissionConfig.technical_emergency_service.num_GKW);
self._ADisVehiclesNeed["40"] += parseInt(self.MissionConfig.technical_emergency_service.num_MTW_TZ);
self._ADisVehiclesNeed["41"] += parseInt(self.MissionConfig.technical_emergency_service.num_MzKW);
self._ADisVehiclesNeed["42"] += parseInt(self.MissionConfig.technical_emergency_service.num_LKW_K9);
self._ADisVehiclesNeed["43"] += parseInt(self.MissionConfig.technical_emergency_service.num_BRmG_R);
self._ADisVehiclesNeed["44"] += parseInt(self.MissionConfig.technical_emergency_service.num_Anh_DLE);
self._ADisVehiclesNeed["45"] += parseInt(self.MissionConfig.technical_emergency_service.num_MLW_5);
self._ADisVehiclesNeed["65"] += parseInt(self.MissionConfig.technical_emergency_service.num_LKW_7Lkr);
$("#vehicle_show_table_body_all").find(".vehicle_select_table_tr").each(function (_, elem) {
var VehicleID = $(elem).attr("id").replace("vehicle_element_content_", "");
// var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue");
var VehicleType = $(elem).attr("vehicle_type");
if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) {
return;
}
if (VehicleType == "GKW" && self._ADisVehiclesNeed["39"] > 0) // GKW
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["39"]--;
} else if (VehicleType == "MTW-TZ" && self._ADisVehiclesNeed["40"] > 0) // MTW-TZ
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["40"]--;
} else if (VehicleType == "MzKW" && self._ADisVehiclesNeed["41"] > 0) // MzKW
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["41"]--;
} else if (VehicleType == "LKW K 9" && self._ADisVehiclesNeed["42"] > 0) // LKW K 9
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["42"]--;
} else if (VehicleType == "BRmG R" && self._ADisVehiclesNeed["43"] > 0) // BRmG R
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["43"]--;
} else if (VehicleType == "Anh DLE" && self._ADisVehiclesNeed["44"] > 0) // Anh DLE
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["44"]--;
} else if (VehicleType == "MLW 5" && self._ADisVehiclesNeed["45"] > 0) // MLW 5
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["45"]--;
} else if (VehicleType == "LKW 7 Lkr 19 tm" && self._ADisVehiclesNeed["65"] > 0) // LKW 7 Lkr 19 tm
{
$("#vehicle_checkbox_" + VehicleID).click();
self._ADisVehiclesNeed["65"]--;
}
});
return true;
}
return false;
}
PrepareVehicleNeedList() {
const self = this;
for (let VehicleTypeID = 0; VehicleTypeID <= self.MaxVehicleID; VehicleTypeID++) {
self._ADisVehiclesNeed[VehicleTypeID] = 0;
}
for (let VehicleTypeID = 0; VehicleTypeID <= self.MaxVehicleID; VehicleTypeID++) {
self.CountInvolvedVehiclesOfType(VehicleTypeID);
}
return true;
}
CountInvolvedVehiclesOfType(VehicleTypeID) {
const self = this;
for (var Key in self.Vehicles) {
var Vehicle = self.Vehicles[Key];
if (Vehicle.type == VehicleTypeID) {
self.SelectCountVehicles(VehicleTypeID);
}
};
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each(function (_, elem) {
if ($(elem).find("a").first().attr("vehicle_type_id") == VehicleTypeID) {
self.SelectCountVehicles(VehicleTypeID);
}
});
return;
}
SelectCountVehicles(VehicleTypeID) {
const self = this;
var VehicleTypeID = Number(VehicleTypeID);
if ([38].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed[VehicleTypeID]--;
} else if ([0, 1, 6, 7, 8, 9, 30, 37, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26].indexOf(VehicleTypeID) != -1) { // LF acts as 'Tragehilfe'
// 30 acts as Rüstwagen
if ([30].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["4"]--;
}
// 0 acts as all LF
self._ADisVehiclesNeed["0"]--;
} else if ([74].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["74"]--;
self._ADisVehiclesNeed["28"]--;
self._ADisVehiclesNeed["29"]--;
} else if ([73].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["73"]--;
} else if ([28].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["28"]--;
} else if ([29].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["29"]--;
} else if ([31].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["31"]--;
} else if ([55].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["55"]--;
} else if ([56].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["56"]--;
} else if ([58].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["58"]--;
} else if ([59].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["59"]--;
} else if ([60].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["60"]--;
} else if ([2].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["2"]--;
} else if ([34, 78].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["3"]--;
self._ADisVehiclesNeed["34"]--;
} else if ([3].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["3"]--;
} else if ([36].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["36"]--;
} else if ([57].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["57"]--;
} else if ([4, 39].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["4"]--;
self._ADisVehiclesNeed["39"]--;
} else if ([4, 47].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["4"]--;
} else if ([5, 48].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["5"]--;
} else if ([10, 49].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["10"]--;
} else if ([12].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["12"]--;
} else if ([11, 13, 14, 15, 16, 62].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["11"]--;
} else if ([27, 77].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["27"]--;
} else if ([33].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["33"]--;
} else if ([53, 54].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["53"]--;
} else if ([83].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["83"]--;
} else if ([84].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["84"]--;
} else if ([85].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["85"]--;
self._ADisVehiclesNeed["2"]--;
} else if ([86].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["86"]--;
} else if ([75].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["75"]--;
} else if ([76].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["76"]--;
} else if ([32].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["32"]--;
} else if ([35].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["35"]--;
} else if ([50].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["50"]--;
} else if ([51].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["51"]--;
} else if ([52].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["52"]--;
} else if ([72].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["72"]--;
} else if ([61].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["61"]--;
} else if ([79].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["79"]--;
} else if ([80].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["80"]--;
} else if ([81].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["81"]--;
} else if ([82].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["82"]--;
} else if ([63, 69].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["63"]--;
} else if ([64].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["64"]--;
} else if ([66, 67, 68, 70, 71].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["70"]--;
} else if ([40].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["40"]--;
} else if ([41].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["41"]--;
} else if ([42].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["42"]--;
} else if ([43].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["43"]--;
} else if ([44].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["44"]--;
} else if ([45].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["45"]--;
} else if ([65].indexOf(VehicleTypeID) != -1) {
self._ADisVehiclesNeed["65"]--;
}
}
CheckNeedMoreVehicles() {
const self = this;
var NeedMoreVehicles = false;
for (var Key in self._ADisVehiclesNeed) {
var VehicleCount = self._ADisVehiclesNeed[Key];
if (VehicleCount > 0) {
NeedMoreVehicles = true;
}
};
return NeedMoreVehicles;
}
}
$(document).ready(function () {
var $div = $("a.missing_vehicles_load:contains('Fahrzeuganzeige begrenzt! Fehlende Fahrzeuge laden!')");
//var isHidden = $div.is(':hidden');
var ppppp = undefined;
//var MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
//console.log('DEBUG::', MissionID, $div, isHidden);
if ($div.length >= 1) {
//console.log('DEBUG::', MissionID, 'Start Observer');
var observer = new MutationObserver(function (mutations) {
//console.log('DEBUG::', 'mutations', mutations)
mutations.forEach(function (mutation) {
//console.log('DEBUG::', 'mutation', mutation)
if (mutation.attributeName === "style") {
if ($(mutation.target).css('display') == 'none') {
if (typeof ppppp != 'undefined') {
clearTimeout(ppppp);
}
ppppp = setTimeout(function () {
//window.console.log('DEBUG:::', 'Start Observer AutomaticDispose()')
window.AutomaticDisposeCall = new AutomaticDispose(window.faye);
}, 250);
}
} else if (mutation.attributeName === "href") {
if (typeof ppppp != 'undefined') {
clearTimeout(ppppp);
}
$(mutation.target).click();
}
});
});
$div.each(function (index, item) {
observer.observe(item, {
attributes: true,
characterData: true,
attributeOldValue: true,
characterDataOldValue: true
});
})
$div.click();
} else {
//window.console.log('DEBUG:::', 'Start AutomaticDispose()')
window.AutomaticDisposeCall = new AutomaticDispose(window.faye);
}
});