From 4d4cb85484df176d535fe40bbcadce6c066a8806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Fr=C3=B6hle?= Date: Mon, 17 Dec 2018 21:20:08 +0100 Subject: [PATCH] v2 up af90u9 --- dist/autoloader.js | 2 +- dist/autoloaderV2.js | 109 ++++++++++++++++++++++++++++--------------- src/autoloaderV2.js | 107 ++++++++++++++++++++++++++++-------------- 3 files changed, 144 insertions(+), 74 deletions(-) diff --git a/dist/autoloader.js b/dist/autoloader.js index a5683ed..fd45385 100755 --- a/dist/autoloader.js +++ b/dist/autoloader.js @@ -1,4 +1,4 @@ -/*Generated on:Mon Dec 17 2018 21:14:22 GMT+0100 (CET)*/ +/*Generated on:Mon Dec 17 2018 21:20:07 GMT+0100 (CET)*/ var AutomaticDispose_Branch = "master"; var AutomaticDispose_URL = "https://jf.git.rest/Jomaar/automatic-dispose/raw/branch/"; var da_lss_adis_time = new Date().getTime(); diff --git a/dist/autoloaderV2.js b/dist/autoloaderV2.js index 5a365bb..d42a41b 100644 --- a/dist/autoloaderV2.js +++ b/dist/autoloaderV2.js @@ -1,4 +1,4 @@ -/*Generated on:Mon Dec 17 2018 21:14:22 GMT+0100 (CET)*/ +/*Generated on:Mon Dec 17 2018 21:20:07 GMT+0100 (CET)*/ /* * Dexie.js - a minimalistic wrapper for IndexedDB * =============================================== @@ -18362,40 +18362,48 @@ class AutomaticDispose { console.log("Window", window.name); console.log("self.MyRunner", self.MyRunner); console.log("self.MyRunnerSettings", self.MyRunnerSettings); - return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions], () => { - self.ADSettings().then((setting) => { - if (setting[self.MyRunnerSettings] === 'true') { - let where = { - missionID: self.MissionID, - runner: self.MyRunner, - done: 'false' - } - console.log(where); - return self.ADisDB.ADisMissions.where(where).and(function (item) { - return item.next_check <= Math.floor(new Date().getTime() / 1000) - }).limit(1) - } - }).then((Wunsch) => { - if (Wunsch !== undefined) { - return Wunsch.count(function (count) { - if (count > 0) { - return Wunsch.each((mywunsch) => { - return self.MainHandler() - }); - } else { - return self.RemoveMissionsFromQueue(self.MissionID).then(() => { - return tellParent(`console.log('wunsch:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); - }) - } - }); - } else { - return self.RemoveMissionsFromQueue(self.MissionID).then(() => { - return tellParent(`console.log('wunsch:2000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); - }) - } + if (self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) { + console.log("DONE: " + self.MissionID); + 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 }) - }) + } else { + return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions], () => { + self.ADSettings().then((setting) => { + if (setting[self.MyRunnerSettings] === 'true') { + + let where = { + missionID: self.MissionID, + runner: self.MyRunner, + done: 'false' + } + console.log(where); + return self.ADisDB.ADisMissions.where(where).and(function (item) { + return item.next_check <= Math.floor(new Date().getTime() / 1000) + }).limit(1) + } + }).then((Wunsch) => { + if (Wunsch !== undefined) { + return Wunsch.count(function (count) { + if (count > 0) { + return Wunsch.each((mywunsch) => { + return self.MainHandler() + }); + } else { + return self.RemoveMissionsFromQueue(self.MissionID).then(() => { + return tellParent(`console.log('wunsch:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); + }) + } + }); + } else { + return self.RemoveMissionsFromQueue(self.MissionID).then(() => { + return tellParent(`console.log('wunsch:2000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); + }) + } + }) + }) + } }, 1500); } @@ -18553,7 +18561,7 @@ class AutomaticDispose { StartAlarmProcess() { const self = this; - setTimeout(function () { + const alarming = function alarming(self) { Promise.resolve().then(async () => { return await self.PrepareVehicleNeedList(); }).then(async () => { @@ -18583,8 +18591,8 @@ class AutomaticDispose { } } - console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').size(), $('#vehicle_show_table_all input[type="checkbox"]:checked')); - console.log("WILL KLICK SEND") + // console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').size(), $('#vehicle_show_table_all input[type="checkbox"]:checked')); + // console.log("WILL KLICK SEND") setTimeout(() => { self.UpdateMissionsToDone(self.MissionID).then(() => { @@ -18594,7 +18602,34 @@ class AutomaticDispose { }, 250); }) - }, 500); + }; + + setTimeout(function () { + 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(self) + }, 750); + } + }); + }); + observer.observe($div[0], { + attributes: true + }); + + $div.click(); + } else { + setTimeout(function () { + alarming(self) + }, 250); + } + }, 150); + } // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/src/autoloaderV2.js b/src/autoloaderV2.js index 972ab9d..0d5c6c0 100644 --- a/src/autoloaderV2.js +++ b/src/autoloaderV2.js @@ -1121,40 +1121,48 @@ class AutomaticDispose { console.log("Window", window.name); console.log("self.MyRunner", self.MyRunner); console.log("self.MyRunnerSettings", self.MyRunnerSettings); - return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions], () => { - self.ADSettings().then((setting) => { - if (setting[self.MyRunnerSettings] === 'true') { - let where = { - missionID: self.MissionID, - runner: self.MyRunner, - done: 'false' - } - console.log(where); - return self.ADisDB.ADisMissions.where(where).and(function (item) { - return item.next_check <= Math.floor(new Date().getTime() / 1000) - }).limit(1) - } - }).then((Wunsch) => { - if (Wunsch !== undefined) { - return Wunsch.count(function (count) { - if (count > 0) { - return Wunsch.each((mywunsch) => { - return self.MainHandler() - }); - } else { - return self.RemoveMissionsFromQueue(self.MissionID).then(() => { - return tellParent(`console.log('wunsch:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); - }) - } - }); - } else { - return self.RemoveMissionsFromQueue(self.MissionID).then(() => { - return tellParent(`console.log('wunsch:2000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); - }) - } + if (self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) { + console.log("DONE: " + self.MissionID); + 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 }) - }) + } else { + return self.ADisDB.transaction('rw', [self.ADisDB.ADisMissions], () => { + self.ADSettings().then((setting) => { + if (setting[self.MyRunnerSettings] === 'true') { + + let where = { + missionID: self.MissionID, + runner: self.MyRunner, + done: 'false' + } + console.log(where); + return self.ADisDB.ADisMissions.where(where).and(function (item) { + return item.next_check <= Math.floor(new Date().getTime() / 1000) + }).limit(1) + } + }).then((Wunsch) => { + if (Wunsch !== undefined) { + return Wunsch.count(function (count) { + if (count > 0) { + return Wunsch.each((mywunsch) => { + return self.MainHandler() + }); + } else { + return self.RemoveMissionsFromQueue(self.MissionID).then(() => { + return tellParent(`console.log('wunsch:1000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); + }) + } + }); + } else { + return self.RemoveMissionsFromQueue(self.MissionID).then(() => { + return tellParent(`console.log('wunsch:2000:done:${window.name}:${self.MissionID}');window.AutomaticDisposeCall.FreeIframe('${self.MyRunner}');`); + }) + } + }) + }) + } }, 1500); } @@ -1312,7 +1320,7 @@ class AutomaticDispose { StartAlarmProcess() { const self = this; - setTimeout(function () { + const alarming = function alarming(self) { Promise.resolve().then(async () => { return await self.PrepareVehicleNeedList(); }).then(async () => { @@ -1342,8 +1350,8 @@ class AutomaticDispose { } } - console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').size(), $('#vehicle_show_table_all input[type="checkbox"]:checked')); - console.log("WILL KLICK SEND") + // console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').size(), $('#vehicle_show_table_all input[type="checkbox"]:checked')); + // console.log("WILL KLICK SEND") setTimeout(() => { self.UpdateMissionsToDone(self.MissionID).then(() => { @@ -1353,7 +1361,34 @@ class AutomaticDispose { }, 250); }) - }, 500); + }; + + setTimeout(function () { + 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(self) + }, 750); + } + }); + }); + observer.observe($div[0], { + attributes: true + }); + + $div.click(); + } else { + setTimeout(function () { + alarming(self) + }, 250); + } + }, 150); + } // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --