1 Commits

Author SHA1 Message Date
Jomaar 36ddb429fa adoa 2018-12-19 17:54:33 +01:00
3 changed files with 802 additions and 1006 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:47:49 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();
+107 -209
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:47:49 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,
@@ -17202,26 +17201,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 +17219,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 +17237,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 +17250,39 @@ 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 () => {
let 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");
}); });
}); }, 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 +17372,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 +17393,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 +17405,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 +17422,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 +17440,38 @@ 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 (MissionID) => {
let self = this; self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => {
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");
}); });
}); }, 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 +17635,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 +18080,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 +18126,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 +18139,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 +18157,8 @@ class AutomaticDispose {
}); });
}) })
} }
}) });
}).catch((err) => { });
console.error(err)
});;
} }
AddMission(ID, Runner) { AddMission(ID, Runner) {
@@ -18226,7 +18167,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 = {
@@ -18280,7 +18221,7 @@ class AutomaticDispose {
var MissionVillage = addr[2]; var MissionVillage = addr[2];
console.log('update mission', MissionID) console.log('update mission', MissionID)
return self.ADisDB.ADisAvailabelMissions.get({ return self.ADisDB.ADisAvailabelMissions.get({
type: _MissionType type: MissionType
}).then((available) => { }).then((available) => {
return self.UpdateMissions({ return self.UpdateMissions({
"missionID": _MissionID, "missionID": _MissionID,
@@ -18327,30 +18268,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 +18296,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 +18306,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 +18328,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 +18339,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 +18363,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)
}); });
} }
@@ -18483,8 +18409,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,8 +18443,6 @@ class AutomaticDispose {
}) })
} }
}) })
}).catch((err) => {
console.error(err)
}) })
// } // }
}, 500); }, 500);
@@ -18527,31 +18451,27 @@ class AutomaticDispose {
MainHandler() { MainHandler() {
const self = this; const self = this;
if (self.includesString($('div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) { if (self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
console.log("DONE!"); console.log("DONE!");
console.log("DONE: ", self.MissionID); 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") /*|| $('#vehicle_show_table_all input[type="checkbox"]:checked').length > 0*/ ) {
} else if (self.includesString($('#iframe-inside-container div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert")) {
console.log("SEND"); console.log("SEND");
console.log("SEND: ", self.MissionID); 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 {
setTimeout(function () {
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();
} }
}, 250);
} }
} }
@@ -18563,9 +18483,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 +18540,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 +18563,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 +18578,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 +18591,17 @@ 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(self) {
Promise.resolve().then(async () => { Promise.resolve().then(async () => {
return await self.PrepareVehicleNeedList(); return await self.PrepareVehicleNeedList();
}).then(async () => { }).then(async () => {
@@ -18749,22 +18654,38 @@ class AutomaticDispose {
setTimeout(() => { setTimeout(() => {
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}');`);
}
}); });
}, 250); }, 250);
}).catch((err) => {
console.error(err)
}) })
};
var $div = $("#mission-form > div:nth-child(7) > a");
var isShow = $div.is(':hidden');
//console.log($div, isShow);
if ($div.length && isShow && 1 == 0) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") {
setTimeout(function () {
alarming(self)
}, 1500);
}
});
});
observer.observe($div[0], {
attributes: true
});
$div.click();
} else {
setTimeout(function () {
alarming(self)
}, 500);
}
} }
@@ -19716,28 +19637,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);
}
});
+96 -198
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'],
@@ -195,26 +194,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 +212,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 +230,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 () => { self.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 +243,39 @@ 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 () => {
let 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");
}); });
}); }, 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)
})
} }
@@ -420,8 +386,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 +398,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 +415,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 () => { self.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 +433,38 @@ 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 (MissionID) => {
let self = this; self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
return self.ADisDB.transaction('rw!', [self.ADisDB.ADisSprechwunschPolice], async () => {
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");
}); });
}); }, 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)
})
} }
@@ -733,7 +678,7 @@ class AutomaticDispose {
var styleElement = document.createElement("link"); var styleElement = document.createElement("link");
styleElement.rel = "stylesheet"; styleElement.rel = "stylesheet";
styleElement.href = "https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700"; styleElement.href = "https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700";
this.ADis_MyHead.appendChild(styleElement); self.ADis_MyHead.appendChild(styleElement);
// - // -
// - FontAwesome 5 // - FontAwesome 5
@@ -741,7 +686,7 @@ class AutomaticDispose {
var scriptElement = document.createElement("script"); var scriptElement = document.createElement("script");
scriptElement.type = "text/javascript"; scriptElement.type = "text/javascript";
scriptElement.src = "https://use.fontawesome.com/releases/v5.5.0/js/all.js"; scriptElement.src = "https://use.fontawesome.com/releases/v5.5.0/js/all.js";
this.ADis_MyHead.appendChild(scriptElement); self.ADis_MyHead.appendChild(scriptElement);
// - // -
// - Navbar Dashboard // - Navbar Dashboard
@@ -750,8 +695,8 @@ class AutomaticDispose {
styleElement.rel = "stylesheet"; styleElement.rel = "stylesheet";
styleElement.type = "text/css"; styleElement.type = "text/css";
styleElement.media = "screen"; styleElement.media = "screen";
styleElement.href = this.ADisSettings.url + this.ADisSettings.branch + "/style/interface.css"; styleElement.href = self.ADisSettings.url + self.ADisSettings.branch + "/style/interface.css";
this.ADis_MyHead.appendChild(styleElement); self.ADis_MyHead.appendChild(styleElement);
// Create Dashboard // Create Dashboard
$('#news_li').before('<li id="adis-nav-item"></li>'); $('#news_li').before('<li id="adis-nav-item"></li>');
@@ -894,14 +839,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 +885,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 +898,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 +916,8 @@ class AutomaticDispose {
}); });
}) })
} }
}) });
}).catch((err) => { });
console.error(err)
});;
} }
AddMission(ID, Runner) { AddMission(ID, Runner) {
@@ -985,7 +926,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 = {
@@ -1039,7 +980,7 @@ class AutomaticDispose {
var MissionVillage = addr[2]; var MissionVillage = addr[2];
console.log('update mission', MissionID) console.log('update mission', MissionID)
return self.ADisDB.ADisAvailabelMissions.get({ return self.ADisDB.ADisAvailabelMissions.get({
type: _MissionType type: MissionType
}).then((available) => { }).then((available) => {
return self.UpdateMissions({ return self.UpdateMissions({
"missionID": _MissionID, "missionID": _MissionID,
@@ -1086,30 +1027,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 +1055,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 +1065,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 +1087,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 +1098,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 +1122,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)
}); });
} }
@@ -1242,8 +1168,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,8 +1202,6 @@ class AutomaticDispose {
}) })
} }
}) })
}).catch((err) => {
console.error(err)
}) })
// } // }
}, 500); }, 500);
@@ -1286,31 +1210,27 @@ class AutomaticDispose {
MainHandler() { MainHandler() {
const self = this; const self = this;
if (self.includesString($('div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) { if (self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
console.log("DONE!"); console.log("DONE!");
console.log("DONE: ", self.MissionID); 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") /*|| $('#vehicle_show_table_all input[type="checkbox"]:checked').length > 0*/ ) {
} else if (self.includesString($('#iframe-inside-container div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert")) {
console.log("SEND"); console.log("SEND");
console.log("SEND: ", self.MissionID); 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 {
setTimeout(function () {
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();
} }
}, 250);
} }
} }
@@ -1322,9 +1242,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 +1299,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 +1322,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 +1337,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 +1350,17 @@ 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(self) {
Promise.resolve().then(async () => { Promise.resolve().then(async () => {
return await self.PrepareVehicleNeedList(); return await self.PrepareVehicleNeedList();
}).then(async () => { }).then(async () => {
@@ -1508,22 +1413,38 @@ class AutomaticDispose {
setTimeout(() => { setTimeout(() => {
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}');`);
}
}); });
}, 250); }, 250);
}).catch((err) => {
console.error(err)
}) })
};
var $div = $("#mission-form > div:nth-child(7) > a");
var isShow = $div.is(':hidden');
//console.log($div, isShow);
if ($div.length && isShow && 1 == 0) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") {
setTimeout(function () {
alarming(self)
}, 1500);
}
});
});
observer.observe($div[0], {
attributes: true
});
$div.click();
} else {
setTimeout(function () {
alarming(self)
}, 500);
}
} }
@@ -2475,28 +2396,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);
}
});