diff --git a/src/autoloaderV2.js b/src/autoloaderV2.js index 393eabb..2d712b9 100644 --- a/src/autoloaderV2.js +++ b/src/autoloaderV2.js @@ -123,7 +123,7 @@ class AutomaticDispose { 'AllianceEvent-Automatic': false } self.genSettings() - + if (window.location.pathname === "/" || window.location.pathname === "/#") { self.GetAvailableMissions() @@ -1358,70 +1358,71 @@ class AutomaticDispose { } + StartAlarmProcessProc() { + const self = this; + new Dexie.Promise.resolve().then(() => { + return self.PrepareVehicleNeedList(); + }).then(() => { + return self.CollectInvolvedVehicles(); + }).then(() => { + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { + return + } + return self.CollectPatients(); + }) + .then(() => { + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { + return + } + return self.ProcessEmergencyMedicalService() + }) + .then(() => { + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { + return + } + return self.ProcessFireDepartment() + }) + .then(() => { + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { + return + } + return self.ProcessPoliceDepartment() + }) + .then(() => { + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { + return + } + return self.ProcessTechnicalEmergencyService() + }) + .then(() => { + if (self.MyRunner == 'os' && self.Vehicles.length > 0) { + return + } + return self.ProcessWaterRescue() + }) + .then(() => { + + if (self.OweSecure && $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:checked').length == 0) { + if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:not(:checked)').length > 0) { + $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:not(:checked)')[0].click(); + } + } + + window.console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').length, $('#vehicle_show_table_all input[type="checkbox"]:checked')); + window.console.log("WILL KLICK SEND") + setTimeout(() => { + window.console.log("WILL KLICK SEND2") + self.UpdateMissionsToDone(self.MissionID).then(() => { + tellParent(`console.log('ok:${window.name}:${self.MissionID}');`); + window.$('#mission_alarm_btn').click(); + }); + }, 250); + + }) + } + StartAlarmProcess() { const self = this; - const alarming = function alarming(self) { - new Dexie.Promise.resolve().then(() => { - return self.PrepareVehicleNeedList(); - }).then(() => { - return self.CollectInvolvedVehicles(); - }).then(() => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0) { - return - } - return self.CollectPatients(); - }) - .then(() => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0) { - return - } - return self.ProcessEmergencyMedicalService() - }) - .then(() => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0) { - return - } - return self.ProcessFireDepartment() - }) - .then(() => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0) { - return - } - return self.ProcessPoliceDepartment() - }) - .then(() => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0) { - return - } - return self.ProcessTechnicalEmergencyService() - }) - .then(() => { - if (self.MyRunner == 'os' && self.Vehicles.length > 0) { - return - } - return self.ProcessWaterRescue() - }) - .then(() => { - - if (self.OweSecure && $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:checked').length == 0) { - if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:not(:checked)').length > 0) { - $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]:not(:checked)')[0].click(); - } - } - - window.console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').length, $('#vehicle_show_table_all input[type="checkbox"]:checked')); - window.console.log("WILL KLICK SEND") - setTimeout(() => { - window.console.log("WILL KLICK SEND2") - self.UpdateMissionsToDone(self.MissionID).then(() => { - tellParent(`console.log('ok:${window.name}:${self.MissionID}');`); - window.$('#mission_alarm_btn').click(); - }); - }, 250); - - }) - }; - var $div = $("#mission-form > div:nth-child(7) > a"); var isShow = $div.is(':hidden'); @@ -1429,22 +1430,21 @@ class AutomaticDispose { if ($div.length && isShow && 1 == 0) { var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { + console.log(mutation.type, self.MissionID); + console.table(mutation, self.MissionID); if (mutation.attributeName === "style") { - setTimeout(function () { - alarming(self) - }, 1500); + self.StartAlarmProcessProc() } }); }); observer.observe($div[0], { - attributes: true + attributes: true, + characterData: true }); $div.click(); } else { - setTimeout(function () { - alarming(self) - }, 500); + self.StartAlarmProcessProc() }