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 94 additions and 88 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/*Generated on:Tue Dec 18 2018 02:47:49 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();
+37 -34
View File
@@ -1,4 +1,4 @@
/*Generated on:Tue Dec 18 2018 02:47:49 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
* =============================================== * ===============================================
@@ -17142,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)
@@ -17168,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)
} }
}); });
@@ -17257,12 +17260,13 @@ class AutomaticDispose {
$("#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 () => { self.RescueVehicleFrameWatchDog = setTimeout(async function () {
const self = this;
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);
} }
}); });
}); });
@@ -17447,12 +17451,13 @@ class AutomaticDispose {
$("#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 (MissionID) => { self.PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) {
const self = this;
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => { 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);
} }
}); });
}); });
@@ -18219,9 +18224,9 @@ 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) => {
return self.UpdateMissions({ return self.UpdateMissions({
"missionID": _MissionID, "missionID": _MissionID,
@@ -18386,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) {
@@ -18445,33 +18450,29 @@ class AutomaticDispose {
}) })
}) })
// } // }
}, 500);
} }
MainHandler() { MainHandler() {
const self = this; const self = this;
if (self.includesString($('#iframe-inside-container > div.missionNotFound > 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.')) {
console.log("DONE!"); tellParent(`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"); const m = $('#iframe-inside-container > div.alert.fade.in.alert-success').text()
console.log("SEND: ", self.MissionID); tellParent(`console.log('SEND: ${self.MissionID}', '${m}');`);
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?") 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) { self.WorkVerbandMission();
self.WorkVerbandMission(); }
}
}, 250);
} }
} }
@@ -18601,7 +18602,8 @@ class AutomaticDispose {
StartAlarmProcess() { StartAlarmProcess() {
const self = this; const self = this;
const alarming = function alarming(self) { 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 () => {
@@ -18651,13 +18653,13 @@ 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(() => {
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();
}); });
}, 250); }.bind(self), 250);
}) })
}; };
@@ -18666,13 +18668,13 @@ class AutomaticDispose {
var $div = $("#mission-form > div:nth-child(7) > a"); var $div = $("#mission-form > div:nth-child(7) > a");
var isShow = $div.is(':hidden'); var isShow = $div.is(':hidden');
//console.log($div, isShow); //console.log($div, isShow);
if ($div.length && isShow && 1 == 0) { if ($div.length && isShow) {
var observer = new MutationObserver(function (mutations) { var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) { mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") { if (mutation.attributeName === "style") {
setTimeout(function () { setTimeout(function () {
alarming(self) alarming()
}, 1500); }.bind(self), 500);
} }
}); });
}); });
@@ -18683,8 +18685,9 @@ class AutomaticDispose {
$div.click(); $div.click();
} else { } else {
setTimeout(function () { setTimeout(function () {
alarming(self) const self = this;
}, 500); alarming().bind(self)
}.bind(self), 250);
} }
+56 -53
View File
@@ -31,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
@@ -89,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'
@@ -111,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,
@@ -135,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)
@@ -161,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)
} }
}); });
@@ -235,7 +238,7 @@ class AutomaticDispose {
OpenNextRescueSprechwunsch() { OpenNextRescueSprechwunsch() {
let self = this; let self = this;
self.ADSettings().then((setting) => { this.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'
@@ -250,12 +253,13 @@ class AutomaticDispose {
$("#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 () => { self.RescueVehicleFrameWatchDog = setTimeout(async function () {
const self = this;
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);
} }
}); });
}); });
@@ -365,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
@@ -425,7 +429,7 @@ class AutomaticDispose {
OpenNextPoliceSprechwunsch() { OpenNextPoliceSprechwunsch() {
let self = this; let self = this;
self.ADSettings().then((setting) => { this.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'
@@ -440,12 +444,13 @@ class AutomaticDispose {
$("#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 (MissionID) => { self.PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) {
const self = this;
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => { 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);
} }
}); });
}); });
@@ -628,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"));
@@ -678,7 +683,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";
self.ADis_MyHead.appendChild(styleElement); this.ADis_MyHead.appendChild(styleElement);
// - // -
// - FontAwesome 5 // - FontAwesome 5
@@ -686,7 +691,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";
self.ADis_MyHead.appendChild(scriptElement); this.ADis_MyHead.appendChild(scriptElement);
// - // -
// - Navbar Dashboard // - Navbar Dashboard
@@ -695,8 +700,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 = self.ADisSettings.url + self.ADisSettings.branch + "/style/interface.css"; styleElement.href = this.ADisSettings.url + this.ADisSettings.branch + "/style/interface.css";
self.ADis_MyHead.appendChild(styleElement); this.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>');
@@ -978,9 +983,9 @@ 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) => {
return self.UpdateMissions({ return self.UpdateMissions({
"missionID": _MissionID, "missionID": _MissionID,
@@ -1145,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) {
@@ -1204,33 +1209,29 @@ class AutomaticDispose {
}) })
}) })
// } // }
}, 500);
} }
MainHandler() { MainHandler() {
const self = this; const self = this;
if (self.includesString($('#iframe-inside-container > div.missionNotFound > 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.')) {
console.log("DONE!"); tellParent(`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"); const m = $('#iframe-inside-container > div.alert.fade.in.alert-success').text()
console.log("SEND: ", self.MissionID); tellParent(`console.log('SEND: ${self.MissionID}', '${m}');`);
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?") 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) { self.WorkVerbandMission();
self.WorkVerbandMission(); }
}
}, 250);
} }
} }
@@ -1360,7 +1361,8 @@ class AutomaticDispose {
StartAlarmProcess() { StartAlarmProcess() {
const self = this; const self = this;
const alarming = function alarming(self) { 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 () => {
@@ -1410,13 +1412,13 @@ 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(() => {
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();
}); });
}, 250); }.bind(self), 250);
}) })
}; };
@@ -1425,13 +1427,13 @@ class AutomaticDispose {
var $div = $("#mission-form > div:nth-child(7) > a"); var $div = $("#mission-form > div:nth-child(7) > a");
var isShow = $div.is(':hidden'); var isShow = $div.is(':hidden');
//console.log($div, isShow); //console.log($div, isShow);
if ($div.length && isShow && 1 == 0) { if ($div.length && isShow) {
var observer = new MutationObserver(function (mutations) { var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) { mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") { if (mutation.attributeName === "style") {
setTimeout(function () { setTimeout(function () {
alarming(self) alarming()
}, 1500); }.bind(self), 500);
} }
}); });
}); });
@@ -1442,8 +1444,9 @@ class AutomaticDispose {
$div.click(); $div.click();
} else { } else {
setTimeout(function () { setTimeout(function () {
alarming(self) const self = this;
}, 500); alarming().bind(self)
}.bind(self), 250);
} }