v2 up 0293
This commit is contained in:
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
/*Generated on:Thu Nov 29 2018 10:40:15 GMT+0100 (CET)*/
|
/*Generated on:Sat Dec 01 2018 12:58:16 GMT+0100 (CET)*/
|
||||||
var AutomaticDispose_Branch = "master";
|
var AutomaticDispose_Branch = "master";
|
||||||
var AutomaticDispose_URL = "https://jf.git.rest/Jomaar/automatic-dispose/raw/branch/";
|
var AutomaticDispose_URL = "https://jf.git.rest/Jomaar/automatic-dispose/raw/branch/";
|
||||||
var da_lss_adis_time = new Date().getTime();
|
var da_lss_adis_time = new Date().getTime();
|
||||||
|
|||||||
Vendored
+316
-94
@@ -1,4 +1,4 @@
|
|||||||
/*Generated on:Thu Nov 29 2018 10:40:15 GMT+0100 (CET)*/
|
/*Generated on:Sat Dec 01 2018 12:58:16 GMT+0100 (CET)*/
|
||||||
/*
|
/*
|
||||||
* Dexie.js - a minimalistic wrapper for IndexedDB
|
* Dexie.js - a minimalistic wrapper for IndexedDB
|
||||||
* ===============================================
|
* ===============================================
|
||||||
@@ -16901,12 +16901,17 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`),
|
}`),
|
||||||
name: this.name
|
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() {
|
constructor() {
|
||||||
let that = this;
|
let self = this;
|
||||||
|
|
||||||
this.ADis_MyHead = document.getElementsByTagName('head')[0];
|
this.ADis_MyHead = document.getElementsByTagName('head')[0];
|
||||||
this.ADis_MyBody = document.getElementsByTagName('body')[0];
|
this.ADis_MyBody = document.getElementsByTagName('body')[0];
|
||||||
@@ -16970,47 +16975,53 @@ class AutomaticDispose {
|
|||||||
* - village
|
* - village
|
||||||
* - last_check
|
* - last_check
|
||||||
* - next_check
|
* - next_check
|
||||||
|
* - runner - type (kt = krankentransport, om = own missions, os = sicherheitswache, vm = verband missions, ve = verband events)
|
||||||
*/
|
*/
|
||||||
ADisMissionsOwn: "++missionID,type,name,last_check,next_check,available,done",
|
ADisMissionsOwn: "++missionID,type,name,last_check,next_check,available,done",
|
||||||
ADisMissionsVerband: "++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",
|
ADisMissionsVerbandEvent: "++missionID,type,name,last_check,next_check,available,done",
|
||||||
|
ADisMissions: "++missionID,runner,available,done,[missionID+available+done],[runner+available+done]"
|
||||||
});
|
});
|
||||||
this.ADisDB.on("populate", function () {
|
this.ADisDB.on("populate", () => {
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "Krankentransport-Automatic",
|
name: "Krankentransport-Automatic",
|
||||||
value: 'true'
|
value: 'true'
|
||||||
});
|
});
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "Sprechwunsch-Automatic",
|
name: "Sprechwunsch-Automatic",
|
||||||
value: 'true'
|
value: 'true'
|
||||||
});
|
});
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "MissionsOwn-Automatic",
|
name: "MissionsOwn-Automatic",
|
||||||
value: 'true'
|
value: 'true'
|
||||||
});
|
});
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "Alliance-Automatic",
|
name: "Alliance-Automatic",
|
||||||
value: 'false'
|
value: 'false'
|
||||||
});
|
});
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "AllianceEvent-Automatic",
|
name: "AllianceEvent-Automatic",
|
||||||
value: 'false'
|
value: 'false'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.ADisDB.open().catch(function (err) {
|
this.ADisDB.open().catch((err) => {
|
||||||
console.error(err.stack || err);
|
console.error(err.stack || err);
|
||||||
});
|
});
|
||||||
this.ADisDB.on("ready", () => {
|
this.ADisDB.on("ready", () => {
|
||||||
|
|
||||||
if (window.location.pathname === "/" || window.location.pathname === "/#") {
|
if (window.location.pathname === "/" || window.location.pathname === "/#") {
|
||||||
that.GetAvailableMissions()
|
self.GetAvailableMissions()
|
||||||
that.IndexPage()
|
self.IndexPage()
|
||||||
setInterval(that.CollectRescueSprechwuensche.bind(that), 2500);
|
setInterval(self.CollectRescueSprechwuensche.bind(self), 2500);
|
||||||
setInterval(that.OpenNextRescueSprechwunsch.bind(that), 5000);
|
setInterval(self.OpenNextRescueSprechwunsch.bind(self), 5000);
|
||||||
that.CollectRescueSprechwuensche();
|
self.CollectRescueSprechwuensche();
|
||||||
setInterval(that.CollectPoliceSprechwuensche.bind(that), 2500);
|
setInterval(self.CollectPoliceSprechwuensche.bind(self), 2500);
|
||||||
setInterval(that.OpenNextPoliceSprechwunsch.bind(that), 5000);
|
setInterval(self.OpenNextPoliceSprechwunsch.bind(self), 5000);
|
||||||
that.CollectPoliceSprechwuensche();
|
self.CollectPoliceSprechwuensche();
|
||||||
|
self.CollectMissions();
|
||||||
|
self.ADisSettings.runner.forEach((runner) => {
|
||||||
|
self.OpenNextMission(runner)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17020,14 +17031,14 @@ class AutomaticDispose {
|
|||||||
// - Sprechwunsch Handler Rettung
|
// - Sprechwunsch Handler Rettung
|
||||||
// -
|
// -
|
||||||
if (window.location.pathname.indexOf("/vehicles/") !== -1 && window.name == 'adis-sprechwunsch-rescue') {
|
if (window.location.pathname.indexOf("/vehicles/") !== -1 && window.name == 'adis-sprechwunsch-rescue') {
|
||||||
that.Check_Call_Hospitals();
|
self.Check_Call_Hospitals();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -
|
// -
|
||||||
// - Sprechwunsch Handler Polizei/Gefangene
|
// - Sprechwunsch Handler Polizei/Gefangene
|
||||||
// -
|
// -
|
||||||
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
|
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
|
||||||
that.Check_Call_Police_Active();
|
self.Check_Call_Police_Active();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -17044,10 +17055,10 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ADSettings() {
|
ADSettings() {
|
||||||
let that = this;
|
let self = this;
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let res = {};
|
let res = {};
|
||||||
await that.ADisDB.ADisSettings.each((setting) => {
|
await self.ADisDB.ADisSettings.each((setting) => {
|
||||||
res[setting.name] = setting.value;
|
res[setting.name] = setting.value;
|
||||||
});
|
});
|
||||||
resolve(res);
|
resolve(res);
|
||||||
@@ -17079,33 +17090,33 @@ class AutomaticDispose {
|
|||||||
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||||
|
|
||||||
CollectRescueSprechwuensche() {
|
CollectRescueSprechwuensche() {
|
||||||
let that = this;
|
let self = this;
|
||||||
new Promise(async function (resolve, reject) {
|
new Promise(async (resolve, reject) => {
|
||||||
await that.ADisDB.ADisSprechwunsch.where({
|
await self.ADisDB.ADisSprechwunsch.where({
|
||||||
done: 'false'
|
done: 'false'
|
||||||
}).each((myWunsch) => {
|
}).each((myWunsch) => {
|
||||||
if ($("#vehicle_list_" + myWunsch.vehicleID).find(".building_list_fms").text() != "5") {
|
if ($("#vehicle_list_" + myWunsch.vehicleID).find(".building_list_fms").text() != "5") {
|
||||||
that.RemoveRescueSprechwunschFromQueue(myWunsch.vehicleID);
|
self.RemoveRescueSprechwunschFromQueue(myWunsch.vehicleID);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return resolve();
|
return resolve();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
$("#building_list").find(".building_list_vehicle_element").each(function () {
|
$("#building_list").find(".building_list_vehicle_element").each(() => {
|
||||||
var VehicleStatus = $(this).find(".building_list_fms").text();
|
var VehicleStatus = $(this).find(".building_list_fms").text();
|
||||||
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
||||||
var VehicleID = $(this).attr("vehicle_id");
|
var VehicleID = $(this).attr("vehicle_id");
|
||||||
if (VehicleStatus == "5" && [32, 52].indexOf(VehicleType) === -1) {
|
if (VehicleStatus == "5" && [32, 52].indexOf(VehicleType) === -1) {
|
||||||
that.AddRescueSprechwunschToQueue(VehicleID);
|
self.AddRescueSprechwunschToQueue(VehicleID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenNextRescueSprechwunsch() {
|
OpenNextRescueSprechwunsch() {
|
||||||
let that = this;
|
let self = this;
|
||||||
this.ADSettings().then((setting) => {
|
this.ADSettings().then((setting) => {
|
||||||
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
||||||
return that.ADisDB.ADisSprechwunsch.where({
|
return self.ADisDB.ADisSprechwunsch.where({
|
||||||
done: 'false'
|
done: 'false'
|
||||||
}).limit(1)
|
}).limit(1)
|
||||||
}
|
}
|
||||||
@@ -17113,13 +17124,13 @@ class AutomaticDispose {
|
|||||||
if (Wunsch !== undefined) {
|
if (Wunsch !== undefined) {
|
||||||
Wunsch.each((myWunsch) => {
|
Wunsch.each((myWunsch) => {
|
||||||
let VehicleID = myWunsch.vehicleID;
|
let VehicleID = myWunsch.vehicleID;
|
||||||
that.UpdateRescueSprechwunschToDone(VehicleID).then(() => {
|
self.UpdateRescueSprechwunschToDone(VehicleID).then(() => {
|
||||||
if ($("#adis-sprechwunsch-rescue-frame").attr("vehicle_id") == "empty") {
|
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("src", "https://www.leitstellenspiel.de/vehicles/" + VehicleID);
|
||||||
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", VehicleID);
|
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", VehicleID);
|
||||||
|
|
||||||
that.RescueVehicleFrameWatchDog = setTimeout(async function () {
|
self.RescueVehicleFrameWatchDog = setTimeout(async () => {
|
||||||
that.RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => {
|
self.RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => {
|
||||||
$("#adis-sprechwunsch-rescue-frame").attr("src", "");
|
$("#adis-sprechwunsch-rescue-frame").attr("src", "");
|
||||||
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty");
|
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty");
|
||||||
});
|
});
|
||||||
@@ -17161,10 +17172,10 @@ class AutomaticDispose {
|
|||||||
|
|
||||||
// Krankenhaus auswählen
|
// Krankenhaus auswählen
|
||||||
Collect_Hospitals() {
|
Collect_Hospitals() {
|
||||||
let that = this;
|
let self = this;
|
||||||
that.Hospitals = [];
|
self.Hospitals = [];
|
||||||
if ($("h4:contains('Eigene Krankenhäuser')").length > 0) {
|
if ($("h4:contains('Eigene Krankenhäuser')").length > 0) {
|
||||||
$("h4:contains('Eigene Krankenhäuser')").next("table").find("tbody").find("tr").each(function () {
|
$("h4:contains('Eigene Krankenhäuser')").next("table").find("tbody").find("tr").each(() => {
|
||||||
var HospitalHref = $(this).find("a:contains('Anfahren')").attr("href");
|
var HospitalHref = $(this).find("a:contains('Anfahren')").attr("href");
|
||||||
var HospitalID = Number(parseInt($(this).find("a:contains('Anfahren')").attr("id").replace("btn_approach_", "")));
|
var HospitalID = Number(parseInt($(this).find("a:contains('Anfahren')").attr("id").replace("btn_approach_", "")));
|
||||||
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
||||||
@@ -17177,7 +17188,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (HospitalFreeBeds > 0) {
|
if (HospitalFreeBeds > 0) {
|
||||||
that.Hospitals.push({
|
self.Hospitals.push({
|
||||||
"id": HospitalID,
|
"id": HospitalID,
|
||||||
"value": HospitalValue,
|
"value": HospitalValue,
|
||||||
"distance": HospitalDistance,
|
"distance": HospitalDistance,
|
||||||
@@ -17188,7 +17199,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($("h4:contains('Verbandskrankenhäuser')").length > 0) {
|
if ($("h4:contains('Verbandskrankenhäuser')").length > 0) {
|
||||||
$("h4:contains('Verbandskrankenhäuser')").next("table").find("tbody").find("tr").each(function () {
|
$("h4:contains('Verbandskrankenhäuser')").next("table").find("tbody").find("tr").each(() => {
|
||||||
var HospitalHref = $(this).find("a").attr("href")
|
var HospitalHref = $(this).find("a").attr("href")
|
||||||
var HospitalID = Number(parseInt(HospitalHref.substr(HospitalHref.lastIndexOf("/") + 1)));
|
var HospitalID = Number(parseInt(HospitalHref.substr(HospitalHref.lastIndexOf("/") + 1)));
|
||||||
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
||||||
@@ -17217,7 +17228,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (HospitalFreeBeds > 0 && HospitalSpecialDepartment) {
|
if (HospitalFreeBeds > 0 && HospitalSpecialDepartment) {
|
||||||
that.Hospitals.push({
|
self.Hospitals.push({
|
||||||
"id": HospitalID,
|
"id": HospitalID,
|
||||||
"value": HospitalValue,
|
"value": HospitalValue,
|
||||||
"taxes": HospitalTaxes,
|
"taxes": HospitalTaxes,
|
||||||
@@ -17228,11 +17239,11 @@ class AutomaticDispose {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
that.Hospitals.sort(function (a, b) {
|
self.Hospitals.sort((a, b) => {
|
||||||
return a.value - b.value;
|
return a.value - b.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
that.Hospitals.reverse();
|
self.Hospitals.reverse();
|
||||||
this.Send_Vehicle_To_Hospital()
|
this.Send_Vehicle_To_Hospital()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17253,27 +17264,27 @@ class AutomaticDispose {
|
|||||||
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||||
|
|
||||||
CollectPoliceSprechwuensche() {
|
CollectPoliceSprechwuensche() {
|
||||||
let that = this;
|
let self = this;
|
||||||
new Promise(async function (resolve, reject) {
|
new Promise(async (resolve, reject) => {
|
||||||
await that.ADisDB.ADisSprechwunschPolice.where({
|
await self.ADisDB.ADisSprechwunschPolice.where({
|
||||||
done: 'false'
|
done: 'false'
|
||||||
}).each((myWunsch) => {
|
}).each((myWunsch) => {
|
||||||
if (!$("#mission_" + myWunsch.missionID).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
if (!$("#mission_" + myWunsch.missionID).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
||||||
$("#mission_" + myWunsch.missionID).remove();
|
$("#mission_" + myWunsch.missionID).remove();
|
||||||
return that.RemovePoliceSprechwunschFromQueue(myWunsch.missionID);
|
return self.RemovePoliceSprechwunschFromQueue(myWunsch.missionID);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return resolve();
|
return resolve();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
var MOIODOS = $('div#mission_list div.missionSideBarEntry:visible');
|
var MOIODOS = $('div#mission_list div.missionSideBarEntry:visible');
|
||||||
return MOIODOS.each(function (index) {
|
return MOIODOS.each(() => {
|
||||||
if ($(this).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
if ($(this).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
||||||
var MissionID = $(this).attr("mission_id");
|
var MissionID = $(this).attr("mission_id");
|
||||||
that.AddPoliceSprechwunschToQueue(MissionID);
|
self.AddPoliceSprechwunschToQueue(MissionID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
$("#building_list").find(".building_list_vehicle_element").each(function () {
|
$("#building_list").find(".building_list_vehicle_element").each(() => {
|
||||||
var VehicleStatus = $(this).find(".building_list_fms").text();
|
var VehicleStatus = $(this).find(".building_list_fms").text();
|
||||||
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
||||||
var VehicleID = $(this).attr("vehicle_id");
|
var VehicleID = $(this).attr("vehicle_id");
|
||||||
@@ -17283,7 +17294,7 @@ class AutomaticDispose {
|
|||||||
var _meap = String(map2.attr('href'));
|
var _meap = String(map2.attr('href'));
|
||||||
var MissionID = _meap.substr(_meap.lastIndexOf("/") + 1);
|
var MissionID = _meap.substr(_meap.lastIndexOf("/") + 1);
|
||||||
if (MissionID) {
|
if (MissionID) {
|
||||||
that.AddPoliceSprechwunschToQueue(MissionID);
|
self.AddPoliceSprechwunschToQueue(MissionID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17292,10 +17303,10 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OpenNextPoliceSprechwunsch() {
|
OpenNextPoliceSprechwunsch() {
|
||||||
let that = this;
|
let self = this;
|
||||||
this.ADSettings().then((setting) => {
|
this.ADSettings().then((setting) => {
|
||||||
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
||||||
return that.ADisDB.ADisSprechwunschPolice.where({
|
return self.ADisDB.ADisSprechwunschPolice.where({
|
||||||
done: 'false'
|
done: 'false'
|
||||||
}).limit(1)
|
}).limit(1)
|
||||||
}
|
}
|
||||||
@@ -17303,13 +17314,13 @@ class AutomaticDispose {
|
|||||||
if (Wunsch !== undefined) {
|
if (Wunsch !== undefined) {
|
||||||
Wunsch.each((myWunsch) => {
|
Wunsch.each((myWunsch) => {
|
||||||
let MissionID = myWunsch.missionID;
|
let MissionID = myWunsch.missionID;
|
||||||
that.UpdatePoliceSprechwunschToDone(MissionID).then(() => {
|
self.UpdatePoliceSprechwunschToDone(MissionID).then(() => {
|
||||||
if ($("#adis-sprechwunsch-police-frame").attr("mission_id") == "empty") {
|
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("src", "https://www.leitstellenspiel.de/missions/" + MissionID);
|
||||||
$("#adis-sprechwunsch-police-frame").attr("mission_id", MissionID);
|
$("#adis-sprechwunsch-police-frame").attr("mission_id", MissionID);
|
||||||
|
|
||||||
that.PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) {
|
self.PoliceVehicleFrameWatchDog = setTimeout(async (MissionID) => {
|
||||||
that.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
|
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
|
||||||
$("#adis-sprechwunsch-police-frame").attr("src", "");
|
$("#adis-sprechwunsch-police-frame").attr("src", "");
|
||||||
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
|
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
|
||||||
});
|
});
|
||||||
@@ -17349,8 +17360,8 @@ class AutomaticDispose {
|
|||||||
|
|
||||||
// Gefängnis auswählen
|
// Gefängnis auswählen
|
||||||
Collect_Jails() {
|
Collect_Jails() {
|
||||||
let that = this;
|
let self = this;
|
||||||
that.Jails = [];
|
self.Jails = [];
|
||||||
var CountGefangene = Number(parseInt($('#h2_prisoners').text()));
|
var CountGefangene = Number(parseInt($('#h2_prisoners').text()));
|
||||||
var parentNode = $('#mission_vehicle_at_mission tr > td:nth-child(5) > a:contains("Jomaar")').parent().parent();
|
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 GefKw = parentNode.find('td:nth-child(2) > a[vehicle_type_id="52"]');
|
||||||
@@ -17358,7 +17369,7 @@ class AutomaticDispose {
|
|||||||
var GefKwGefaegnisse = $(GefKw[0]).parent().parent().next('tr');
|
var GefKwGefaegnisse = $(GefKw[0]).parent().parent().next('tr');
|
||||||
var FuStWGefaegnisse = $(FuStW[0]).parent().parent().next('tr');
|
var FuStWGefaegnisse = $(FuStW[0]).parent().parent().next('tr');
|
||||||
|
|
||||||
GefKwGefaegnisse.find("a:contains('Freie Zellen')").each(function () {
|
GefKwGefaegnisse.find("a:contains('Freie Zellen')").each(() => {
|
||||||
var JailHref = $(this).attr("href");
|
var JailHref = $(this).attr("href");
|
||||||
var JailID = JailHref.split("/").pop();
|
var JailID = JailHref.split("/").pop();
|
||||||
var JailText = $(this).text();
|
var JailText = $(this).text();
|
||||||
@@ -17366,10 +17377,10 @@ class AutomaticDispose {
|
|||||||
var JailDistance = 0;
|
var JailDistance = 0;
|
||||||
var JailTax = 0;
|
var JailTax = 0;
|
||||||
let m;
|
let m;
|
||||||
while ((m = that.JailRegEx.exec(JailText)) !== null) {
|
while ((m = self.JailRegEx.exec(JailText)) !== null) {
|
||||||
// This is necessary to avoid infinite loops with zero-width matches
|
// This is necessary to avoid infinite loops with zero-width matches
|
||||||
if (m.index === that.JailRegEx.lastIndex) {
|
if (m.index === self.JailRegEx.lastIndex) {
|
||||||
that.JailRegEx.lastIndex++;
|
self.JailRegEx.lastIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The result can be accessed through the `m`-variable.
|
// The result can be accessed through the `m`-variable.
|
||||||
@@ -17406,7 +17417,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (JailFreeBeds >= 5) {
|
if (JailFreeBeds >= 5) {
|
||||||
that.Jails.push({
|
self.Jails.push({
|
||||||
"id": JailID,
|
"id": JailID,
|
||||||
"value": JailValue + 1000,
|
"value": JailValue + 1000,
|
||||||
"text": JailText,
|
"text": JailText,
|
||||||
@@ -17414,7 +17425,7 @@ class AutomaticDispose {
|
|||||||
"href": JailHref
|
"href": JailHref
|
||||||
});
|
});
|
||||||
} else if (JailFreeBeds >= 1) {
|
} else if (JailFreeBeds >= 1) {
|
||||||
that.Jails.push({
|
self.Jails.push({
|
||||||
"id": JailID,
|
"id": JailID,
|
||||||
"value": JailValue,
|
"value": JailValue,
|
||||||
"text": JailText,
|
"text": JailText,
|
||||||
@@ -17423,7 +17434,7 @@ class AutomaticDispose {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
FuStWGefaegnisse.find("a:contains('Freie Zellen')").each(function () {
|
FuStWGefaegnisse.find("a:contains('Freie Zellen')").each(() => {
|
||||||
var JailHref = $(this).attr("href");
|
var JailHref = $(this).attr("href");
|
||||||
var JailID = JailHref.split("/").pop();
|
var JailID = JailHref.split("/").pop();
|
||||||
var JailText = $(this).text();
|
var JailText = $(this).text();
|
||||||
@@ -17431,10 +17442,10 @@ class AutomaticDispose {
|
|||||||
var JailDistance = 0;
|
var JailDistance = 0;
|
||||||
var JailTax = 0;
|
var JailTax = 0;
|
||||||
let m;
|
let m;
|
||||||
while ((m = that.JailRegEx.exec(JailText)) !== null) {
|
while ((m = self.JailRegEx.exec(JailText)) !== null) {
|
||||||
// This is necessary to avoid infinite loops with zero-width matches
|
// This is necessary to avoid infinite loops with zero-width matches
|
||||||
if (m.index === that.JailRegEx.lastIndex) {
|
if (m.index === self.JailRegEx.lastIndex) {
|
||||||
that.JailRegEx.lastIndex++;
|
self.JailRegEx.lastIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The result can be accessed through the `m`-variable.
|
// The result can be accessed through the `m`-variable.
|
||||||
@@ -17470,7 +17481,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (JailFreeBeds >= CountGefangene) {
|
if (JailFreeBeds >= CountGefangene) {
|
||||||
that.Jails.push({
|
self.Jails.push({
|
||||||
"id": JailID,
|
"id": JailID,
|
||||||
"value": JailValue + 1000,
|
"value": JailValue + 1000,
|
||||||
"text": JailText,
|
"text": JailText,
|
||||||
@@ -17478,7 +17489,7 @@ class AutomaticDispose {
|
|||||||
"href": JailHref
|
"href": JailHref
|
||||||
});
|
});
|
||||||
} else if (JailFreeBeds >= 1) {
|
} else if (JailFreeBeds >= 1) {
|
||||||
that.Jails.push({
|
self.Jails.push({
|
||||||
"id": JailID,
|
"id": JailID,
|
||||||
"value": JailValue,
|
"value": JailValue,
|
||||||
"text": JailText,
|
"text": JailText,
|
||||||
@@ -17488,15 +17499,15 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
that.Jails.sort(function (a, b) {
|
self.Jails.sort((a, b) => {
|
||||||
return a.value - b.value;
|
return a.value - b.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
that.Jails.reverse();
|
self.Jails.reverse();
|
||||||
if (that.Jails.length > 0) {
|
if (self.Jails.length > 0) {
|
||||||
this.Send_Vehicle_To_Jail()
|
this.Send_Vehicle_To_Jail()
|
||||||
} else {
|
} else {
|
||||||
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each(function () {
|
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each(() => {
|
||||||
var CalledVehicleID = parseInt($(this).find("a").first().attr("vehicle_type_id"));
|
var CalledVehicleID = parseInt($(this).find("a").first().attr("vehicle_type_id"));
|
||||||
if (CalledVehicleID == 52) {
|
if (CalledVehicleID == 52) {
|
||||||
CountGefangene -= 5;
|
CountGefangene -= 5;
|
||||||
@@ -17506,7 +17517,7 @@ class AutomaticDispose {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if ($('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').size() > 0 && CountGefangene >= 5) {
|
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 () {
|
$('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').each(() => {
|
||||||
if (CountGefangene > 0) {
|
if (CountGefangene > 0) {
|
||||||
$(this).click()
|
$(this).click()
|
||||||
CountGefangene -= 5;
|
CountGefangene -= 5;
|
||||||
@@ -17514,7 +17525,7 @@ class AutomaticDispose {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').size() > 0 && CountGefangene > 0) {
|
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 () {
|
$('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').each(() => {
|
||||||
if (CountGefangene > 0) {
|
if (CountGefangene > 0) {
|
||||||
$(this).click()
|
$(this).click()
|
||||||
CountGefangene -= 1;
|
CountGefangene -= 1;
|
||||||
@@ -17537,7 +17548,7 @@ class AutomaticDispose {
|
|||||||
// - Index Page Loader
|
// - Index Page Loader
|
||||||
// -
|
// -
|
||||||
IndexPage() {
|
IndexPage() {
|
||||||
let that = this;
|
let self = this;
|
||||||
// -
|
// -
|
||||||
// - Google Font
|
// - Google Font
|
||||||
// -
|
// -
|
||||||
@@ -17756,53 +17767,53 @@ class AutomaticDispose {
|
|||||||
// Click Events
|
// Click Events
|
||||||
//
|
//
|
||||||
|
|
||||||
$("#adis-setting-krankentransport-automatic").click(function () {
|
$("#adis-setting-krankentransport-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "Krankentransport-Automatic",
|
name: "Krankentransport-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#adis-setting-full-automatic").click(function () {
|
$("#adis-setting-full-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "MissionsOwn-Automatic",
|
name: "MissionsOwn-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#adis-setting-sprechwunsch-automatic").click(function () {
|
$("#adis-setting-sprechwunsch-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "Sprechwunsch-Automatic",
|
name: "Sprechwunsch-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#adis-setting-alliance-automatic").click(function () {
|
$("#adis-setting-alliance-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "Alliance-Automatic",
|
name: "Alliance-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#adis-setting-alliance-automatic").click(function () {
|
$("#adis-setting-alliance-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "AllianceEvent-Automatic",
|
name: "AllianceEvent-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -17810,22 +17821,22 @@ class AutomaticDispose {
|
|||||||
// Dashboard Functions
|
// Dashboard Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
$("#adis-open-button").click(function () {
|
$("#adis-open-button").click(() => {
|
||||||
$("#adis-dashboard").css("display", "flex");
|
$("#adis-dashboard").css("display", "flex");
|
||||||
$("#adis-dashboard").animate({
|
$("#adis-dashboard").animate({
|
||||||
opacity: 1
|
opacity: 1
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
$("#adis-dashboard-close-button").click(function () {
|
$("#adis-dashboard-close-button").click(() => {
|
||||||
$("#adis-dashboard").animate({
|
$("#adis-dashboard").animate({
|
||||||
opacity: 0
|
opacity: 0
|
||||||
}, 200, function () {
|
}, 200, () => {
|
||||||
$(this).css("display", "none");
|
$(this).css("display", "none");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// initial call to load the current setting state
|
// initial call to load the current setting state
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
|
|
||||||
// Create Iframes
|
// Create Iframes
|
||||||
$("body").append('<div id="adis-frame-container"></div>');
|
$("body").append('<div id="adis-frame-container"></div>');
|
||||||
@@ -17948,6 +17959,217 @@ class AutomaticDispose {
|
|||||||
console.error(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.ADisSettings, self.ADisDB.ADisAvailabelMissions], () => {
|
||||||
|
if (typeof MissionID != "undefined") {
|
||||||
|
self.AddMission(MissionID, Runner);
|
||||||
|
} else {
|
||||||
|
self.ADisSettings.runner_divs.forEach((RunnerX, index) => {
|
||||||
|
$("#" + RunnerX).find(".missionSideBarEntry").each(() => {
|
||||||
|
MissionID = $(this).attr("mission_id");
|
||||||
|
self.AddMission(MissionID, RunnerX);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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') {
|
||||||
|
return self.ADisDB.ADisMissions.where({
|
||||||
|
missionID: ID,
|
||||||
|
runner: runnerOpt
|
||||||
|
}).limit(1)
|
||||||
|
}
|
||||||
|
}).then((Missions) => {
|
||||||
|
if (Missions === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return Missions.count((count) => {
|
||||||
|
if (count > 0) {
|
||||||
|
return Missions.each(() => {
|
||||||
|
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.AddMissionToQueue({
|
||||||
|
"id": _MissionID,
|
||||||
|
"type": _MissionType,
|
||||||
|
"runner": runnerOpt,
|
||||||
|
"name": MissionName,
|
||||||
|
"street": MissionStreet,
|
||||||
|
"village": MissionVillage,
|
||||||
|
"available": (available !== undefined),
|
||||||
|
"done": false,
|
||||||
|
"last_check": Math.floor(new Date().getTime() / 1000),
|
||||||
|
"next_check": Math.floor(new Date().getTime() / 1000) + 1
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
} 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];
|
||||||
|
|
||||||
|
return self.ADisDB.ADisAvailabelMissions.get({
|
||||||
|
type: MissionType
|
||||||
|
}).then((available) => {
|
||||||
|
return self.AddMissionToQueue({
|
||||||
|
"id": MissionID,
|
||||||
|
"type": MissionType,
|
||||||
|
"runner": runnerOpt,
|
||||||
|
"name": MissionName,
|
||||||
|
"street": MissionStreet,
|
||||||
|
"village": MissionVillage,
|
||||||
|
"available": (available !== undefined),
|
||||||
|
"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({
|
||||||
|
missionID: Mission.id,
|
||||||
|
type: Mission.type,
|
||||||
|
runner: Mission.runner,
|
||||||
|
name: Mission.name,
|
||||||
|
available: Mission.available ? 'true' : 'false',
|
||||||
|
done: Mission.done ? 'true' : 'false',
|
||||||
|
street: Mission.street,
|
||||||
|
village: Mission.village,
|
||||||
|
last_check: Mission.last_check,
|
||||||
|
next_check: Mission.next_check
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateMissions(Mission) {
|
||||||
|
const self = this;
|
||||||
|
return self.ADisDB.ADisMissions.put(Mission).catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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(console.error(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenNextMission(Runner) {
|
||||||
|
const self = this;
|
||||||
|
const runnerID = self.ADisSettings.runner.indexOf(Runner)
|
||||||
|
const runnerIframeName = self.ADisSettings.runner_iframesName[runnerID];
|
||||||
|
const runnerSettings = self.ADisSettings.runner_settings[runnerID];
|
||||||
|
|
||||||
|
return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, ADisDB.ADisSettings, ADisDB.ADisAvailabelMissions], () => {
|
||||||
|
self.ADSettings().then((setting) => {
|
||||||
|
if (setting[runnerSettings] == 'true') {
|
||||||
|
return self.ADisDB.ADisMissions.where({
|
||||||
|
runner: Runner,
|
||||||
|
done: 'false'
|
||||||
|
}).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) => {
|
||||||
|
let MissionID = myWunsch.missionID;
|
||||||
|
if ($('#' + runnerIframeName).attr("mission_id") == "empty") {
|
||||||
|
$('#' + runnerIframeName).attr("src", "https://www.leitstellenspiel.de/missions/" + MissionID);
|
||||||
|
$('#' + runnerIframeName).attr("mission_id", MissionID);
|
||||||
|
self.UpdateMissionsToDone(MissionID).then(()=>{
|
||||||
|
$('#' + runnerIframeName).attr("src", '');
|
||||||
|
$('#' + runnerIframeName).attr("mission_id", 'empty');
|
||||||
|
setTimeout(self.OpenNextMission.bind(self), 5000, Runner);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return setTimeout(self.OpenNextMission.bind(self), 5000, Runner);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return setTimeout(self.OpenNextMission.bind(self), 5000, Runner);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+315
-93
@@ -8,12 +8,17 @@ class AutomaticDispose {
|
|||||||
url: "https://jf.git.rest/Jomaar/automatic-dispose/raw/branch/",
|
url: "https://jf.git.rest/Jomaar/automatic-dispose/raw/branch/",
|
||||||
branch: "master",
|
branch: "master",
|
||||||
all_missions: /***ADis_AllMissions***/ 0,
|
all_missions: /***ADis_AllMissions***/ 0,
|
||||||
name: this.name
|
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() {
|
constructor() {
|
||||||
let that = this;
|
let self = this;
|
||||||
|
|
||||||
this.ADis_MyHead = document.getElementsByTagName('head')[0];
|
this.ADis_MyHead = document.getElementsByTagName('head')[0];
|
||||||
this.ADis_MyBody = document.getElementsByTagName('body')[0];
|
this.ADis_MyBody = document.getElementsByTagName('body')[0];
|
||||||
@@ -77,47 +82,53 @@ class AutomaticDispose {
|
|||||||
* - village
|
* - village
|
||||||
* - last_check
|
* - last_check
|
||||||
* - next_check
|
* - next_check
|
||||||
|
* - runner - type (kt = krankentransport, om = own missions, os = sicherheitswache, vm = verband missions, ve = verband events)
|
||||||
*/
|
*/
|
||||||
ADisMissionsOwn: "++missionID,type,name,last_check,next_check,available,done",
|
ADisMissionsOwn: "++missionID,type,name,last_check,next_check,available,done",
|
||||||
ADisMissionsVerband: "++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",
|
ADisMissionsVerbandEvent: "++missionID,type,name,last_check,next_check,available,done",
|
||||||
|
ADisMissions: "++missionID,runner,available,done,[missionID+available+done],[runner+available+done]"
|
||||||
});
|
});
|
||||||
this.ADisDB.on("populate", function () {
|
this.ADisDB.on("populate", () => {
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "Krankentransport-Automatic",
|
name: "Krankentransport-Automatic",
|
||||||
value: 'true'
|
value: 'true'
|
||||||
});
|
});
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "Sprechwunsch-Automatic",
|
name: "Sprechwunsch-Automatic",
|
||||||
value: 'true'
|
value: 'true'
|
||||||
});
|
});
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "MissionsOwn-Automatic",
|
name: "MissionsOwn-Automatic",
|
||||||
value: 'true'
|
value: 'true'
|
||||||
});
|
});
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "Alliance-Automatic",
|
name: "Alliance-Automatic",
|
||||||
value: 'false'
|
value: 'false'
|
||||||
});
|
});
|
||||||
that.ADisDB.ADisSettings.add({
|
self.ADisDB.ADisSettings.add({
|
||||||
name: "AllianceEvent-Automatic",
|
name: "AllianceEvent-Automatic",
|
||||||
value: 'false'
|
value: 'false'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.ADisDB.open().catch(function (err) {
|
this.ADisDB.open().catch((err) => {
|
||||||
console.error(err.stack || err);
|
console.error(err.stack || err);
|
||||||
});
|
});
|
||||||
this.ADisDB.on("ready", () => {
|
this.ADisDB.on("ready", () => {
|
||||||
|
|
||||||
if (window.location.pathname === "/" || window.location.pathname === "/#") {
|
if (window.location.pathname === "/" || window.location.pathname === "/#") {
|
||||||
that.GetAvailableMissions()
|
self.GetAvailableMissions()
|
||||||
that.IndexPage()
|
self.IndexPage()
|
||||||
setInterval(that.CollectRescueSprechwuensche.bind(that), 2500);
|
setInterval(self.CollectRescueSprechwuensche.bind(self), 2500);
|
||||||
setInterval(that.OpenNextRescueSprechwunsch.bind(that), 5000);
|
setInterval(self.OpenNextRescueSprechwunsch.bind(self), 5000);
|
||||||
that.CollectRescueSprechwuensche();
|
self.CollectRescueSprechwuensche();
|
||||||
setInterval(that.CollectPoliceSprechwuensche.bind(that), 2500);
|
setInterval(self.CollectPoliceSprechwuensche.bind(self), 2500);
|
||||||
setInterval(that.OpenNextPoliceSprechwunsch.bind(that), 5000);
|
setInterval(self.OpenNextPoliceSprechwunsch.bind(self), 5000);
|
||||||
that.CollectPoliceSprechwuensche();
|
self.CollectPoliceSprechwuensche();
|
||||||
|
self.CollectMissions();
|
||||||
|
self.ADisSettings.runner.forEach((runner) => {
|
||||||
|
self.OpenNextMission(runner)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,14 +138,14 @@ class AutomaticDispose {
|
|||||||
// - Sprechwunsch Handler Rettung
|
// - Sprechwunsch Handler Rettung
|
||||||
// -
|
// -
|
||||||
if (window.location.pathname.indexOf("/vehicles/") !== -1 && window.name == 'adis-sprechwunsch-rescue') {
|
if (window.location.pathname.indexOf("/vehicles/") !== -1 && window.name == 'adis-sprechwunsch-rescue') {
|
||||||
that.Check_Call_Hospitals();
|
self.Check_Call_Hospitals();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -
|
// -
|
||||||
// - Sprechwunsch Handler Polizei/Gefangene
|
// - Sprechwunsch Handler Polizei/Gefangene
|
||||||
// -
|
// -
|
||||||
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
|
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
|
||||||
that.Check_Call_Police_Active();
|
self.Check_Call_Police_Active();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -151,10 +162,10 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ADSettings() {
|
ADSettings() {
|
||||||
let that = this;
|
let self = this;
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let res = {};
|
let res = {};
|
||||||
await that.ADisDB.ADisSettings.each((setting) => {
|
await self.ADisDB.ADisSettings.each((setting) => {
|
||||||
res[setting.name] = setting.value;
|
res[setting.name] = setting.value;
|
||||||
});
|
});
|
||||||
resolve(res);
|
resolve(res);
|
||||||
@@ -186,33 +197,33 @@ class AutomaticDispose {
|
|||||||
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||||
|
|
||||||
CollectRescueSprechwuensche() {
|
CollectRescueSprechwuensche() {
|
||||||
let that = this;
|
let self = this;
|
||||||
new Promise(async function (resolve, reject) {
|
new Promise(async (resolve, reject) => {
|
||||||
await that.ADisDB.ADisSprechwunsch.where({
|
await self.ADisDB.ADisSprechwunsch.where({
|
||||||
done: 'false'
|
done: 'false'
|
||||||
}).each((myWunsch) => {
|
}).each((myWunsch) => {
|
||||||
if ($("#vehicle_list_" + myWunsch.vehicleID).find(".building_list_fms").text() != "5") {
|
if ($("#vehicle_list_" + myWunsch.vehicleID).find(".building_list_fms").text() != "5") {
|
||||||
that.RemoveRescueSprechwunschFromQueue(myWunsch.vehicleID);
|
self.RemoveRescueSprechwunschFromQueue(myWunsch.vehicleID);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return resolve();
|
return resolve();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
$("#building_list").find(".building_list_vehicle_element").each(function () {
|
$("#building_list").find(".building_list_vehicle_element").each(() => {
|
||||||
var VehicleStatus = $(this).find(".building_list_fms").text();
|
var VehicleStatus = $(this).find(".building_list_fms").text();
|
||||||
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
||||||
var VehicleID = $(this).attr("vehicle_id");
|
var VehicleID = $(this).attr("vehicle_id");
|
||||||
if (VehicleStatus == "5" && [32, 52].indexOf(VehicleType) === -1) {
|
if (VehicleStatus == "5" && [32, 52].indexOf(VehicleType) === -1) {
|
||||||
that.AddRescueSprechwunschToQueue(VehicleID);
|
self.AddRescueSprechwunschToQueue(VehicleID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenNextRescueSprechwunsch() {
|
OpenNextRescueSprechwunsch() {
|
||||||
let that = this;
|
let self = this;
|
||||||
this.ADSettings().then((setting) => {
|
this.ADSettings().then((setting) => {
|
||||||
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
||||||
return that.ADisDB.ADisSprechwunsch.where({
|
return self.ADisDB.ADisSprechwunsch.where({
|
||||||
done: 'false'
|
done: 'false'
|
||||||
}).limit(1)
|
}).limit(1)
|
||||||
}
|
}
|
||||||
@@ -220,13 +231,13 @@ class AutomaticDispose {
|
|||||||
if (Wunsch !== undefined) {
|
if (Wunsch !== undefined) {
|
||||||
Wunsch.each((myWunsch) => {
|
Wunsch.each((myWunsch) => {
|
||||||
let VehicleID = myWunsch.vehicleID;
|
let VehicleID = myWunsch.vehicleID;
|
||||||
that.UpdateRescueSprechwunschToDone(VehicleID).then(() => {
|
self.UpdateRescueSprechwunschToDone(VehicleID).then(() => {
|
||||||
if ($("#adis-sprechwunsch-rescue-frame").attr("vehicle_id") == "empty") {
|
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("src", "https://www.leitstellenspiel.de/vehicles/" + VehicleID);
|
||||||
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", VehicleID);
|
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", VehicleID);
|
||||||
|
|
||||||
that.RescueVehicleFrameWatchDog = setTimeout(async function () {
|
self.RescueVehicleFrameWatchDog = setTimeout(async () => {
|
||||||
that.RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => {
|
self.RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => {
|
||||||
$("#adis-sprechwunsch-rescue-frame").attr("src", "");
|
$("#adis-sprechwunsch-rescue-frame").attr("src", "");
|
||||||
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty");
|
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty");
|
||||||
});
|
});
|
||||||
@@ -268,10 +279,10 @@ class AutomaticDispose {
|
|||||||
|
|
||||||
// Krankenhaus auswählen
|
// Krankenhaus auswählen
|
||||||
Collect_Hospitals() {
|
Collect_Hospitals() {
|
||||||
let that = this;
|
let self = this;
|
||||||
that.Hospitals = [];
|
self.Hospitals = [];
|
||||||
if ($("h4:contains('Eigene Krankenhäuser')").length > 0) {
|
if ($("h4:contains('Eigene Krankenhäuser')").length > 0) {
|
||||||
$("h4:contains('Eigene Krankenhäuser')").next("table").find("tbody").find("tr").each(function () {
|
$("h4:contains('Eigene Krankenhäuser')").next("table").find("tbody").find("tr").each(() => {
|
||||||
var HospitalHref = $(this).find("a:contains('Anfahren')").attr("href");
|
var HospitalHref = $(this).find("a:contains('Anfahren')").attr("href");
|
||||||
var HospitalID = Number(parseInt($(this).find("a:contains('Anfahren')").attr("id").replace("btn_approach_", "")));
|
var HospitalID = Number(parseInt($(this).find("a:contains('Anfahren')").attr("id").replace("btn_approach_", "")));
|
||||||
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
||||||
@@ -284,7 +295,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (HospitalFreeBeds > 0) {
|
if (HospitalFreeBeds > 0) {
|
||||||
that.Hospitals.push({
|
self.Hospitals.push({
|
||||||
"id": HospitalID,
|
"id": HospitalID,
|
||||||
"value": HospitalValue,
|
"value": HospitalValue,
|
||||||
"distance": HospitalDistance,
|
"distance": HospitalDistance,
|
||||||
@@ -295,7 +306,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($("h4:contains('Verbandskrankenhäuser')").length > 0) {
|
if ($("h4:contains('Verbandskrankenhäuser')").length > 0) {
|
||||||
$("h4:contains('Verbandskrankenhäuser')").next("table").find("tbody").find("tr").each(function () {
|
$("h4:contains('Verbandskrankenhäuser')").next("table").find("tbody").find("tr").each(() => {
|
||||||
var HospitalHref = $(this).find("a").attr("href")
|
var HospitalHref = $(this).find("a").attr("href")
|
||||||
var HospitalID = Number(parseInt(HospitalHref.substr(HospitalHref.lastIndexOf("/") + 1)));
|
var HospitalID = Number(parseInt(HospitalHref.substr(HospitalHref.lastIndexOf("/") + 1)));
|
||||||
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
var HospitalDistance = parseInt($(this).find("td").eq("1").text());
|
||||||
@@ -324,7 +335,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (HospitalFreeBeds > 0 && HospitalSpecialDepartment) {
|
if (HospitalFreeBeds > 0 && HospitalSpecialDepartment) {
|
||||||
that.Hospitals.push({
|
self.Hospitals.push({
|
||||||
"id": HospitalID,
|
"id": HospitalID,
|
||||||
"value": HospitalValue,
|
"value": HospitalValue,
|
||||||
"taxes": HospitalTaxes,
|
"taxes": HospitalTaxes,
|
||||||
@@ -335,11 +346,11 @@ class AutomaticDispose {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
that.Hospitals.sort(function (a, b) {
|
self.Hospitals.sort((a, b) => {
|
||||||
return a.value - b.value;
|
return a.value - b.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
that.Hospitals.reverse();
|
self.Hospitals.reverse();
|
||||||
this.Send_Vehicle_To_Hospital()
|
this.Send_Vehicle_To_Hospital()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,27 +371,27 @@ class AutomaticDispose {
|
|||||||
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||||
|
|
||||||
CollectPoliceSprechwuensche() {
|
CollectPoliceSprechwuensche() {
|
||||||
let that = this;
|
let self = this;
|
||||||
new Promise(async function (resolve, reject) {
|
new Promise(async (resolve, reject) => {
|
||||||
await that.ADisDB.ADisSprechwunschPolice.where({
|
await self.ADisDB.ADisSprechwunschPolice.where({
|
||||||
done: 'false'
|
done: 'false'
|
||||||
}).each((myWunsch) => {
|
}).each((myWunsch) => {
|
||||||
if (!$("#mission_" + myWunsch.missionID).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
if (!$("#mission_" + myWunsch.missionID).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
||||||
$("#mission_" + myWunsch.missionID).remove();
|
$("#mission_" + myWunsch.missionID).remove();
|
||||||
return that.RemovePoliceSprechwunschFromQueue(myWunsch.missionID);
|
return self.RemovePoliceSprechwunschFromQueue(myWunsch.missionID);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return resolve();
|
return resolve();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
var MOIODOS = $('div#mission_list div.missionSideBarEntry:visible');
|
var MOIODOS = $('div#mission_list div.missionSideBarEntry:visible');
|
||||||
return MOIODOS.each(function (index) {
|
return MOIODOS.each(() => {
|
||||||
if ($(this).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
if ($(this).text().match(/Gefangene sollen abtransportiert werden/g)) {
|
||||||
var MissionID = $(this).attr("mission_id");
|
var MissionID = $(this).attr("mission_id");
|
||||||
that.AddPoliceSprechwunschToQueue(MissionID);
|
self.AddPoliceSprechwunschToQueue(MissionID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
$("#building_list").find(".building_list_vehicle_element").each(function () {
|
$("#building_list").find(".building_list_vehicle_element").each(() => {
|
||||||
var VehicleStatus = $(this).find(".building_list_fms").text();
|
var VehicleStatus = $(this).find(".building_list_fms").text();
|
||||||
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id")));
|
||||||
var VehicleID = $(this).attr("vehicle_id");
|
var VehicleID = $(this).attr("vehicle_id");
|
||||||
@@ -390,7 +401,7 @@ class AutomaticDispose {
|
|||||||
var _meap = String(map2.attr('href'));
|
var _meap = String(map2.attr('href'));
|
||||||
var MissionID = _meap.substr(_meap.lastIndexOf("/") + 1);
|
var MissionID = _meap.substr(_meap.lastIndexOf("/") + 1);
|
||||||
if (MissionID) {
|
if (MissionID) {
|
||||||
that.AddPoliceSprechwunschToQueue(MissionID);
|
self.AddPoliceSprechwunschToQueue(MissionID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -399,10 +410,10 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OpenNextPoliceSprechwunsch() {
|
OpenNextPoliceSprechwunsch() {
|
||||||
let that = this;
|
let self = this;
|
||||||
this.ADSettings().then((setting) => {
|
this.ADSettings().then((setting) => {
|
||||||
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
if (setting['Sprechwunsch-Automatic'] == 'true') {
|
||||||
return that.ADisDB.ADisSprechwunschPolice.where({
|
return self.ADisDB.ADisSprechwunschPolice.where({
|
||||||
done: 'false'
|
done: 'false'
|
||||||
}).limit(1)
|
}).limit(1)
|
||||||
}
|
}
|
||||||
@@ -410,13 +421,13 @@ class AutomaticDispose {
|
|||||||
if (Wunsch !== undefined) {
|
if (Wunsch !== undefined) {
|
||||||
Wunsch.each((myWunsch) => {
|
Wunsch.each((myWunsch) => {
|
||||||
let MissionID = myWunsch.missionID;
|
let MissionID = myWunsch.missionID;
|
||||||
that.UpdatePoliceSprechwunschToDone(MissionID).then(() => {
|
self.UpdatePoliceSprechwunschToDone(MissionID).then(() => {
|
||||||
if ($("#adis-sprechwunsch-police-frame").attr("mission_id") == "empty") {
|
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("src", "https://www.leitstellenspiel.de/missions/" + MissionID);
|
||||||
$("#adis-sprechwunsch-police-frame").attr("mission_id", MissionID);
|
$("#adis-sprechwunsch-police-frame").attr("mission_id", MissionID);
|
||||||
|
|
||||||
that.PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) {
|
self.PoliceVehicleFrameWatchDog = setTimeout(async (MissionID) => {
|
||||||
that.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
|
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
|
||||||
$("#adis-sprechwunsch-police-frame").attr("src", "");
|
$("#adis-sprechwunsch-police-frame").attr("src", "");
|
||||||
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
|
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
|
||||||
});
|
});
|
||||||
@@ -456,8 +467,8 @@ class AutomaticDispose {
|
|||||||
|
|
||||||
// Gefängnis auswählen
|
// Gefängnis auswählen
|
||||||
Collect_Jails() {
|
Collect_Jails() {
|
||||||
let that = this;
|
let self = this;
|
||||||
that.Jails = [];
|
self.Jails = [];
|
||||||
var CountGefangene = Number(parseInt($('#h2_prisoners').text()));
|
var CountGefangene = Number(parseInt($('#h2_prisoners').text()));
|
||||||
var parentNode = $('#mission_vehicle_at_mission tr > td:nth-child(5) > a:contains("Jomaar")').parent().parent();
|
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 GefKw = parentNode.find('td:nth-child(2) > a[vehicle_type_id="52"]');
|
||||||
@@ -465,7 +476,7 @@ class AutomaticDispose {
|
|||||||
var GefKwGefaegnisse = $(GefKw[0]).parent().parent().next('tr');
|
var GefKwGefaegnisse = $(GefKw[0]).parent().parent().next('tr');
|
||||||
var FuStWGefaegnisse = $(FuStW[0]).parent().parent().next('tr');
|
var FuStWGefaegnisse = $(FuStW[0]).parent().parent().next('tr');
|
||||||
|
|
||||||
GefKwGefaegnisse.find("a:contains('Freie Zellen')").each(function () {
|
GefKwGefaegnisse.find("a:contains('Freie Zellen')").each(() => {
|
||||||
var JailHref = $(this).attr("href");
|
var JailHref = $(this).attr("href");
|
||||||
var JailID = JailHref.split("/").pop();
|
var JailID = JailHref.split("/").pop();
|
||||||
var JailText = $(this).text();
|
var JailText = $(this).text();
|
||||||
@@ -473,10 +484,10 @@ class AutomaticDispose {
|
|||||||
var JailDistance = 0;
|
var JailDistance = 0;
|
||||||
var JailTax = 0;
|
var JailTax = 0;
|
||||||
let m;
|
let m;
|
||||||
while ((m = that.JailRegEx.exec(JailText)) !== null) {
|
while ((m = self.JailRegEx.exec(JailText)) !== null) {
|
||||||
// This is necessary to avoid infinite loops with zero-width matches
|
// This is necessary to avoid infinite loops with zero-width matches
|
||||||
if (m.index === that.JailRegEx.lastIndex) {
|
if (m.index === self.JailRegEx.lastIndex) {
|
||||||
that.JailRegEx.lastIndex++;
|
self.JailRegEx.lastIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The result can be accessed through the `m`-variable.
|
// The result can be accessed through the `m`-variable.
|
||||||
@@ -513,7 +524,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (JailFreeBeds >= 5) {
|
if (JailFreeBeds >= 5) {
|
||||||
that.Jails.push({
|
self.Jails.push({
|
||||||
"id": JailID,
|
"id": JailID,
|
||||||
"value": JailValue + 1000,
|
"value": JailValue + 1000,
|
||||||
"text": JailText,
|
"text": JailText,
|
||||||
@@ -521,7 +532,7 @@ class AutomaticDispose {
|
|||||||
"href": JailHref
|
"href": JailHref
|
||||||
});
|
});
|
||||||
} else if (JailFreeBeds >= 1) {
|
} else if (JailFreeBeds >= 1) {
|
||||||
that.Jails.push({
|
self.Jails.push({
|
||||||
"id": JailID,
|
"id": JailID,
|
||||||
"value": JailValue,
|
"value": JailValue,
|
||||||
"text": JailText,
|
"text": JailText,
|
||||||
@@ -530,7 +541,7 @@ class AutomaticDispose {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
FuStWGefaegnisse.find("a:contains('Freie Zellen')").each(function () {
|
FuStWGefaegnisse.find("a:contains('Freie Zellen')").each(() => {
|
||||||
var JailHref = $(this).attr("href");
|
var JailHref = $(this).attr("href");
|
||||||
var JailID = JailHref.split("/").pop();
|
var JailID = JailHref.split("/").pop();
|
||||||
var JailText = $(this).text();
|
var JailText = $(this).text();
|
||||||
@@ -538,10 +549,10 @@ class AutomaticDispose {
|
|||||||
var JailDistance = 0;
|
var JailDistance = 0;
|
||||||
var JailTax = 0;
|
var JailTax = 0;
|
||||||
let m;
|
let m;
|
||||||
while ((m = that.JailRegEx.exec(JailText)) !== null) {
|
while ((m = self.JailRegEx.exec(JailText)) !== null) {
|
||||||
// This is necessary to avoid infinite loops with zero-width matches
|
// This is necessary to avoid infinite loops with zero-width matches
|
||||||
if (m.index === that.JailRegEx.lastIndex) {
|
if (m.index === self.JailRegEx.lastIndex) {
|
||||||
that.JailRegEx.lastIndex++;
|
self.JailRegEx.lastIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The result can be accessed through the `m`-variable.
|
// The result can be accessed through the `m`-variable.
|
||||||
@@ -577,7 +588,7 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (JailFreeBeds >= CountGefangene) {
|
if (JailFreeBeds >= CountGefangene) {
|
||||||
that.Jails.push({
|
self.Jails.push({
|
||||||
"id": JailID,
|
"id": JailID,
|
||||||
"value": JailValue + 1000,
|
"value": JailValue + 1000,
|
||||||
"text": JailText,
|
"text": JailText,
|
||||||
@@ -585,7 +596,7 @@ class AutomaticDispose {
|
|||||||
"href": JailHref
|
"href": JailHref
|
||||||
});
|
});
|
||||||
} else if (JailFreeBeds >= 1) {
|
} else if (JailFreeBeds >= 1) {
|
||||||
that.Jails.push({
|
self.Jails.push({
|
||||||
"id": JailID,
|
"id": JailID,
|
||||||
"value": JailValue,
|
"value": JailValue,
|
||||||
"text": JailText,
|
"text": JailText,
|
||||||
@@ -595,15 +606,15 @@ class AutomaticDispose {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
that.Jails.sort(function (a, b) {
|
self.Jails.sort((a, b) => {
|
||||||
return a.value - b.value;
|
return a.value - b.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
that.Jails.reverse();
|
self.Jails.reverse();
|
||||||
if (that.Jails.length > 0) {
|
if (self.Jails.length > 0) {
|
||||||
this.Send_Vehicle_To_Jail()
|
this.Send_Vehicle_To_Jail()
|
||||||
} else {
|
} else {
|
||||||
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each(function () {
|
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each(() => {
|
||||||
var CalledVehicleID = parseInt($(this).find("a").first().attr("vehicle_type_id"));
|
var CalledVehicleID = parseInt($(this).find("a").first().attr("vehicle_type_id"));
|
||||||
if (CalledVehicleID == 52) {
|
if (CalledVehicleID == 52) {
|
||||||
CountGefangene -= 5;
|
CountGefangene -= 5;
|
||||||
@@ -613,7 +624,7 @@ class AutomaticDispose {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if ($('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').size() > 0 && CountGefangene >= 5) {
|
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 () {
|
$('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').each(() => {
|
||||||
if (CountGefangene > 0) {
|
if (CountGefangene > 0) {
|
||||||
$(this).click()
|
$(this).click()
|
||||||
CountGefangene -= 5;
|
CountGefangene -= 5;
|
||||||
@@ -621,7 +632,7 @@ class AutomaticDispose {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').size() > 0 && CountGefangene > 0) {
|
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 () {
|
$('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').each(() => {
|
||||||
if (CountGefangene > 0) {
|
if (CountGefangene > 0) {
|
||||||
$(this).click()
|
$(this).click()
|
||||||
CountGefangene -= 1;
|
CountGefangene -= 1;
|
||||||
@@ -644,7 +655,7 @@ class AutomaticDispose {
|
|||||||
// - Index Page Loader
|
// - Index Page Loader
|
||||||
// -
|
// -
|
||||||
IndexPage() {
|
IndexPage() {
|
||||||
let that = this;
|
let self = this;
|
||||||
// -
|
// -
|
||||||
// - Google Font
|
// - Google Font
|
||||||
// -
|
// -
|
||||||
@@ -683,53 +694,53 @@ class AutomaticDispose {
|
|||||||
// Click Events
|
// Click Events
|
||||||
//
|
//
|
||||||
|
|
||||||
$("#adis-setting-krankentransport-automatic").click(function () {
|
$("#adis-setting-krankentransport-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "Krankentransport-Automatic",
|
name: "Krankentransport-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#adis-setting-full-automatic").click(function () {
|
$("#adis-setting-full-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "MissionsOwn-Automatic",
|
name: "MissionsOwn-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#adis-setting-sprechwunsch-automatic").click(function () {
|
$("#adis-setting-sprechwunsch-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "Sprechwunsch-Automatic",
|
name: "Sprechwunsch-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#adis-setting-alliance-automatic").click(function () {
|
$("#adis-setting-alliance-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "Alliance-Automatic",
|
name: "Alliance-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#adis-setting-alliance-automatic").click(function () {
|
$("#adis-setting-alliance-automatic").click(() => {
|
||||||
var tf = $(this).hasClass("active");
|
var tf = $(this).hasClass("active");
|
||||||
that.ADisDB.ADisSettings.put({
|
self.ADisDB.ADisSettings.put({
|
||||||
name: "AllianceEvent-Automatic",
|
name: "AllianceEvent-Automatic",
|
||||||
value: !tf ? 'true' : 'false'
|
value: !tf ? 'true' : 'false'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -737,22 +748,22 @@ class AutomaticDispose {
|
|||||||
// Dashboard Functions
|
// Dashboard Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
$("#adis-open-button").click(function () {
|
$("#adis-open-button").click(() => {
|
||||||
$("#adis-dashboard").css("display", "flex");
|
$("#adis-dashboard").css("display", "flex");
|
||||||
$("#adis-dashboard").animate({
|
$("#adis-dashboard").animate({
|
||||||
opacity: 1
|
opacity: 1
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
$("#adis-dashboard-close-button").click(function () {
|
$("#adis-dashboard-close-button").click(() => {
|
||||||
$("#adis-dashboard").animate({
|
$("#adis-dashboard").animate({
|
||||||
opacity: 0
|
opacity: 0
|
||||||
}, 200, function () {
|
}, 200, () => {
|
||||||
$(this).css("display", "none");
|
$(this).css("display", "none");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// initial call to load the current setting state
|
// initial call to load the current setting state
|
||||||
that.UIUpdateSettings();
|
self.UIUpdateSettings();
|
||||||
|
|
||||||
// Create Iframes
|
// Create Iframes
|
||||||
$("body").append('<div id="adis-frame-container"></div>');
|
$("body").append('<div id="adis-frame-container"></div>');
|
||||||
@@ -821,6 +832,217 @@ class AutomaticDispose {
|
|||||||
console.error(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.ADisSettings, self.ADisDB.ADisAvailabelMissions], () => {
|
||||||
|
if (typeof MissionID != "undefined") {
|
||||||
|
self.AddMission(MissionID, Runner);
|
||||||
|
} else {
|
||||||
|
self.ADisSettings.runner_divs.forEach((RunnerX, index) => {
|
||||||
|
$("#" + RunnerX).find(".missionSideBarEntry").each(() => {
|
||||||
|
MissionID = $(this).attr("mission_id");
|
||||||
|
self.AddMission(MissionID, RunnerX);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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') {
|
||||||
|
return self.ADisDB.ADisMissions.where({
|
||||||
|
missionID: ID,
|
||||||
|
runner: runnerOpt
|
||||||
|
}).limit(1)
|
||||||
|
}
|
||||||
|
}).then((Missions) => {
|
||||||
|
if (Missions === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return Missions.count((count) => {
|
||||||
|
if (count > 0) {
|
||||||
|
return Missions.each(() => {
|
||||||
|
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.AddMissionToQueue({
|
||||||
|
"id": _MissionID,
|
||||||
|
"type": _MissionType,
|
||||||
|
"runner": runnerOpt,
|
||||||
|
"name": MissionName,
|
||||||
|
"street": MissionStreet,
|
||||||
|
"village": MissionVillage,
|
||||||
|
"available": (available !== undefined),
|
||||||
|
"done": false,
|
||||||
|
"last_check": Math.floor(new Date().getTime() / 1000),
|
||||||
|
"next_check": Math.floor(new Date().getTime() / 1000) + 1
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
} 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];
|
||||||
|
|
||||||
|
return self.ADisDB.ADisAvailabelMissions.get({
|
||||||
|
type: MissionType
|
||||||
|
}).then((available) => {
|
||||||
|
return self.AddMissionToQueue({
|
||||||
|
"id": MissionID,
|
||||||
|
"type": MissionType,
|
||||||
|
"runner": runnerOpt,
|
||||||
|
"name": MissionName,
|
||||||
|
"street": MissionStreet,
|
||||||
|
"village": MissionVillage,
|
||||||
|
"available": (available !== undefined),
|
||||||
|
"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({
|
||||||
|
missionID: Mission.id,
|
||||||
|
type: Mission.type,
|
||||||
|
runner: Mission.runner,
|
||||||
|
name: Mission.name,
|
||||||
|
available: Mission.available ? 'true' : 'false',
|
||||||
|
done: Mission.done ? 'true' : 'false',
|
||||||
|
street: Mission.street,
|
||||||
|
village: Mission.village,
|
||||||
|
last_check: Mission.last_check,
|
||||||
|
next_check: Mission.next_check
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateMissions(Mission) {
|
||||||
|
const self = this;
|
||||||
|
return self.ADisDB.ADisMissions.put(Mission).catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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(console.error(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenNextMission(Runner) {
|
||||||
|
const self = this;
|
||||||
|
const runnerID = self.ADisSettings.runner.indexOf(Runner)
|
||||||
|
const runnerIframeName = self.ADisSettings.runner_iframesName[runnerID];
|
||||||
|
const runnerSettings = self.ADisSettings.runner_settings[runnerID];
|
||||||
|
|
||||||
|
return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, ADisDB.ADisSettings, ADisDB.ADisAvailabelMissions], () => {
|
||||||
|
self.ADSettings().then((setting) => {
|
||||||
|
if (setting[runnerSettings] == 'true') {
|
||||||
|
return self.ADisDB.ADisMissions.where({
|
||||||
|
runner: Runner,
|
||||||
|
done: 'false'
|
||||||
|
}).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) => {
|
||||||
|
let MissionID = myWunsch.missionID;
|
||||||
|
if ($('#' + runnerIframeName).attr("mission_id") == "empty") {
|
||||||
|
$('#' + runnerIframeName).attr("src", "https://www.leitstellenspiel.de/missions/" + MissionID);
|
||||||
|
$('#' + runnerIframeName).attr("mission_id", MissionID);
|
||||||
|
self.UpdateMissionsToDone(MissionID).then(()=>{
|
||||||
|
$('#' + runnerIframeName).attr("src", '');
|
||||||
|
$('#' + runnerIframeName).attr("mission_id", 'empty');
|
||||||
|
setTimeout(self.OpenNextMission.bind(self), 5000, Runner);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return setTimeout(self.OpenNextMission.bind(self), 5000, Runner);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return setTimeout(self.OpenNextMission.bind(self), 5000, Runner);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user