8 Commits

Author SHA1 Message Date
Jomaar 350eaaaccd v2 update 2018-12-18 02:20:23 +01:00
Jomaar be635ae0b8 v2 kp 2018-12-18 02:16:58 +01:00
Jomaar dbfd6625bc no logS? 2018-12-18 02:10:12 +01:00
Jomaar 83bf4de7af fix update mission Type 2018-12-18 02:08:06 +01:00
Jomaar 764ce66548 remove setTimeout 2018-12-18 02:03:10 +01:00
Jomaar 3cd86f5642 fix logginx 2018-12-18 02:02:16 +01:00
Jomaar a4b4c0ce61 v2 - all functions need bind self 2018-12-18 01:57:56 +01:00
Jomaar a1db2a34ef v2 update remove setTimeout 2018-12-18 01:51:45 +01:00
3 changed files with 828 additions and 1026 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/*Generated on:Wed Dec 19 2018 18:06:36 GMT+0100 (CET)*/ /*Generated on:Tue Dec 18 2018 02:20:22 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();
+120 -219
View File
@@ -1,4 +1,4 @@
/*Generated on:Wed Dec 19 2018 18:06:36 GMT+0100 (CET)*/ /*Generated on:Tue Dec 18 2018 02:20:22 GMT+0100 (CET)*/
/* /*
* Dexie.js - a minimalistic wrapper for IndexedDB * Dexie.js - a minimalistic wrapper for IndexedDB
* =============================================== * ===============================================
@@ -4479,7 +4479,6 @@ class AutomaticDispose {
// Variablen // Variablen
get ADisSettings() { get ADisSettings() {
let self = this
return { return {
url: "https://jf.git.rest/Jomaar/automatic-dispose/raw/branch/", url: "https://jf.git.rest/Jomaar/automatic-dispose/raw/branch/",
branch: "master", branch: "master",
@@ -17016,7 +17015,7 @@ class AutomaticDispose {
} }
} }
}`), }`),
name: self.name, name: this.name,
runner: ['kt', 'om', 'os', 'vm', 've'], runner: ['kt', 'om', 'os', 'vm', 've'],
runner_divs: ['mission_list_krankentransporte', 'mission_list', /*'mission_list_sicherheitswache',*/ 'mission_list_alliance', 'mission_list_alliance_event'], 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_settings: ['Krankentransport-Automatic', 'MissionsOwn-Automatic', /*'MissionsOwn-Automatic',*/ 'Alliance-Automatic', 'AllianceEvent-Automatic'],
@@ -17039,20 +17038,20 @@ class AutomaticDispose {
self.Vehicles = {} self.Vehicles = {}
self.Patients = {} self.Patients = {}
self.ADis_MyHead = document.getElementsByTagName('head')[0]; this.ADis_MyHead = document.getElementsByTagName('head')[0];
self.ADis_MyBody = document.getElementsByTagName('body')[0]; this.ADis_MyBody = document.getElementsByTagName('body')[0];
// - // -
// - Sprechwunsch Variablen // - Sprechwunsch Variablen
// - // -
self.Jails = []; this.Jails = [];
self.JailRegEx = /\(Freie Zellen\:\s+(\d)\,\s+Entfernung\:\s+(\d+\,\d+)\s+km(?:\,\s+Abgabe an Besitzer\:\s+(\d+)%)?\)/g; this.JailRegEx = /\(Freie Zellen\:\s+(\d)\,\s+Entfernung\:\s+(\d+\,\d+)\s+km(?:\,\s+Abgabe an Besitzer\:\s+(\d+)%)?\)/g;
self.Hospitals = []; this.Hospitals = [];
self.RescueVehicleFrameWatchDog = null; this.RescueVehicleFrameWatchDog = null;
self.PoliceVehicleFrameWatchDog = null; this.PoliceVehicleFrameWatchDog = null;
self.ADisDB = new Dexie('LSS_AutomaticDispo'); this.ADisDB = new Dexie('LSS_AutomaticDispo');
self.ADisDB.version(1).stores({ this.ADisDB.version(1).stores({
/** /**
* AvailabelMissions * AvailabelMissions
* - missionID * - missionID
@@ -17097,7 +17096,7 @@ class AutomaticDispose {
*/ */
ADisMissions: "++missionID,runner,available,done,[missionID+available+done],[missionID+runner],[missionID+runner+done],[runner+available+done]" ADisMissions: "++missionID,runner,available,done,[missionID+available+done],[missionID+runner],[missionID+runner+done],[runner+available+done]"
}); });
self.ADisDB.on("populate", () => { this.ADisDB.on("populate", () => {
self.ADisDB.ADisSettings.add({ self.ADisDB.ADisSettings.add({
name: "Krankentransport-Automatic", name: "Krankentransport-Automatic",
value: 'true' value: 'true'
@@ -17119,10 +17118,10 @@ class AutomaticDispose {
value: 'false' value: 'false'
}); });
}); });
self.ADisDB.open().catch((err) => { this.ADisDB.open().catch((err) => {
console.error(err.stack || err); console.error(err.stack || err);
}); });
self.ADisDB.on("ready", async () => { this.ADisDB.on("ready", async () => {
self.adis_settings = { self.adis_settings = {
'Krankentransport-Automatic': false, 'Krankentransport-Automatic': false,
'Sprechwunsch-Automatic': false, 'Sprechwunsch-Automatic': false,
@@ -17143,10 +17142,11 @@ class AutomaticDispose {
setInterval(self.OpenNextPoliceSprechwunsch.bind(self), 5000); setInterval(self.OpenNextPoliceSprechwunsch.bind(self), 5000);
self.CollectPoliceSprechwuensche(); self.CollectPoliceSprechwuensche();
setTimeout(() => { setTimeout(function() {
const self = this;
self.CollectMissions(); self.CollectMissions();
self.ReadAndAddMissions(); self.ReadAndAddMissions();
}, 500); }.bind(self), 500);
self.ADisSettings.runner.forEach((runner) => { self.ADisSettings.runner.forEach((runner) => {
self.OpenNextMission(runner) self.OpenNextMission(runner)
@@ -17169,7 +17169,9 @@ class AutomaticDispose {
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') { if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
self.Check_Call_Police_Active(); self.Check_Call_Police_Active();
} else if (window.location.pathname.indexOf("/missions/") !== -1 && window.name != 'adis-sprechwunsch-police') { } else if (window.location.pathname.indexOf("/missions/") !== -1 && window.name != 'adis-sprechwunsch-police') {
self.StartMission(); setTimeout(function(){
this.StartMission();
}.bind(self),250)
} }
}); });
@@ -17202,26 +17204,14 @@ class AutomaticDispose {
// - Sprechwunsch Queue // - Sprechwunsch Queue
// - // -
RemovePoliceSprechwunschFromQueue(WunschID) { RemovePoliceSprechwunschFromQueue(WunschID) {
let self = this; return this.ADisDB.ADisSprechwunschPolice.where({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => {
return await self.ADisDB.ADisSprechwunschPolice.where({
missionID: WunschID missionID: WunschID
}).delete(); }).delete();
}).catch((err) => {
console.error(err)
})
} }
RemoveRescueSprechwunschFromQueue(WunschID) { RemoveRescueSprechwunschFromQueue(WunschID) {
let self = this; return this.ADisDB.ADisSprechwunsch.where({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
return await self.ADisDB.ADisSprechwunsch.where({
vehicleID: WunschID vehicleID: WunschID
}).delete(); }).delete();
}).catch((err) => {
console.error(err)
})
} }
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -17232,7 +17222,6 @@ class AutomaticDispose {
CollectRescueSprechwuensche() { CollectRescueSprechwuensche() {
let self = this; let self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
new Promise(async (resolve, reject) => { new Promise(async (resolve, reject) => {
await self.ADisDB.ADisSprechwunsch.where({ await self.ADisDB.ADisSprechwunsch.where({
done: 'false' done: 'false'
@@ -17251,16 +17240,12 @@ class AutomaticDispose {
self.AddRescueSprechwunschToQueue(VehicleID); self.AddRescueSprechwunschToQueue(VehicleID);
} }
}); });
}) });
}).catch((err) => {
console.error(err)
})
} }
OpenNextRescueSprechwunsch() { OpenNextRescueSprechwunsch() {
let self = this; let self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => { this.ADSettings().then((setting) => {
return await self.ADSettings().then((setting) => {
if (setting['Sprechwunsch-Automatic'] == 'true') { if (setting['Sprechwunsch-Automatic'] == 'true') {
return self.ADisDB.ADisSprechwunsch.where({ return self.ADisDB.ADisSprechwunsch.where({
done: 'false' done: 'false'
@@ -17268,55 +17253,40 @@ class AutomaticDispose {
} }
}).then((Wunsch) => { }).then((Wunsch) => {
if (Wunsch !== undefined) { if (Wunsch !== undefined) {
Wunsch.each(async (myWunsch) => { Wunsch.each((myWunsch) => {
let VehicleID = myWunsch.vehicleID; let VehicleID = myWunsch.vehicleID;
await self.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);
self.RescueVehicleFrameWatchDog = setTimeout(async function () { self.RescueVehicleFrameWatchDog = setTimeout(async function () {
let self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
self.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");
}); });
});
}.bind(self), 1500); }.bind(self), 1500);
} }
}); });
}); });
} }
}) });
}).catch((err) => {
console.error(err)
})
} }
AddRescueSprechwunschToQueue(WunschID) { AddRescueSprechwunschToQueue(WunschID) {
let self = this return this.ADisDB.ADisSprechwunsch.put({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
return await self.ADisDB.ADisSprechwunsch.put({
vehicleID: WunschID, vehicleID: WunschID,
done: 'false' done: 'false'
}) }).catch((err) => {})
}).catch((err) => {
console.error(err)
})
} }
UpdateRescueSprechwunschToDone(WunschID) { UpdateRescueSprechwunschToDone(WunschID) {
let self = this return this.ADisDB.ADisSprechwunsch.put({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
return await self.ADisDB.ADisSprechwunsch.put({
vehicleID: WunschID, vehicleID: WunschID,
done: 'true' done: 'true'
}) }).catch((err) => {})
}).catch((err) => {
console.error(err)
})
} }
@@ -17406,7 +17376,7 @@ class AutomaticDispose {
}); });
self.Hospitals.reverse(); self.Hospitals.reverse();
self.Send_Vehicle_To_Hospital() this.Send_Vehicle_To_Hospital()
} }
// Krankenhaus einlieferung // Krankenhaus einlieferung
@@ -17427,8 +17397,7 @@ class AutomaticDispose {
CollectPoliceSprechwuensche() { CollectPoliceSprechwuensche() {
let self = this; let self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => { new Promise(async (resolve, reject) => {
await new Promise(async (resolve, reject) => {
await self.ADisDB.ADisSprechwunschPolice.where({ await self.ADisDB.ADisSprechwunschPolice.where({
done: 'false' done: 'false'
}).each((myWunsch) => { }).each((myWunsch) => {
@@ -17440,14 +17409,14 @@ class AutomaticDispose {
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(async (_, elem) => { return MOIODOS.each((_, elem) => {
if ($(elem).text().match(/Gefangene sollen abtransportiert werden/g)) { if ($(elem).text().match(/Gefangene sollen abtransportiert werden/g)) {
var MissionID = $(elem).attr("mission_id"); var MissionID = $(elem).attr("mission_id");
await self.AddPoliceSprechwunschToQueue(MissionID); self.AddPoliceSprechwunschToQueue(MissionID);
} }
}); });
}).then(() => { }).then(() => {
$("#building_list").find(".building_list_vehicle_element").each(async (_, elem) => { $("#building_list").find(".building_list_vehicle_element").each((_, elem) => {
var VehicleStatus = $(elem).find(".building_list_fms").text(); var VehicleStatus = $(elem).find(".building_list_fms").text();
var VehicleType = Number(parseInt($(elem).find("a").attr("vehicle_type_id"))); var VehicleType = Number(parseInt($(elem).find("a").attr("vehicle_type_id")));
var VehicleID = $(elem).attr("vehicle_id"); var VehicleID = $(elem).attr("vehicle_id");
@@ -17457,21 +17426,17 @@ 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) {
await self.AddPoliceSprechwunschToQueue(MissionID); self.AddPoliceSprechwunschToQueue(MissionID);
} }
} }
} }
}); });
}) });
}).catch((err) => {
console.error(err)
})
} }
OpenNextPoliceSprechwunsch() { OpenNextPoliceSprechwunsch() {
let self = this; let self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => { this.ADSettings().then((setting) => {
return await self.ADSettings().then((setting) => {
if (setting['Sprechwunsch-Automatic'] == 'true') { if (setting['Sprechwunsch-Automatic'] == 'true') {
return self.ADisDB.ADisSprechwunschPolice.where({ return self.ADisDB.ADisSprechwunschPolice.where({
done: 'false' done: 'false'
@@ -17479,54 +17444,39 @@ class AutomaticDispose {
} }
}).then((Wunsch) => { }).then((Wunsch) => {
if (Wunsch !== undefined) { if (Wunsch !== undefined) {
Wunsch.each(async (myWunsch) => { Wunsch.each((myWunsch) => {
let MissionID = myWunsch.missionID; let MissionID = myWunsch.missionID;
await self.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);
self.PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) { self.PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) {
let self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => { self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
await 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");
}); });
});
}.bind(self), 1500, MissionID); }.bind(self), 1500, MissionID);
} }
}); });
}); });
} }
}) });
}).catch((err) => {
console.error(err)
})
} }
AddPoliceSprechwunschToQueue(WunschID) { AddPoliceSprechwunschToQueue(WunschID) {
let self = this; return this.ADisDB.ADisSprechwunschPolice.put({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => {
return await self.ADisDB.ADisSprechwunschPolice.put({
missionID: WunschID, missionID: WunschID,
done: 'false' done: 'false'
}) }).catch((err) => {})
}).catch((err) => {
console.error(err)
})
} }
UpdatePoliceSprechwunschToDone(WunschID) { UpdatePoliceSprechwunschToDone(WunschID) {
let self = this; return this.ADisDB.ADisSprechwunschPolice.add({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => {
return await self.ADisDB.ADisSprechwunschPolice.put({
missionID: WunschID, missionID: WunschID,
done: 'true' done: 'true'
}) }).catch((err) => {})
}).catch((err) => {
console.error(err)
})
} }
@@ -17690,7 +17640,7 @@ class AutomaticDispose {
self.Jails.reverse(); self.Jails.reverse();
if (self.Jails.length > 0) { if (self.Jails.length > 0) {
self.Send_Vehicle_To_Jail() this.Send_Vehicle_To_Jail()
} else { } else {
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each((_, elem) => { $("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each((_, elem) => {
var CalledVehicleID = parseInt($(elem).find("a").first().attr("vehicle_type_id")); var CalledVehicleID = parseInt($(elem).find("a").first().attr("vehicle_type_id"));
@@ -18135,14 +18085,11 @@ class AutomaticDispose {
} }
AddAvailableMissions(Mission) { AddAvailableMissions(Mission) {
let self = this; return this.ADisDB.ADisAvailabelMissions.put({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisAvailabelMissions], async () => {
return self.ADisDB.ADisAvailabelMissions.put({
missionID: Mission.id, missionID: Mission.id,
type: Mission.type, type: Mission.type,
name: Mission.name, name: Mission.name,
jsondata: Mission jsondata: Mission
})
}).catch((err) => { }).catch((err) => {
console.error(err) console.error(err)
}) })
@@ -18184,8 +18131,9 @@ class AutomaticDispose {
ReadAndAddMissions(MissionID, Runner) { ReadAndAddMissions(MissionID, Runner) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], async () => { return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => {
return self.ADSettings().then(async () => {
self.ADSettings().then(() => {
return self.ADisDB.ADisMissions.toCollection() return self.ADisDB.ADisMissions.toCollection()
}).then((Missions) => { }).then((Missions) => {
if (typeof Missions !== "undefined") { if (typeof Missions !== "undefined") {
@@ -18196,7 +18144,7 @@ class AutomaticDispose {
if (MissionElement.length == 0 || $('#mission_panel_' + MyMission.missionID).hasClass('mission_panel_green')) { if (MissionElement.length == 0 || $('#mission_panel_' + MyMission.missionID).hasClass('mission_panel_green')) {
// remove // remove
console.log("Remove :", MyMission) console.log("Remove :", MyMission)
return self.RemoveMissionsFromQueue(MyMission.missionID) self.RemoveMissionsFromQueue(MyMission.missionID)
} }
}); });
} }
@@ -18214,10 +18162,8 @@ class AutomaticDispose {
}); });
}) })
} }
}) });
}).catch((err) => { });
console.error(err)
});;
} }
AddMission(ID, Runner) { AddMission(ID, Runner) {
@@ -18226,7 +18172,7 @@ class AutomaticDispose {
const runnerID = self.ADisSettings.runner_divs.indexOf(Runner); const runnerID = self.ADisSettings.runner_divs.indexOf(Runner);
const settingOpt = self.ADisSettings.runner_settings[runnerID]; const settingOpt = self.ADisSettings.runner_settings[runnerID];
const runnerOpt = self.ADisSettings.runner[runnerID]; const runnerOpt = self.ADisSettings.runner[runnerID];
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], async () => {
return self.ADSettings().then((setting) => { return self.ADSettings().then((setting) => {
if (setting[settingOpt] == 'true') { if (setting[settingOpt] == 'true') {
let where = { let where = {
@@ -18278,7 +18224,7 @@ class AutomaticDispose {
var MissionName = addr[0]; var MissionName = addr[0];
var MissionStreet = addr[1]; var MissionStreet = addr[1];
var MissionVillage = addr[2]; var MissionVillage = addr[2];
console.log('update mission', MissionID) console.log('update mission', _MissionID, MissionType, _MissionType)
return self.ADisDB.ADisAvailabelMissions.get({ return self.ADisDB.ADisAvailabelMissions.get({
type: _MissionType type: _MissionType
}).then((available) => { }).then((available) => {
@@ -18327,30 +18273,21 @@ class AutomaticDispose {
} }
}); });
}); });
});
} }
AddMissionsToQueue(Mission) { AddMissionsToQueue(Mission) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions], async () => {
return self.ADisDB.ADisMissions.put(Mission).catch((err) => { return self.ADisDB.ADisMissions.put(Mission).catch((err) => {
console.error(err) console.error(err)
}); });
}).catch((err) => {
console.error(err)
});
} }
UpdateMissions(Mission) { UpdateMissions(Mission) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions], async () => {
return self.ADisDB.ADisMissions.put(Mission).catch((err) => { return self.ADisDB.ADisMissions.put(Mission).catch((err) => {
console.error(err) console.error(err)
}); })
}).catch((err) => {
console.error(err)
});
} }
FreeIframe(Runner) { FreeIframe(Runner) {
@@ -18364,11 +18301,9 @@ class AutomaticDispose {
UpdateMissionsToDone(MissionID) { UpdateMissionsToDone(MissionID) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions], async () => {
return self.ADisDB.ADisMissions.update(MissionID, { return self.ADisDB.ADisMissions.update(MissionID, {
last_check: Math.floor(new Date().getTime() / 1000), last_check: Math.floor(new Date().getTime() / 1000),
next_check: Math.floor(new Date().getTime() / 1000) + 120 next_check: Math.floor(new Date().getTime() / 1000) + 120
})
}).catch((err) => { }).catch((err) => {
console.error(err) console.error(err)
}) })
@@ -18376,11 +18311,9 @@ class AutomaticDispose {
RemoveMissionsFromQueue(MissionID) { RemoveMissionsFromQueue(MissionID) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions], async () => {
return self.ADisDB.ADisMissions.where({ return self.ADisDB.ADisMissions.where({
missionID: MissionID missionID: MissionID
}).delete() }).delete().catch((err) => {
}).catch((err) => {
console.error(err) console.error(err)
}) })
} }
@@ -18400,10 +18333,10 @@ class AutomaticDispose {
// runnerIframe:runnerIframe // runnerIframe:runnerIframe
// }) // })
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], async () => { return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => {
return await self.ADSettings().then(async (setting) => { self.ADSettings().then((setting) => {
if (setting[runnerSettings] == 'true') { if (setting[runnerSettings] == 'true') {
return await self.ADisDB.ADisMissions.where({ return self.ADisDB.ADisMissions.where({
runner: Runner, runner: Runner,
available: 'true', available: 'true',
done: 'false' done: 'false'
@@ -18411,7 +18344,6 @@ class AutomaticDispose {
return item.next_check <= Math.floor(new Date().getTime() / 1000) return item.next_check <= Math.floor(new Date().getTime() / 1000)
}).limit(1) }).limit(1)
} }
})
}).then((Wunsch) => { }).then((Wunsch) => {
// console.table(Wunsch); // console.table(Wunsch);
if (Wunsch !== undefined) { if (Wunsch !== undefined) {
@@ -18436,13 +18368,12 @@ class AutomaticDispose {
} }
}); });
} else { } else {
return setTimeout(Dexie.ignoreTransaction(function () {self.OpenNextMission.bind(self, Runner)}), 1000); return setTimeout(self.OpenNextMission.bind(self), 1000, Runner);
} }
}); });
} }
return setTimeout(Dexie.ignoreTransaction(function () {self.OpenNextMission.bind(self, Runner)}), 1000); return setTimeout(self.OpenNextMission.bind(self), 1000, Runner);
}).catch((err) => { });
console.error(err)
}); });
} }
@@ -18460,7 +18391,7 @@ class AutomaticDispose {
const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name); const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name);
self.MyRunner = self.ADisSettings.runner[runnerID]; self.MyRunner = self.ADisSettings.runner[runnerID];
self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID]; self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID];
setTimeout(function () {
self.MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1); self.MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
var help_el = $('a#mission_help'); var help_el = $('a#mission_help');
if (help_el.length > 0) { if (help_el.length > 0) {
@@ -18483,8 +18414,8 @@ class AutomaticDispose {
// return tellParent(`console.log('handler:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed // return tellParent(`console.log('handler:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed
// }) // })
// } else { // } else {
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, ], async () => { return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions], () => {
return self.ADSettings().then(async (setting) => { self.ADSettings().then((setting) => {
if (setting[self.MyRunnerSettings] === 'true') { if (setting[self.MyRunnerSettings] === 'true') {
let where = { let where = {
@@ -18517,41 +18448,31 @@ class AutomaticDispose {
}) })
} }
}) })
}).catch((err) => {
console.error(err)
}) })
// } // }
}, 500);
} }
MainHandler() { MainHandler() {
const self = this; const self = this;
if (self.includesString($('div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) { if (self.MissionType == null || self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
tellParent(`console.log('DONE: ${self.MissionID}');`);
console.log("DONE!");
console.log("DONE: ", self.MissionID);
return self.RemoveMissionsFromQueue(self.MissionID).then(() => { return self.RemoveMissionsFromQueue(self.MissionID).then(() => {
return tellParent(`console.log('handler:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed return tellParent(`console.log('handler:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed
}) })
} else if (self.includesString($('#iframe-inside-container > div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert") ) {
} else if (self.includesString($('#iframe-inside-container div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert")) { const m = $('#iframe-inside-container > div.alert.fade.in.alert-success').text()
tellParent(`console.log('SEND: ${self.MissionID}', '${m}');`);
console.log("SEND");
console.log("SEND: ", self.MissionID);
return self.UpdateMissionsToDone(self.MissionID).then(() => { return self.UpdateMissionsToDone(self.MissionID).then(() => {
return tellParent(`console.log('handler:2000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full return tellParent(`console.log('handler:2000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full
}); });
} else { } else {
if (['adis-ownmissions', 'adis-plannedevents', 'adis-krankentransporte'].indexOf(window.name) != -1) { if (['adis-ownmissions', 'adis-plannedevents', 'adis-krankentransporte'].indexOf(window.name) != -1) {
console.log("WILL SEND?") console.log("WILL SEND?")
return self.CheckMissionAutomatic(); self.CheckMissionAutomatic();
} else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) { } else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) {
return self.WorkVerbandMission(); self.WorkVerbandMission();
} }
} }
} }
@@ -18563,9 +18484,6 @@ class AutomaticDispose {
WorkVerbandMission() { WorkVerbandMission() {
const self = this; const self = this;
const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name);
self.MyRunner = self.ADisSettings.runner[runnerID];
self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID];
self.ADSettings().then((setting) => { self.ADSettings().then((setting) => {
var title = document.getElementById('missionH1'); var title = document.getElementById('missionH1');
var isVerband = title.innerText.toLowerCase().includes("[verband]"); var isVerband = title.innerText.toLowerCase().includes("[verband]");
@@ -18623,14 +18541,15 @@ class AutomaticDispose {
CheckMissionAutomatic() { CheckMissionAutomatic() {
const self = this; const self = this;
var setOpt;
const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name); if (window.name == 'adis-ownmissions' || window.name == 'adis-plannedevents') {
self.MyRunner = self.ADisSettings.runner[runnerID]; setOpt = 'MissionsOwn-Automatic';
self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID]; } else if (window.name == 'adis-krankentransporte') {
if (self.MyRunnerSettings && self.MyRunner) { setOpt = 'Krankentransport-Automatic';
console.log("debug 1"); }
if (setOpt && self.MyRunner) {
self.ADSettings().then((setting) => { self.ADSettings().then((setting) => {
if (setting[self.MyRunnerSettings] === 'true') { if (setting[setOpt] == 'true') {
let where = { let where = {
missionID: self.MissionID, missionID: self.MissionID,
runner: self.MyRunner, runner: self.MyRunner,
@@ -18645,21 +18564,14 @@ class AutomaticDispose {
return coll.limit(1).toArray() return coll.limit(1).toArray()
} }
}).then((Missions) => { }).then((Missions) => {
console.log("debug 2", Missions);
if (Missions.length > 0) { if (Missions.length > 0) {
var Mission = Missions[0]; var Mission = Missions[0];
if (self.MyRunner == 'os') { if (self.MyRunner == 'os') {
self.OweSecure = true; self.OweSecure = true;
} }
self.GetMissionConfiguration(Mission.type); self.GetMissionConfiguration(Mission.type);
} else {
tellParent(`console.log('config:1000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full
} }
}).catch((err) => {
console.error(err)
}); });
} else {
tellParent(`console.log('config:2000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full
} }
} }
@@ -18667,14 +18579,10 @@ class AutomaticDispose {
GetMissionConfiguration(MissionType) { GetMissionConfiguration(MissionType) {
const self = this; const self = this;
console.log("debug 3") return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => {
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], function () {
console.log("debug 3", MissionType, MissionType.toString())
return self.ADisDB.ADisAvailabelMissions.get({ return self.ADisDB.ADisAvailabelMissions.get({
type: MissionType.toString() type: MissionType.toString()
})
}).then((availableMission) => { }).then((availableMission) => {
console.log("debug 3", availableMission)
if (availableMission != undefined && availableMission.jsondata) { if (availableMission != undefined && availableMission.jsondata) {
self.MissionConfig = availableMission.jsondata; self.MissionConfig = availableMission.jsondata;
// console.log('MissionConfig: ', MissionType.toString(), JSON.stringify(self.MissionConfig, null, 2)) // console.log('MissionConfig: ', MissionType.toString(), JSON.stringify(self.MissionConfig, null, 2))
@@ -18684,19 +18592,18 @@ class AutomaticDispose {
available: false, available: false,
next_check: CurrentTime + 60 next_check: CurrentTime + 60
}; };
self.UpdateMissionsToDone(self.MissionID); self.UpdateOwnMissionsToDone(self.MissionID, updateData);
tellParent(`console.log('config:3000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full
} }
}).catch((err) => { });
console.error(err) });
});;
} }
StartAlarmProcess() { StartAlarmProcess() {
const self = this; const self = this;
const alarming = function alarming() {
const self = this;
Promise.resolve().then(async () => { Promise.resolve().then(async () => {
return await self.PrepareVehicleNeedList(); return await self.PrepareVehicleNeedList();
}).then(async () => { }).then(async () => {
@@ -18746,25 +18653,42 @@ class AutomaticDispose {
// console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').length, $('#vehicle_show_table_all input[type="checkbox"]:checked')); // console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').length, $('#vehicle_show_table_all input[type="checkbox"]:checked'));
// console.log("WILL KLICK SEND") // console.log("WILL KLICK SEND")
setTimeout(() => { setTimeout(function () {
self.UpdateMissionsToDone(self.MissionID).then(() => { self.UpdateMissionsToDone(self.MissionID).then(() => {
if ($('#vehicle_show_table_all tr input[type="checkbox"]:checked').length > 0) {
tellParent(`console.log('ok:${window.name}:${self.MissionID}');`); tellParent(`console.log('ok:${window.name}:${self.MissionID}');`);
window.$('#mission_alarm_btn').click(); window.$('#mission_alarm_btn').click();
} else { });
tellParent(`window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); }.bind(self), 250);
})
};
var $div = $("#mission-form > div:nth-child(7) > a");
var isShow = $div.is(':hidden');
//console.log($div, isShow);
if ($div.length && isShow) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") {
setTimeout(function () {
alarming()
}.bind(self), 500);
} }
}); });
}, 250); });
observer.observe($div[0], {
}).catch((err) => { attributes: true
console.error(err) });
})
$div.click();
} else {
setTimeout(function () {
const self = this;
alarming().bind(self)
}.bind(self), 250);
}
} }
@@ -19716,28 +19640,5 @@ class AutomaticDispose {
} }
} }
$(document).ready(function () {
var $div = $("a:contains('Fahrzeuganzeige begrenzt! Fehlende Fahrzeuge laden!')");
var isShow = $div.is(':hidden');
//console.log($div, isShow);
if ($div.length && isShow && 1 == 0) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") {
setTimeout(function () {
window.AutomaticDisposeCall = new AutomaticDispose();
}, 1500);
}
});
});
observer.observe($div[0], {
attributes: true
});
$div.click();
} else {
setTimeout(function () {
window.AutomaticDisposeCall = new AutomaticDispose(); window.AutomaticDisposeCall = new AutomaticDispose();
}, 500);
}
});
+119 -218
View File
@@ -4,12 +4,11 @@ class AutomaticDispose {
// Variablen // Variablen
get ADisSettings() { get ADisSettings() {
let self = this
return { return {
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: self.name, name: this.name,
runner: ['kt', 'om', 'os', 'vm', 've'], runner: ['kt', 'om', 'os', 'vm', 've'],
runner_divs: ['mission_list_krankentransporte', 'mission_list', /*'mission_list_sicherheitswache',*/ 'mission_list_alliance', 'mission_list_alliance_event'], 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_settings: ['Krankentransport-Automatic', 'MissionsOwn-Automatic', /*'MissionsOwn-Automatic',*/ 'Alliance-Automatic', 'AllianceEvent-Automatic'],
@@ -32,20 +31,20 @@ class AutomaticDispose {
self.Vehicles = {} self.Vehicles = {}
self.Patients = {} self.Patients = {}
self.ADis_MyHead = document.getElementsByTagName('head')[0]; this.ADis_MyHead = document.getElementsByTagName('head')[0];
self.ADis_MyBody = document.getElementsByTagName('body')[0]; this.ADis_MyBody = document.getElementsByTagName('body')[0];
// - // -
// - Sprechwunsch Variablen // - Sprechwunsch Variablen
// - // -
self.Jails = []; this.Jails = [];
self.JailRegEx = /\(Freie Zellen\:\s+(\d)\,\s+Entfernung\:\s+(\d+\,\d+)\s+km(?:\,\s+Abgabe an Besitzer\:\s+(\d+)%)?\)/g; this.JailRegEx = /\(Freie Zellen\:\s+(\d)\,\s+Entfernung\:\s+(\d+\,\d+)\s+km(?:\,\s+Abgabe an Besitzer\:\s+(\d+)%)?\)/g;
self.Hospitals = []; this.Hospitals = [];
self.RescueVehicleFrameWatchDog = null; this.RescueVehicleFrameWatchDog = null;
self.PoliceVehicleFrameWatchDog = null; this.PoliceVehicleFrameWatchDog = null;
self.ADisDB = new Dexie('LSS_AutomaticDispo'); this.ADisDB = new Dexie('LSS_AutomaticDispo');
self.ADisDB.version(1).stores({ this.ADisDB.version(1).stores({
/** /**
* AvailabelMissions * AvailabelMissions
* - missionID * - missionID
@@ -90,7 +89,7 @@ class AutomaticDispose {
*/ */
ADisMissions: "++missionID,runner,available,done,[missionID+available+done],[missionID+runner],[missionID+runner+done],[runner+available+done]" ADisMissions: "++missionID,runner,available,done,[missionID+available+done],[missionID+runner],[missionID+runner+done],[runner+available+done]"
}); });
self.ADisDB.on("populate", () => { this.ADisDB.on("populate", () => {
self.ADisDB.ADisSettings.add({ self.ADisDB.ADisSettings.add({
name: "Krankentransport-Automatic", name: "Krankentransport-Automatic",
value: 'true' value: 'true'
@@ -112,10 +111,10 @@ class AutomaticDispose {
value: 'false' value: 'false'
}); });
}); });
self.ADisDB.open().catch((err) => { this.ADisDB.open().catch((err) => {
console.error(err.stack || err); console.error(err.stack || err);
}); });
self.ADisDB.on("ready", async () => { this.ADisDB.on("ready", async () => {
self.adis_settings = { self.adis_settings = {
'Krankentransport-Automatic': false, 'Krankentransport-Automatic': false,
'Sprechwunsch-Automatic': false, 'Sprechwunsch-Automatic': false,
@@ -136,10 +135,11 @@ class AutomaticDispose {
setInterval(self.OpenNextPoliceSprechwunsch.bind(self), 5000); setInterval(self.OpenNextPoliceSprechwunsch.bind(self), 5000);
self.CollectPoliceSprechwuensche(); self.CollectPoliceSprechwuensche();
setTimeout(() => { setTimeout(function() {
const self = this;
self.CollectMissions(); self.CollectMissions();
self.ReadAndAddMissions(); self.ReadAndAddMissions();
}, 500); }.bind(self), 500);
self.ADisSettings.runner.forEach((runner) => { self.ADisSettings.runner.forEach((runner) => {
self.OpenNextMission(runner) self.OpenNextMission(runner)
@@ -162,7 +162,9 @@ class AutomaticDispose {
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') { if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
self.Check_Call_Police_Active(); self.Check_Call_Police_Active();
} else if (window.location.pathname.indexOf("/missions/") !== -1 && window.name != 'adis-sprechwunsch-police') { } else if (window.location.pathname.indexOf("/missions/") !== -1 && window.name != 'adis-sprechwunsch-police') {
self.StartMission(); setTimeout(function(){
this.StartMission();
}.bind(self),250)
} }
}); });
@@ -195,26 +197,14 @@ class AutomaticDispose {
// - Sprechwunsch Queue // - Sprechwunsch Queue
// - // -
RemovePoliceSprechwunschFromQueue(WunschID) { RemovePoliceSprechwunschFromQueue(WunschID) {
let self = this; return this.ADisDB.ADisSprechwunschPolice.where({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => {
return await self.ADisDB.ADisSprechwunschPolice.where({
missionID: WunschID missionID: WunschID
}).delete(); }).delete();
}).catch((err) => {
console.error(err)
})
} }
RemoveRescueSprechwunschFromQueue(WunschID) { RemoveRescueSprechwunschFromQueue(WunschID) {
let self = this; return this.ADisDB.ADisSprechwunsch.where({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
return await self.ADisDB.ADisSprechwunsch.where({
vehicleID: WunschID vehicleID: WunschID
}).delete(); }).delete();
}).catch((err) => {
console.error(err)
})
} }
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -225,7 +215,6 @@ class AutomaticDispose {
CollectRescueSprechwuensche() { CollectRescueSprechwuensche() {
let self = this; let self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
new Promise(async (resolve, reject) => { new Promise(async (resolve, reject) => {
await self.ADisDB.ADisSprechwunsch.where({ await self.ADisDB.ADisSprechwunsch.where({
done: 'false' done: 'false'
@@ -244,16 +233,12 @@ class AutomaticDispose {
self.AddRescueSprechwunschToQueue(VehicleID); self.AddRescueSprechwunschToQueue(VehicleID);
} }
}); });
}) });
}).catch((err) => {
console.error(err)
})
} }
OpenNextRescueSprechwunsch() { OpenNextRescueSprechwunsch() {
let self = this; let self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => { this.ADSettings().then((setting) => {
return await self.ADSettings().then((setting) => {
if (setting['Sprechwunsch-Automatic'] == 'true') { if (setting['Sprechwunsch-Automatic'] == 'true') {
return self.ADisDB.ADisSprechwunsch.where({ return self.ADisDB.ADisSprechwunsch.where({
done: 'false' done: 'false'
@@ -261,55 +246,40 @@ class AutomaticDispose {
} }
}).then((Wunsch) => { }).then((Wunsch) => {
if (Wunsch !== undefined) { if (Wunsch !== undefined) {
Wunsch.each(async (myWunsch) => { Wunsch.each((myWunsch) => {
let VehicleID = myWunsch.vehicleID; let VehicleID = myWunsch.vehicleID;
await self.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);
self.RescueVehicleFrameWatchDog = setTimeout(async function () { self.RescueVehicleFrameWatchDog = setTimeout(async function () {
let self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
self.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");
}); });
});
}.bind(self), 1500); }.bind(self), 1500);
} }
}); });
}); });
} }
}) });
}).catch((err) => {
console.error(err)
})
} }
AddRescueSprechwunschToQueue(WunschID) { AddRescueSprechwunschToQueue(WunschID) {
let self = this return this.ADisDB.ADisSprechwunsch.put({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
return await self.ADisDB.ADisSprechwunsch.put({
vehicleID: WunschID, vehicleID: WunschID,
done: 'false' done: 'false'
}) }).catch((err) => {})
}).catch((err) => {
console.error(err)
})
} }
UpdateRescueSprechwunschToDone(WunschID) { UpdateRescueSprechwunschToDone(WunschID) {
let self = this return this.ADisDB.ADisSprechwunsch.put({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunsch], async () => {
return await self.ADisDB.ADisSprechwunsch.put({
vehicleID: WunschID, vehicleID: WunschID,
done: 'true' done: 'true'
}) }).catch((err) => {})
}).catch((err) => {
console.error(err)
})
} }
@@ -399,7 +369,7 @@ class AutomaticDispose {
}); });
self.Hospitals.reverse(); self.Hospitals.reverse();
self.Send_Vehicle_To_Hospital() this.Send_Vehicle_To_Hospital()
} }
// Krankenhaus einlieferung // Krankenhaus einlieferung
@@ -420,8 +390,7 @@ class AutomaticDispose {
CollectPoliceSprechwuensche() { CollectPoliceSprechwuensche() {
let self = this; let self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => { new Promise(async (resolve, reject) => {
await new Promise(async (resolve, reject) => {
await self.ADisDB.ADisSprechwunschPolice.where({ await self.ADisDB.ADisSprechwunschPolice.where({
done: 'false' done: 'false'
}).each((myWunsch) => { }).each((myWunsch) => {
@@ -433,14 +402,14 @@ class AutomaticDispose {
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(async (_, elem) => { return MOIODOS.each((_, elem) => {
if ($(elem).text().match(/Gefangene sollen abtransportiert werden/g)) { if ($(elem).text().match(/Gefangene sollen abtransportiert werden/g)) {
var MissionID = $(elem).attr("mission_id"); var MissionID = $(elem).attr("mission_id");
await self.AddPoliceSprechwunschToQueue(MissionID); self.AddPoliceSprechwunschToQueue(MissionID);
} }
}); });
}).then(() => { }).then(() => {
$("#building_list").find(".building_list_vehicle_element").each(async (_, elem) => { $("#building_list").find(".building_list_vehicle_element").each((_, elem) => {
var VehicleStatus = $(elem).find(".building_list_fms").text(); var VehicleStatus = $(elem).find(".building_list_fms").text();
var VehicleType = Number(parseInt($(elem).find("a").attr("vehicle_type_id"))); var VehicleType = Number(parseInt($(elem).find("a").attr("vehicle_type_id")));
var VehicleID = $(elem).attr("vehicle_id"); var VehicleID = $(elem).attr("vehicle_id");
@@ -450,21 +419,17 @@ 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) {
await self.AddPoliceSprechwunschToQueue(MissionID); self.AddPoliceSprechwunschToQueue(MissionID);
} }
} }
} }
}); });
}) });
}).catch((err) => {
console.error(err)
})
} }
OpenNextPoliceSprechwunsch() { OpenNextPoliceSprechwunsch() {
let self = this; let self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => { this.ADSettings().then((setting) => {
return await self.ADSettings().then((setting) => {
if (setting['Sprechwunsch-Automatic'] == 'true') { if (setting['Sprechwunsch-Automatic'] == 'true') {
return self.ADisDB.ADisSprechwunschPolice.where({ return self.ADisDB.ADisSprechwunschPolice.where({
done: 'false' done: 'false'
@@ -472,54 +437,39 @@ class AutomaticDispose {
} }
}).then((Wunsch) => { }).then((Wunsch) => {
if (Wunsch !== undefined) { if (Wunsch !== undefined) {
Wunsch.each(async (myWunsch) => { Wunsch.each((myWunsch) => {
let MissionID = myWunsch.missionID; let MissionID = myWunsch.missionID;
await self.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);
self.PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) { self.PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) {
let self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => { self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
await 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");
}); });
});
}.bind(self), 1500, MissionID); }.bind(self), 1500, MissionID);
} }
}); });
}); });
} }
}) });
}).catch((err) => {
console.error(err)
})
} }
AddPoliceSprechwunschToQueue(WunschID) { AddPoliceSprechwunschToQueue(WunschID) {
let self = this; return this.ADisDB.ADisSprechwunschPolice.put({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => {
return await self.ADisDB.ADisSprechwunschPolice.put({
missionID: WunschID, missionID: WunschID,
done: 'false' done: 'false'
}) }).catch((err) => {})
}).catch((err) => {
console.error(err)
})
} }
UpdatePoliceSprechwunschToDone(WunschID) { UpdatePoliceSprechwunschToDone(WunschID) {
let self = this; return this.ADisDB.ADisSprechwunschPolice.add({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => {
return await self.ADisDB.ADisSprechwunschPolice.put({
missionID: WunschID, missionID: WunschID,
done: 'true' done: 'true'
}) }).catch((err) => {})
}).catch((err) => {
console.error(err)
})
} }
@@ -683,7 +633,7 @@ class AutomaticDispose {
self.Jails.reverse(); self.Jails.reverse();
if (self.Jails.length > 0) { if (self.Jails.length > 0) {
self.Send_Vehicle_To_Jail() this.Send_Vehicle_To_Jail()
} else { } else {
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each((_, elem) => { $("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each((_, elem) => {
var CalledVehicleID = parseInt($(elem).find("a").first().attr("vehicle_type_id")); var CalledVehicleID = parseInt($(elem).find("a").first().attr("vehicle_type_id"));
@@ -894,14 +844,11 @@ class AutomaticDispose {
} }
AddAvailableMissions(Mission) { AddAvailableMissions(Mission) {
let self = this; return this.ADisDB.ADisAvailabelMissions.put({
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisAvailabelMissions], async () => {
return self.ADisDB.ADisAvailabelMissions.put({
missionID: Mission.id, missionID: Mission.id,
type: Mission.type, type: Mission.type,
name: Mission.name, name: Mission.name,
jsondata: Mission jsondata: Mission
})
}).catch((err) => { }).catch((err) => {
console.error(err) console.error(err)
}) })
@@ -943,8 +890,9 @@ class AutomaticDispose {
ReadAndAddMissions(MissionID, Runner) { ReadAndAddMissions(MissionID, Runner) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], async () => { return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => {
return self.ADSettings().then(async () => {
self.ADSettings().then(() => {
return self.ADisDB.ADisMissions.toCollection() return self.ADisDB.ADisMissions.toCollection()
}).then((Missions) => { }).then((Missions) => {
if (typeof Missions !== "undefined") { if (typeof Missions !== "undefined") {
@@ -955,7 +903,7 @@ class AutomaticDispose {
if (MissionElement.length == 0 || $('#mission_panel_' + MyMission.missionID).hasClass('mission_panel_green')) { if (MissionElement.length == 0 || $('#mission_panel_' + MyMission.missionID).hasClass('mission_panel_green')) {
// remove // remove
console.log("Remove :", MyMission) console.log("Remove :", MyMission)
return self.RemoveMissionsFromQueue(MyMission.missionID) self.RemoveMissionsFromQueue(MyMission.missionID)
} }
}); });
} }
@@ -973,10 +921,8 @@ class AutomaticDispose {
}); });
}) })
} }
}) });
}).catch((err) => { });
console.error(err)
});;
} }
AddMission(ID, Runner) { AddMission(ID, Runner) {
@@ -985,7 +931,7 @@ class AutomaticDispose {
const runnerID = self.ADisSettings.runner_divs.indexOf(Runner); const runnerID = self.ADisSettings.runner_divs.indexOf(Runner);
const settingOpt = self.ADisSettings.runner_settings[runnerID]; const settingOpt = self.ADisSettings.runner_settings[runnerID];
const runnerOpt = self.ADisSettings.runner[runnerID]; const runnerOpt = self.ADisSettings.runner[runnerID];
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], async () => {
return self.ADSettings().then((setting) => { return self.ADSettings().then((setting) => {
if (setting[settingOpt] == 'true') { if (setting[settingOpt] == 'true') {
let where = { let where = {
@@ -1037,7 +983,7 @@ class AutomaticDispose {
var MissionName = addr[0]; var MissionName = addr[0];
var MissionStreet = addr[1]; var MissionStreet = addr[1];
var MissionVillage = addr[2]; var MissionVillage = addr[2];
console.log('update mission', MissionID) console.log('update mission', _MissionID, MissionType, _MissionType)
return self.ADisDB.ADisAvailabelMissions.get({ return self.ADisDB.ADisAvailabelMissions.get({
type: _MissionType type: _MissionType
}).then((available) => { }).then((available) => {
@@ -1086,30 +1032,21 @@ class AutomaticDispose {
} }
}); });
}); });
});
} }
AddMissionsToQueue(Mission) { AddMissionsToQueue(Mission) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions], async () => {
return self.ADisDB.ADisMissions.put(Mission).catch((err) => { return self.ADisDB.ADisMissions.put(Mission).catch((err) => {
console.error(err) console.error(err)
}); });
}).catch((err) => {
console.error(err)
});
} }
UpdateMissions(Mission) { UpdateMissions(Mission) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions], async () => {
return self.ADisDB.ADisMissions.put(Mission).catch((err) => { return self.ADisDB.ADisMissions.put(Mission).catch((err) => {
console.error(err) console.error(err)
}); })
}).catch((err) => {
console.error(err)
});
} }
FreeIframe(Runner) { FreeIframe(Runner) {
@@ -1123,11 +1060,9 @@ class AutomaticDispose {
UpdateMissionsToDone(MissionID) { UpdateMissionsToDone(MissionID) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions], async () => {
return self.ADisDB.ADisMissions.update(MissionID, { return self.ADisDB.ADisMissions.update(MissionID, {
last_check: Math.floor(new Date().getTime() / 1000), last_check: Math.floor(new Date().getTime() / 1000),
next_check: Math.floor(new Date().getTime() / 1000) + 120 next_check: Math.floor(new Date().getTime() / 1000) + 120
})
}).catch((err) => { }).catch((err) => {
console.error(err) console.error(err)
}) })
@@ -1135,11 +1070,9 @@ class AutomaticDispose {
RemoveMissionsFromQueue(MissionID) { RemoveMissionsFromQueue(MissionID) {
const self = this; const self = this;
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions], async () => {
return self.ADisDB.ADisMissions.where({ return self.ADisDB.ADisMissions.where({
missionID: MissionID missionID: MissionID
}).delete() }).delete().catch((err) => {
}).catch((err) => {
console.error(err) console.error(err)
}) })
} }
@@ -1159,10 +1092,10 @@ class AutomaticDispose {
// runnerIframe:runnerIframe // runnerIframe:runnerIframe
// }) // })
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], async () => { return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => {
return await self.ADSettings().then(async (setting) => { self.ADSettings().then((setting) => {
if (setting[runnerSettings] == 'true') { if (setting[runnerSettings] == 'true') {
return await self.ADisDB.ADisMissions.where({ return self.ADisDB.ADisMissions.where({
runner: Runner, runner: Runner,
available: 'true', available: 'true',
done: 'false' done: 'false'
@@ -1170,7 +1103,6 @@ class AutomaticDispose {
return item.next_check <= Math.floor(new Date().getTime() / 1000) return item.next_check <= Math.floor(new Date().getTime() / 1000)
}).limit(1) }).limit(1)
} }
})
}).then((Wunsch) => { }).then((Wunsch) => {
// console.table(Wunsch); // console.table(Wunsch);
if (Wunsch !== undefined) { if (Wunsch !== undefined) {
@@ -1195,13 +1127,12 @@ class AutomaticDispose {
} }
}); });
} else { } else {
return setTimeout(Dexie.ignoreTransaction(function () {self.OpenNextMission.bind(self, Runner)}), 1000); return setTimeout(self.OpenNextMission.bind(self), 1000, Runner);
} }
}); });
} }
return setTimeout(Dexie.ignoreTransaction(function () {self.OpenNextMission.bind(self, Runner)}), 1000); return setTimeout(self.OpenNextMission.bind(self), 1000, Runner);
}).catch((err) => { });
console.error(err)
}); });
} }
@@ -1219,7 +1150,7 @@ class AutomaticDispose {
const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name); const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name);
self.MyRunner = self.ADisSettings.runner[runnerID]; self.MyRunner = self.ADisSettings.runner[runnerID];
self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID]; self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID];
setTimeout(function () {
self.MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1); self.MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
var help_el = $('a#mission_help'); var help_el = $('a#mission_help');
if (help_el.length > 0) { if (help_el.length > 0) {
@@ -1242,8 +1173,8 @@ class AutomaticDispose {
// return tellParent(`console.log('handler:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed // return tellParent(`console.log('handler:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed
// }) // })
// } else { // } else {
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, ], async () => { return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions], () => {
return self.ADSettings().then(async (setting) => { self.ADSettings().then((setting) => {
if (setting[self.MyRunnerSettings] === 'true') { if (setting[self.MyRunnerSettings] === 'true') {
let where = { let where = {
@@ -1276,41 +1207,31 @@ class AutomaticDispose {
}) })
} }
}) })
}).catch((err) => {
console.error(err)
}) })
// } // }
}, 500);
} }
MainHandler() { MainHandler() {
const self = this; const self = this;
if (self.includesString($('div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) { if (self.MissionType == null || self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
tellParent(`console.log('DONE: ${self.MissionID}');`);
console.log("DONE!");
console.log("DONE: ", self.MissionID);
return self.RemoveMissionsFromQueue(self.MissionID).then(() => { return self.RemoveMissionsFromQueue(self.MissionID).then(() => {
return tellParent(`console.log('handler:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed return tellParent(`console.log('handler:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // delete Mission here as completed
}) })
} else if (self.includesString($('#iframe-inside-container > div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert") ) {
} else if (self.includesString($('#iframe-inside-container div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert")) { const m = $('#iframe-inside-container > div.alert.fade.in.alert-success').text()
tellParent(`console.log('SEND: ${self.MissionID}', '${m}');`);
console.log("SEND");
console.log("SEND: ", self.MissionID);
return self.UpdateMissionsToDone(self.MissionID).then(() => { return self.UpdateMissionsToDone(self.MissionID).then(() => {
return tellParent(`console.log('handler:2000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full return tellParent(`console.log('handler:2000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full
}); });
} else { } else {
if (['adis-ownmissions', 'adis-plannedevents', 'adis-krankentransporte'].indexOf(window.name) != -1) { if (['adis-ownmissions', 'adis-plannedevents', 'adis-krankentransporte'].indexOf(window.name) != -1) {
console.log("WILL SEND?") console.log("WILL SEND?")
return self.CheckMissionAutomatic(); self.CheckMissionAutomatic();
} else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) { } else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) {
return self.WorkVerbandMission(); self.WorkVerbandMission();
} }
} }
} }
@@ -1322,9 +1243,6 @@ class AutomaticDispose {
WorkVerbandMission() { WorkVerbandMission() {
const self = this; const self = this;
const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name);
self.MyRunner = self.ADisSettings.runner[runnerID];
self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID];
self.ADSettings().then((setting) => { self.ADSettings().then((setting) => {
var title = document.getElementById('missionH1'); var title = document.getElementById('missionH1');
var isVerband = title.innerText.toLowerCase().includes("[verband]"); var isVerband = title.innerText.toLowerCase().includes("[verband]");
@@ -1382,14 +1300,15 @@ class AutomaticDispose {
CheckMissionAutomatic() { CheckMissionAutomatic() {
const self = this; const self = this;
var setOpt;
const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name); if (window.name == 'adis-ownmissions' || window.name == 'adis-plannedevents') {
self.MyRunner = self.ADisSettings.runner[runnerID]; setOpt = 'MissionsOwn-Automatic';
self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID]; } else if (window.name == 'adis-krankentransporte') {
if (self.MyRunnerSettings && self.MyRunner) { setOpt = 'Krankentransport-Automatic';
console.log("debug 1"); }
if (setOpt && self.MyRunner) {
self.ADSettings().then((setting) => { self.ADSettings().then((setting) => {
if (setting[self.MyRunnerSettings] === 'true') { if (setting[setOpt] == 'true') {
let where = { let where = {
missionID: self.MissionID, missionID: self.MissionID,
runner: self.MyRunner, runner: self.MyRunner,
@@ -1404,21 +1323,14 @@ class AutomaticDispose {
return coll.limit(1).toArray() return coll.limit(1).toArray()
} }
}).then((Missions) => { }).then((Missions) => {
console.log("debug 2", Missions);
if (Missions.length > 0) { if (Missions.length > 0) {
var Mission = Missions[0]; var Mission = Missions[0];
if (self.MyRunner == 'os') { if (self.MyRunner == 'os') {
self.OweSecure = true; self.OweSecure = true;
} }
self.GetMissionConfiguration(Mission.type); self.GetMissionConfiguration(Mission.type);
} else {
tellParent(`console.log('config:1000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full
} }
}).catch((err) => {
console.error(err)
}); });
} else {
tellParent(`console.log('config:2000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full
} }
} }
@@ -1426,14 +1338,10 @@ class AutomaticDispose {
GetMissionConfiguration(MissionType) { GetMissionConfiguration(MissionType) {
const self = this; const self = this;
console.log("debug 3") return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], () => {
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisMissions, self.ADisDB.ADisAvailabelMissions], function () {
console.log("debug 3", MissionType, MissionType.toString())
return self.ADisDB.ADisAvailabelMissions.get({ return self.ADisDB.ADisAvailabelMissions.get({
type: MissionType.toString() type: MissionType.toString()
})
}).then((availableMission) => { }).then((availableMission) => {
console.log("debug 3", availableMission)
if (availableMission != undefined && availableMission.jsondata) { if (availableMission != undefined && availableMission.jsondata) {
self.MissionConfig = availableMission.jsondata; self.MissionConfig = availableMission.jsondata;
// console.log('MissionConfig: ', MissionType.toString(), JSON.stringify(self.MissionConfig, null, 2)) // console.log('MissionConfig: ', MissionType.toString(), JSON.stringify(self.MissionConfig, null, 2))
@@ -1443,19 +1351,18 @@ class AutomaticDispose {
available: false, available: false,
next_check: CurrentTime + 60 next_check: CurrentTime + 60
}; };
self.UpdateMissionsToDone(self.MissionID); self.UpdateOwnMissionsToDone(self.MissionID, updateData);
tellParent(`console.log('config:3000:update:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); // update Mission here as updated or full
} }
}).catch((err) => { });
console.error(err) });
});;
} }
StartAlarmProcess() { StartAlarmProcess() {
const self = this; const self = this;
const alarming = function alarming() {
const self = this;
Promise.resolve().then(async () => { Promise.resolve().then(async () => {
return await self.PrepareVehicleNeedList(); return await self.PrepareVehicleNeedList();
}).then(async () => { }).then(async () => {
@@ -1505,25 +1412,42 @@ class AutomaticDispose {
// console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').length, $('#vehicle_show_table_all input[type="checkbox"]:checked')); // console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').length, $('#vehicle_show_table_all input[type="checkbox"]:checked'));
// console.log("WILL KLICK SEND") // console.log("WILL KLICK SEND")
setTimeout(() => { setTimeout(function () {
self.UpdateMissionsToDone(self.MissionID).then(() => { self.UpdateMissionsToDone(self.MissionID).then(() => {
if ($('#vehicle_show_table_all tr input[type="checkbox"]:checked').length > 0) {
tellParent(`console.log('ok:${window.name}:${self.MissionID}');`); tellParent(`console.log('ok:${window.name}:${self.MissionID}');`);
window.$('#mission_alarm_btn').click(); window.$('#mission_alarm_btn').click();
} else { });
tellParent(`window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); }.bind(self), 250);
})
};
var $div = $("#mission-form > div:nth-child(7) > a");
var isShow = $div.is(':hidden');
//console.log($div, isShow);
if ($div.length && isShow) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") {
setTimeout(function () {
alarming()
}.bind(self), 500);
} }
}); });
}, 250); });
observer.observe($div[0], {
}).catch((err) => { attributes: true
console.error(err) });
})
$div.click();
} else {
setTimeout(function () {
const self = this;
alarming().bind(self)
}.bind(self), 250);
}
} }
@@ -2475,28 +2399,5 @@ class AutomaticDispose {
} }
} }
$(document).ready(function () {
var $div = $("a:contains('Fahrzeuganzeige begrenzt! Fehlende Fahrzeuge laden!')");
var isShow = $div.is(':hidden');
//console.log($div, isShow);
if ($div.length && isShow && 1 == 0) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") {
setTimeout(function () {
window.AutomaticDisposeCall = new AutomaticDispose();
}, 1500);
}
});
});
observer.observe($div[0], {
attributes: true
});
$div.click();
} else {
setTimeout(function () {
window.AutomaticDisposeCall = new AutomaticDispose(); window.AutomaticDisposeCall = new AutomaticDispose();
}, 500);
}
});