V2 update no async

This commit is contained in:
2019-01-11 01:11:18 +01:00
parent 536696ddc4
commit ad4f7ba47b
4 changed files with 1200899 additions and 31 deletions

View File

@@ -114,7 +114,7 @@ class AutomaticDispose {
self.ADisDB.open().catch((err) => {
console.error(err.stack || err);
});
self.ADisDB.on("ready", async () => {
self.ADisDB.on("ready", () => {
self.adis_settings = {
'Krankentransport-Automatic': false,
'Sprechwunsch-Automatic': false,
@@ -122,8 +122,8 @@ class AutomaticDispose {
'Alliance-Automatic': false,
'AllianceEvent-Automatic': false
}
await self.genSettings()
setInterval(self.genSettings.bind(self), 1000);
self.genSettings()
if (window.location.pathname === "/" || window.location.pathname === "/#") {
self.GetAvailableMissions()
@@ -177,11 +177,12 @@ class AutomaticDispose {
self.adis_settings[setting.name] = setting.value;
});
self.UIUpdateSettings();
setTimeout(self.genSettings, 1000);
}
ADSettings() {
let self = this;
return new Promise(async (resolve, reject) => {
return new Dexie.Promise((resolve, reject) => {
return resolve(self.adis_settings);
})
}
@@ -212,15 +213,14 @@ class AutomaticDispose {
CollectRescueSprechwuensche() {
let self = this;
new Promise(async (resolve, reject) => {
await self.ADisDB.ADisSprechwunsch.where({
new Promise((resolve, reject) => {
return self.ADisDB.ADisSprechwunsch.where({
done: 'false'
}).each((myWunsch) => {
if ($("#vehicle_list_" + myWunsch.vehicleID).find(".building_list_fms").text() != "5") {
self.RemoveRescueSprechwunschFromQueue(myWunsch.vehicleID);
}
})
return resolve();
}).then(() => {
$("#building_list").find(".building_list_vehicle_element").each((_, elem) => {
var VehicleStatus = $(elem).find(".building_list_fms").text();
@@ -250,7 +250,7 @@ class AutomaticDispose {
$("#adis-sprechwunsch-rescue-frame").attr("src", "https://www.leitstellenspiel.de/vehicles/" + VehicleID);
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", VehicleID);
self.RescueVehicleFrameWatchDog = setTimeout(async () => {
self.RescueVehicleFrameWatchDog = setTimeout(() => {
self.RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => {
$("#adis-sprechwunsch-rescue-frame").attr("src", "");
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty");
@@ -386,8 +386,8 @@ class AutomaticDispose {
CollectPoliceSprechwuensche() {
let self = this;
new Promise(async (resolve, reject) => {
await self.ADisDB.ADisSprechwunschPolice.where({
new Promise((resolve, reject) => {
return self.ADisDB.ADisSprechwunschPolice.where({
done: 'false'
}).each((myWunsch) => {
if (!$("#mission_" + myWunsch.missionID).text().match(/Gefangene sollen abtransportiert werden/g)) {
@@ -395,7 +395,6 @@ class AutomaticDispose {
return self.RemovePoliceSprechwunschFromQueue(myWunsch.missionID);
}
})
return resolve();
}).then(() => {
var MOIODOS = $('div#mission_list div.missionSideBarEntry:visible');
return MOIODOS.each((_, elem) => {
@@ -440,7 +439,7 @@ class AutomaticDispose {
$("#adis-sprechwunsch-police-frame").attr("src", "https://www.leitstellenspiel.de/missions/" + MissionID);
$("#adis-sprechwunsch-police-frame").attr("mission_id", MissionID);
self.PoliceVehicleFrameWatchDog = setTimeout(async (MissionID) => {
self.PoliceVehicleFrameWatchDog = setTimeout((MissionID) => {
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
$("#adis-sprechwunsch-police-frame").attr("src", "");
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
@@ -909,10 +908,11 @@ class AutomaticDispose {
if (typeof MissionID != 'undefined') {
return self.AddMission(MissionID, Runner);
} else {
return self.ADisSettings.runner_divs.forEach(async (RunnerX, index) => {
await $("#" + RunnerX).find(".missionSideBarEntry").each(async (index, elem) => {
return self.ADisSettings.runner_divs.forEach((RunnerX, index) => {
$("#" + RunnerX).find(".missionSideBarEntry").each((index, elem) => {
MissionID = $(elem).attr("mission_id");
await self.AddMission(MissionID, RunnerX);
self.AddMission(MissionID, RunnerX);
return true;
});
})
}
@@ -1361,45 +1361,45 @@ class AutomaticDispose {
StartAlarmProcess() {
const self = this;
const alarming = function alarming(self) {
Promise.resolve().then(async () => {
return await self.PrepareVehicleNeedList();
}).then(async () => {
return await self.CollectInvolvedVehicles();
}).then(async () => {
new Dexie.Promise.resolve().then(() => {
return self.PrepareVehicleNeedList();
}).then(() => {
return self.CollectInvolvedVehicles();
}).then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return await self.CollectPatients();
return self.CollectPatients();
})
.then(async () => {
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return await self.ProcessEmergencyMedicalService()
return self.ProcessEmergencyMedicalService()
})
.then(async () => {
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return await self.ProcessFireDepartment()
return self.ProcessFireDepartment()
})
.then(async () => {
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return await self.ProcessPoliceDepartment()
return self.ProcessPoliceDepartment()
})
.then(async () => {
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return await self.ProcessTechnicalEmergencyService()
return self.ProcessTechnicalEmergencyService()
})
.then(async () => {
.then(() => {
if (self.MyRunner == 'os' && self.Vehicles.length > 0) {
return
}
return await self.ProcessWaterRescue()
return self.ProcessWaterRescue()
}).then(() => {
if (self.OweSecure && $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:checked').length == 0) {