807 lines
30 KiB
JavaScript
807 lines
30 KiB
JavaScript
//=require ../node_modules/dexie/dist/dexie.js
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
constructor() {
|
|
let that = this;
|
|
|
|
this.ADis_MyHead = document.getElementsByTagName('head')[0];
|
|
this.ADis_MyBody = document.getElementsByTagName('body')[0];
|
|
|
|
// -
|
|
// - Sprechwunsch Variablen
|
|
// -
|
|
this.Jails = [];
|
|
this.JailRegEx = /\(Freie Zellen\:\s+(\d)\,\s+Entfernung\:\s+(\d+\,\d+)\s+km(?:\,\s+Abgabe an Besitzer\:\s+(\d+)%)?\)/g;
|
|
this.Hospitals = [];
|
|
this.RescueVehicleFrameWatchDog = null;
|
|
this.PoliceVehicleFrameWatchDog = null;
|
|
|
|
|
|
|
|
this.ADisDB = new Dexie('LSS_AutomaticDispo');
|
|
this.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",
|
|
/**
|
|
* Krankentransport
|
|
* - missionID
|
|
* - done
|
|
*/
|
|
ADisKrankentransport: "++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
|
|
*/
|
|
ADisMissionsOwn: "++missionID,type,name,last_check,next_check,available,done",
|
|
ADisMissionsVerband: "++missionID,type,name,last_check,next_check,available,done",
|
|
ADisMissionsVerbandEvent: "++missionID,type,name,last_check,next_check,available,done",
|
|
});
|
|
this.ADisDB.on("populate", function () {
|
|
that.ADisDB.ADisSettings.add({
|
|
name: "Krankentransport-Automatic",
|
|
value: 'true'
|
|
});
|
|
that.ADisDB.ADisSettings.add({
|
|
name: "Sprechwunsch-Automatic",
|
|
value: 'true'
|
|
});
|
|
that.ADisDB.ADisSettings.add({
|
|
name: "MissionsOwn-Automatic",
|
|
value: 'true'
|
|
});
|
|
that.ADisDB.ADisSettings.add({
|
|
name: "Alliance-Automatic",
|
|
value: 'false'
|
|
});
|
|
that.ADisDB.ADisSettings.add({
|
|
name: "AllianceEvent-Automatic",
|
|
value: 'false'
|
|
});
|
|
});
|
|
this.ADisDB.open().catch(function (err) {
|
|
console.error(err.stack || err);
|
|
});
|
|
this.ADisDB.on("ready", () => {
|
|
|
|
if (window.location.pathname === "/" || window.location.pathname === "/#") {
|
|
that.IndexPage()
|
|
setInterval(that.CollectRescueSprechwuensche.bind(that), 2500);
|
|
setInterval(that.OpenNextRescueSprechwunsch.bind(that), 5000);
|
|
that.CollectRescueSprechwuensche();
|
|
setInterval(that.CollectPoliceSprechwuensche.bind(that), 2500);
|
|
setInterval(that.OpenNextPoliceSprechwunsch.bind(that), 5000);
|
|
that.CollectPoliceSprechwuensche();
|
|
}
|
|
|
|
/**
|
|
* / /=require ../script/mission.js
|
|
*/
|
|
// -
|
|
// - Sprechwunsch Handler Rettung
|
|
// -
|
|
if (window.location.pathname.indexOf("/vehicles/") !== -1 && window.name == 'adis-sprechwunsch-rescue') {
|
|
that.Check_Call_Hospitals();
|
|
}
|
|
|
|
// -
|
|
// - Sprechwunsch Handler Polizei/Gefangene
|
|
// -
|
|
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
|
|
that.Check_Call_Police_Active();
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
get Settings() {
|
|
console.log('static', this.ADisSettings);
|
|
console.log('static WindowName', this);
|
|
return this.ADisSettings;
|
|
}
|
|
|
|
includesString(string1, string2) {
|
|
return string1.toLowerCase().includes(string2.toLowerCase());
|
|
}
|
|
|
|
ADSettings() {
|
|
let that = this;
|
|
return new Promise(async (resolve, reject) => {
|
|
let res = {};
|
|
await that.ADisDB.ADisSettings.each((setting) => {
|
|
res[setting.name] = setting.value;
|
|
});
|
|
resolve(res);
|
|
})
|
|
}
|
|
|
|
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 that = this;
|
|
new Promise(async function (resolve, reject) {
|
|
await that.ADisDB.ADisSprechwunsch.where({
|
|
done: 'false'
|
|
}).each((myWunsch) => {
|
|
if ($("#vehicle_list_" + myWunsch.vehicleID).find(".building_list_fms").text() != "5") {
|
|
that.RemoveRescueSprechwunschFromQueue(myWunsch.vehicleID);
|
|
}
|
|
})
|
|
return resolve();
|
|
}).then(() => {
|
|
$("#building_list").find(".building_list_vehicle_element").each(function () {
|
|
var VehicleStatus = $(this).find(".building_list_fms").text();
|
|
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
|
var VehicleID = $(this).attr("vehicle_id");
|
|
if (VehicleStatus == "5" && [32, 52].indexOf(VehicleType) === -1) {
|
|
that.AddRescueSprechwunschToQueue(VehicleID);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
OpenNextRescueSprechwunsch() {
|
|
let that = this;
|
|
this.ADSettings().then((setting) => {
|
|
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
|
return that.ADisDB.ADisSprechwunsch.where({
|
|
done: 'false'
|
|
}).limit(1)
|
|
}
|
|
}).then((Wunsch) => {
|
|
if (Wunsch !== undefined) {
|
|
Wunsch.each((myWunsch) => {
|
|
let VehicleID = myWunsch.vehicleID;
|
|
that.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);
|
|
|
|
that.RescueVehicleFrameWatchDog = setTimeout(async function () {
|
|
that.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 that = this;
|
|
that.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) {
|
|
that.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) {
|
|
that.Hospitals.push({
|
|
"id": HospitalID,
|
|
"value": HospitalValue,
|
|
"taxes": HospitalTaxes,
|
|
"distance": HospitalDistance,
|
|
"href": HospitalHref
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
that.Hospitals.sort(function (a, b) {
|
|
return a.value - b.value;
|
|
});
|
|
|
|
that.Hospitals.reverse();
|
|
this.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 that = this;
|
|
new Promise(async function (resolve, reject) {
|
|
await that.ADisDB.ADisSprechwunschPolice.where({
|
|
done: 'false'
|
|
}).each((myWunsch) => {
|
|
if (!$("#mission_" + myWunsch.missionID).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
|
$("#mission_" + myWunsch.missionID).remove();
|
|
return that.RemovePoliceSprechwunschFromQueue(myWunsch.missionID);
|
|
}
|
|
})
|
|
return resolve();
|
|
}).then(() => {
|
|
var MOIODOS = $('div#mission_list div.missionSideBarEntry:visible');
|
|
return MOIODOS.each(function (index) {
|
|
if ($(this).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
|
var MissionID = $(this).attr("mission_id");
|
|
that.AddPoliceSprechwunschToQueue(MissionID);
|
|
}
|
|
});
|
|
}).then(() => {
|
|
$("#building_list").find(".building_list_vehicle_element").each(function () {
|
|
var VehicleStatus = $(this).find(".building_list_fms").text();
|
|
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
|
var VehicleID = $(this).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) {
|
|
that.AddPoliceSprechwunschToQueue(MissionID);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
OpenNextPoliceSprechwunsch() {
|
|
let that = this;
|
|
this.ADSettings().then((setting) => {
|
|
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
|
return that.ADisDB.ADisSprechwunschPolice.where({
|
|
done: 'false'
|
|
}).limit(1)
|
|
}
|
|
}).then((Wunsch) => {
|
|
if (Wunsch !== undefined) {
|
|
Wunsch.each((myWunsch) => {
|
|
let MissionID = myWunsch.missionID;
|
|
that.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);
|
|
|
|
that.PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) {
|
|
that.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
|
|
$("#adis-sprechwunsch-police-frame").attr("src", "");
|
|
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
|
|
});
|
|
}, 2500, 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() {
|
|
if ($('#h2_prisoners').length > 0) {
|
|
this.Collect_Jails();
|
|
} else {
|
|
this.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
|
|
$("#adis-sprechwunsch-police-frame").attr("src", "");
|
|
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
|
|
});
|
|
}
|
|
}
|
|
|
|
// Gefängnis auswählen
|
|
Collect_Jails() {
|
|
let that = this;
|
|
that.Jails = [];
|
|
var CountGefangene = Number(parseInt($('#h2_prisoners').text()));
|
|
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(function () {
|
|
var JailHref = $(this).attr("href");
|
|
var JailID = JailHref.split("/").pop();
|
|
var JailText = $(this).text();
|
|
var JailFreeBeds = 0;
|
|
var JailDistance = 0;
|
|
var JailTax = 0;
|
|
let m;
|
|
while ((m = that.JailRegEx.exec(JailText)) !== null) {
|
|
// This is necessary to avoid infinite loops with zero-width matches
|
|
if (m.index === that.JailRegEx.lastIndex) {
|
|
that.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) {
|
|
that.Jails.push({
|
|
"id": JailID,
|
|
"value": JailValue + 1000,
|
|
"text": JailText,
|
|
"distance": JailDistance,
|
|
"href": JailHref
|
|
});
|
|
} else if (JailFreeBeds >= 1) {
|
|
that.Jails.push({
|
|
"id": JailID,
|
|
"value": JailValue,
|
|
"text": JailText,
|
|
"distance": JailDistance,
|
|
"href": JailHref
|
|
});
|
|
}
|
|
});
|
|
FuStWGefaegnisse.find("a:contains('Freie Zellen')").each(function () {
|
|
var JailHref = $(this).attr("href");
|
|
var JailID = JailHref.split("/").pop();
|
|
var JailText = $(this).text();
|
|
var JailFreeBeds = 0;
|
|
var JailDistance = 0;
|
|
var JailTax = 0;
|
|
let m;
|
|
while ((m = that.JailRegEx.exec(JailText)) !== null) {
|
|
// This is necessary to avoid infinite loops with zero-width matches
|
|
if (m.index === that.JailRegEx.lastIndex) {
|
|
that.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) {
|
|
that.Jails.push({
|
|
"id": JailID,
|
|
"value": JailValue + 1000,
|
|
"text": JailText,
|
|
"distance": JailDistance,
|
|
"href": JailHref
|
|
});
|
|
} else if (JailFreeBeds >= 1) {
|
|
that.Jails.push({
|
|
"id": JailID,
|
|
"value": JailValue,
|
|
"text": JailText,
|
|
"distance": JailDistance,
|
|
"href": JailHref
|
|
});
|
|
}
|
|
});
|
|
|
|
that.Jails.sort(function (a, b) {
|
|
return a.value - b.value;
|
|
});
|
|
|
|
that.Jails.reverse();
|
|
if (that.Jails.length > 0) {
|
|
this.Send_Vehicle_To_Jail()
|
|
} else {
|
|
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each(function () {
|
|
var CalledVehicleID = parseInt($(this).find("a").first().attr("vehicle_type_id"));
|
|
if (CalledVehicleID == 52) {
|
|
CountGefangene -= 5;
|
|
} else if (CalledVehicleID == 32) {
|
|
CountGefangene -= 1;
|
|
}
|
|
});
|
|
|
|
if ($('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').size() > 0 && CountGefangene >= 5) {
|
|
$('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').each(function () {
|
|
if (CountGefangene > 0) {
|
|
$(this).click()
|
|
CountGefangene -= 5;
|
|
}
|
|
});
|
|
}
|
|
if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').size() > 0 && CountGefangene > 0) {
|
|
$('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').each(function () {
|
|
if (CountGefangene > 0) {
|
|
$(this).click()
|
|
CountGefangene -= 1;
|
|
}
|
|
});
|
|
}
|
|
if ($('#vehicle_show_table_all input[type="checkbox"]:checked').size() > 0) {
|
|
$('#mission_alarm_btn').click();
|
|
}
|
|
}
|
|
}
|
|
|
|
// Gefängnis einlieferung
|
|
Send_Vehicle_To_Jail() {
|
|
var JailHref = this.Jails[0].href
|
|
document.location.href = document.location.origin + JailHref;
|
|
}
|
|
|
|
// -
|
|
// - Index Page Loader
|
|
// -
|
|
IndexPage() {
|
|
let that = 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";
|
|
this.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";
|
|
this.ADis_MyHead.appendChild(scriptElement);
|
|
|
|
// -
|
|
// - Navbar Dashboard
|
|
// -
|
|
var styleElement = document.createElement("link");
|
|
styleElement.rel = "stylesheet";
|
|
styleElement.type = "text/css";
|
|
styleElement.media = "screen";
|
|
styleElement.href = this.ADisSettings.url + this.ADisSettings.branch + "/style/interface.css";
|
|
this.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(function () {
|
|
var tf = $(this).hasClass("active");
|
|
that.ADisDB.ADisSettings.put({
|
|
name: "Krankentransport-Automatic",
|
|
value: !tf ? 'true' : 'false'
|
|
}).then((res) => {
|
|
that.UIUpdateSettings();
|
|
});
|
|
});
|
|
|
|
$("#adis-setting-full-automatic").click(function () {
|
|
var tf = $(this).hasClass("active");
|
|
that.ADisDB.ADisSettings.put({
|
|
name: "MissionsOwn-Automatic",
|
|
value: !tf ? 'true' : 'false'
|
|
}).then(() => {
|
|
that.UIUpdateSettings();
|
|
});
|
|
});
|
|
|
|
$("#adis-setting-sprechwunsch-automatic").click(function () {
|
|
var tf = $(this).hasClass("active");
|
|
that.ADisDB.ADisSettings.put({
|
|
name: "Sprechwunsch-Automatic",
|
|
value: !tf ? 'true' : 'false'
|
|
}).then(() => {
|
|
that.UIUpdateSettings();
|
|
});
|
|
});
|
|
|
|
$("#adis-setting-alliance-automatic").click(function () {
|
|
var tf = $(this).hasClass("active");
|
|
that.ADisDB.ADisSettings.put({
|
|
name: "Alliance-Automatic",
|
|
value: !tf ? 'true' : 'false'
|
|
}).then(() => {
|
|
that.UIUpdateSettings();
|
|
});
|
|
});
|
|
|
|
$("#adis-setting-alliance-automatic").click(function () {
|
|
var tf = $(this).hasClass("active");
|
|
that.ADisDB.ADisSettings.put({
|
|
name: "AllianceEvent-Automatic",
|
|
value: !tf ? 'true' : 'false'
|
|
}).then(() => {
|
|
that.UIUpdateSettings();
|
|
});
|
|
});
|
|
|
|
//
|
|
// Dashboard Functions
|
|
//
|
|
|
|
$("#adis-open-button").click(function () {
|
|
$("#adis-dashboard").css("display", "flex");
|
|
$("#adis-dashboard").animate({
|
|
opacity: 1
|
|
}, 200);
|
|
});
|
|
$("#adis-dashboard-close-button").click(function () {
|
|
$("#adis-dashboard").animate({
|
|
opacity: 0
|
|
}, 200, function () {
|
|
$(this).css("display", "none");
|
|
});
|
|
});
|
|
|
|
// initial call to load the current setting state
|
|
that.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");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
window.AutomaticDisposeCall = new AutomaticDispose(); |