4 Commits

Author SHA1 Message Date
Jomaar 36ddb429fa adoa 2018-12-19 17:54:33 +01:00
Jomaar f95f4a6483 xxx 2018-12-18 02:47:49 +01:00
Jomaar 6bbb9cc5cb xx 2018-12-18 02:35:47 +01:00
Jomaar b6532cbf27 x 2018-12-18 02:34:19 +01:00
3 changed files with 88 additions and 94 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
/*Generated on:Tue Dec 18 2018 02:20:22 GMT+0100 (CET)*/
/*Generated on:Tue Dec 18 2018 02:47:49 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();
+34 -37
View File
@@ -1,4 +1,4 @@
/*Generated on:Tue Dec 18 2018 02:20:22 GMT+0100 (CET)*/
/*Generated on:Tue Dec 18 2018 02:47:49 GMT+0100 (CET)*/
/*
* Dexie.js - a minimalistic wrapper for IndexedDB
* ===============================================
@@ -17142,11 +17142,10 @@ class AutomaticDispose {
setInterval(self.OpenNextPoliceSprechwunsch.bind(self), 5000);
self.CollectPoliceSprechwuensche();
setTimeout(function() {
const self = this;
setTimeout(() => {
self.CollectMissions();
self.ReadAndAddMissions();
}.bind(self), 500);
}, 500);
self.ADisSettings.runner.forEach((runner) => {
self.OpenNextMission(runner)
@@ -17169,9 +17168,7 @@ class AutomaticDispose {
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
self.Check_Call_Police_Active();
} else if (window.location.pathname.indexOf("/missions/") !== -1 && window.name != 'adis-sprechwunsch-police') {
setTimeout(function(){
this.StartMission();
}.bind(self),250)
self.StartMission();
}
});
@@ -17260,13 +17257,12 @@ 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 function () {
const self = this;
self.RescueVehicleFrameWatchDog = setTimeout(async () => {
self.RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => {
$("#adis-sprechwunsch-rescue-frame").attr("src", "");
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty");
});
}.bind(self), 1500);
}, 1500);
}
});
});
@@ -17451,13 +17447,12 @@ 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 function (MissionID) {
const self = this;
self.PoliceVehicleFrameWatchDog = setTimeout(async (MissionID) => {
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
$("#adis-sprechwunsch-police-frame").attr("src", "");
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
});
}.bind(self), 1500, MissionID);
}, 1500, MissionID);
}
});
});
@@ -18224,9 +18219,9 @@ class AutomaticDispose {
var MissionName = addr[0];
var MissionStreet = addr[1];
var MissionVillage = addr[2];
console.log('update mission', _MissionID, MissionType, _MissionType)
console.log('update mission', MissionID)
return self.ADisDB.ADisAvailabelMissions.get({
type: _MissionType
type: MissionType
}).then((available) => {
return self.UpdateMissions({
"missionID": _MissionID,
@@ -18391,7 +18386,7 @@ class AutomaticDispose {
const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name);
self.MyRunner = self.ADisSettings.runner[runnerID];
self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID];
setTimeout(function () {
self.MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
var help_el = $('a#mission_help');
if (help_el.length > 0) {
@@ -18450,29 +18445,33 @@ class AutomaticDispose {
})
})
// }
}, 500);
}
MainHandler() {
const self = this;
if (self.MissionType == null || self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
tellParent(`console.log('DONE: ${self.MissionID}');`);
if (self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
console.log("DONE!");
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 if (self.includesString($('#iframe-inside-container > div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert") ) {
const m = $('#iframe-inside-container > div.alert.fade.in.alert-success').text()
tellParent(`console.log('SEND: ${self.MissionID}', '${m}');`);
} 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*/ ) {
console.log("SEND");
console.log("SEND: ", self.MissionID);
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
});
} else {
if (['adis-ownmissions', 'adis-plannedevents', 'adis-krankentransporte'].indexOf(window.name) != -1) {
console.log("WILL SEND?")
self.CheckMissionAutomatic();
} else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) {
self.WorkVerbandMission();
}
setTimeout(function () {
if (['adis-ownmissions', 'adis-plannedevents', 'adis-krankentransporte'].indexOf(window.name) != -1) {
console.log("WILL SEND?")
self.CheckMissionAutomatic();
} else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) {
self.WorkVerbandMission();
}
}, 250);
}
}
@@ -18602,8 +18601,7 @@ class AutomaticDispose {
StartAlarmProcess() {
const self = this;
const alarming = function alarming() {
const self = this;
const alarming = function alarming(self) {
Promise.resolve().then(async () => {
return await self.PrepareVehicleNeedList();
}).then(async () => {
@@ -18653,13 +18651,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("WILL KLICK SEND")
setTimeout(function () {
setTimeout(() => {
self.UpdateMissionsToDone(self.MissionID).then(() => {
tellParent(`console.log('ok:${window.name}:${self.MissionID}');`);
window.$('#mission_alarm_btn').click();
});
}.bind(self), 250);
}, 250);
})
};
@@ -18668,13 +18666,13 @@ class AutomaticDispose {
var $div = $("#mission-form > div:nth-child(7) > a");
var isShow = $div.is(':hidden');
//console.log($div, isShow);
if ($div.length && isShow) {
if ($div.length && isShow && 1 == 0) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") {
setTimeout(function () {
alarming()
}.bind(self), 500);
alarming(self)
}, 1500);
}
});
});
@@ -18685,9 +18683,8 @@ class AutomaticDispose {
$div.click();
} else {
setTimeout(function () {
const self = this;
alarming().bind(self)
}.bind(self), 250);
alarming(self)
}, 500);
}
+53 -56
View File
@@ -31,20 +31,20 @@ class AutomaticDispose {
self.Vehicles = {}
self.Patients = {}
this.ADis_MyHead = document.getElementsByTagName('head')[0];
this.ADis_MyBody = document.getElementsByTagName('body')[0];
self.ADis_MyHead = document.getElementsByTagName('head')[0];
self.ADis_MyBody = document.getElementsByTagName('body')[0];
// -
// - Sprechwunsch Variablen
// -
this.Jails = [];
this.JailRegEx = /\(Freie Zellen\:\s+(\d)\,\s+Entfernung\:\s+(\d+\,\d+)\s+km(?:\,\s+Abgabe an Besitzer\:\s+(\d+)%)?\)/g;
this.Hospitals = [];
this.RescueVehicleFrameWatchDog = null;
this.PoliceVehicleFrameWatchDog = null;
self.Jails = [];
self.JailRegEx = /\(Freie Zellen\:\s+(\d)\,\s+Entfernung\:\s+(\d+\,\d+)\s+km(?:\,\s+Abgabe an Besitzer\:\s+(\d+)%)?\)/g;
self.Hospitals = [];
self.RescueVehicleFrameWatchDog = null;
self.PoliceVehicleFrameWatchDog = null;
this.ADisDB = new Dexie('LSS_AutomaticDispo');
this.ADisDB.version(1).stores({
self.ADisDB = new Dexie('LSS_AutomaticDispo');
self.ADisDB.version(1).stores({
/**
* AvailabelMissions
* - missionID
@@ -89,7 +89,7 @@ class AutomaticDispose {
*/
ADisMissions: "++missionID,runner,available,done,[missionID+available+done],[missionID+runner],[missionID+runner+done],[runner+available+done]"
});
this.ADisDB.on("populate", () => {
self.ADisDB.on("populate", () => {
self.ADisDB.ADisSettings.add({
name: "Krankentransport-Automatic",
value: 'true'
@@ -111,10 +111,10 @@ class AutomaticDispose {
value: 'false'
});
});
this.ADisDB.open().catch((err) => {
self.ADisDB.open().catch((err) => {
console.error(err.stack || err);
});
this.ADisDB.on("ready", async () => {
self.ADisDB.on("ready", async () => {
self.adis_settings = {
'Krankentransport-Automatic': false,
'Sprechwunsch-Automatic': false,
@@ -135,11 +135,10 @@ class AutomaticDispose {
setInterval(self.OpenNextPoliceSprechwunsch.bind(self), 5000);
self.CollectPoliceSprechwuensche();
setTimeout(function() {
const self = this;
setTimeout(() => {
self.CollectMissions();
self.ReadAndAddMissions();
}.bind(self), 500);
}, 500);
self.ADisSettings.runner.forEach((runner) => {
self.OpenNextMission(runner)
@@ -162,9 +161,7 @@ class AutomaticDispose {
if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') {
self.Check_Call_Police_Active();
} else if (window.location.pathname.indexOf("/missions/") !== -1 && window.name != 'adis-sprechwunsch-police') {
setTimeout(function(){
this.StartMission();
}.bind(self),250)
self.StartMission();
}
});
@@ -238,7 +235,7 @@ class AutomaticDispose {
OpenNextRescueSprechwunsch() {
let self = this;
this.ADSettings().then((setting) => {
self.ADSettings().then((setting) => {
if (setting['Sprechwunsch-Automatic'] == 'true') {
return self.ADisDB.ADisSprechwunsch.where({
done: 'false'
@@ -253,13 +250,12 @@ 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 function () {
const self = this;
self.RescueVehicleFrameWatchDog = setTimeout(async () => {
self.RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => {
$("#adis-sprechwunsch-rescue-frame").attr("src", "");
$("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty");
});
}.bind(self), 1500);
}, 1500);
}
});
});
@@ -369,7 +365,7 @@ class AutomaticDispose {
});
self.Hospitals.reverse();
this.Send_Vehicle_To_Hospital()
self.Send_Vehicle_To_Hospital()
}
// Krankenhaus einlieferung
@@ -429,7 +425,7 @@ class AutomaticDispose {
OpenNextPoliceSprechwunsch() {
let self = this;
this.ADSettings().then((setting) => {
self.ADSettings().then((setting) => {
if (setting['Sprechwunsch-Automatic'] == 'true') {
return self.ADisDB.ADisSprechwunschPolice.where({
done: 'false'
@@ -444,13 +440,12 @@ 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 function (MissionID) {
const self = this;
self.PoliceVehicleFrameWatchDog = setTimeout(async (MissionID) => {
self.RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => {
$("#adis-sprechwunsch-police-frame").attr("src", "");
$("#adis-sprechwunsch-police-frame").attr("mission_id", "empty");
});
}.bind(self), 1500, MissionID);
}, 1500, MissionID);
}
});
});
@@ -633,7 +628,7 @@ class AutomaticDispose {
self.Jails.reverse();
if (self.Jails.length > 0) {
this.Send_Vehicle_To_Jail()
self.Send_Vehicle_To_Jail()
} else {
$("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each((_, elem) => {
var CalledVehicleID = parseInt($(elem).find("a").first().attr("vehicle_type_id"));
@@ -683,7 +678,7 @@ class AutomaticDispose {
var styleElement = document.createElement("link");
styleElement.rel = "stylesheet";
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
@@ -691,7 +686,7 @@ class AutomaticDispose {
var scriptElement = document.createElement("script");
scriptElement.type = "text/javascript";
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
@@ -700,8 +695,8 @@ class AutomaticDispose {
styleElement.rel = "stylesheet";
styleElement.type = "text/css";
styleElement.media = "screen";
styleElement.href = this.ADisSettings.url + this.ADisSettings.branch + "/style/interface.css";
this.ADis_MyHead.appendChild(styleElement);
styleElement.href = self.ADisSettings.url + self.ADisSettings.branch + "/style/interface.css";
self.ADis_MyHead.appendChild(styleElement);
// Create Dashboard
$('#news_li').before('<li id="adis-nav-item"></li>');
@@ -983,9 +978,9 @@ class AutomaticDispose {
var MissionName = addr[0];
var MissionStreet = addr[1];
var MissionVillage = addr[2];
console.log('update mission', _MissionID, MissionType, _MissionType)
console.log('update mission', MissionID)
return self.ADisDB.ADisAvailabelMissions.get({
type: _MissionType
type: MissionType
}).then((available) => {
return self.UpdateMissions({
"missionID": _MissionID,
@@ -1150,7 +1145,7 @@ class AutomaticDispose {
const runnerID = self.ADisSettings.runner_iframesName.indexOf(window.name);
self.MyRunner = self.ADisSettings.runner[runnerID];
self.MyRunnerSettings = self.ADisSettings.runner_settings[runnerID];
setTimeout(function () {
self.MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1);
var help_el = $('a#mission_help');
if (help_el.length > 0) {
@@ -1209,29 +1204,33 @@ class AutomaticDispose {
})
})
// }
}, 500);
}
MainHandler() {
const self = this;
if (self.MissionType == null || self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
tellParent(`console.log('DONE: ${self.MissionID}');`);
if (self.includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) {
console.log("DONE!");
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 if (self.includesString($('#iframe-inside-container > div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert") ) {
const m = $('#iframe-inside-container > div.alert.fade.in.alert-success').text()
tellParent(`console.log('SEND: ${self.MissionID}', '${m}');`);
} 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*/ ) {
console.log("SEND");
console.log("SEND: ", self.MissionID);
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
});
} else {
if (['adis-ownmissions', 'adis-plannedevents', 'adis-krankentransporte'].indexOf(window.name) != -1) {
console.log("WILL SEND?")
self.CheckMissionAutomatic();
} else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) {
self.WorkVerbandMission();
}
setTimeout(function () {
if (['adis-ownmissions', 'adis-plannedevents', 'adis-krankentransporte'].indexOf(window.name) != -1) {
console.log("WILL SEND?")
self.CheckMissionAutomatic();
} else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) {
self.WorkVerbandMission();
}
}, 250);
}
}
@@ -1361,8 +1360,7 @@ class AutomaticDispose {
StartAlarmProcess() {
const self = this;
const alarming = function alarming() {
const self = this;
const alarming = function alarming(self) {
Promise.resolve().then(async () => {
return await self.PrepareVehicleNeedList();
}).then(async () => {
@@ -1412,13 +1410,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("WILL KLICK SEND")
setTimeout(function () {
setTimeout(() => {
self.UpdateMissionsToDone(self.MissionID).then(() => {
tellParent(`console.log('ok:${window.name}:${self.MissionID}');`);
window.$('#mission_alarm_btn').click();
});
}.bind(self), 250);
}, 250);
})
};
@@ -1427,13 +1425,13 @@ class AutomaticDispose {
var $div = $("#mission-form > div:nth-child(7) > a");
var isShow = $div.is(':hidden');
//console.log($div, isShow);
if ($div.length && isShow) {
if ($div.length && isShow && 1 == 0) {
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "style") {
setTimeout(function () {
alarming()
}.bind(self), 500);
alarming(self)
}, 1500);
}
});
});
@@ -1444,9 +1442,8 @@ class AutomaticDispose {
$div.click();
} else {
setTimeout(function () {
const self = this;
alarming().bind(self)
}.bind(self), 250);
alarming(self)
}, 500);
}