This commit is contained in:
2018-12-17 00:23:53 +01:00
parent 66d44850cf
commit 00efc5ff9c
3 changed files with 154 additions and 114 deletions

View File

@@ -1310,66 +1310,86 @@ class AutomaticDispose {
StartAlarmProcess() {
const self = this;
setTimeout(function () {
Promise.resolve().then(async () => {
return await self.PrepareVehicleNeedList();
}).then(async () => {
return await self.CollectInvolvedVehicles();
}).then(async () => {
return await self.CollectPatients();
})
.then(async () => {
return await self.ProcessEmergencyMedicalService()
})
.then(async () => {
return await self.ProcessFireDepartment()
})
.then(async () => {
return await self.ProcessPoliceDepartment()
})
.then(async () => {
return await self.ProcessTechnicalEmergencyService()
})
.then(async () => {
return await self.ProcessWaterRescue()
}).then(() => {
var $div = $("a.btn-warning.missing_vehicles_load");
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "class") {
var attributeValue = $(mutation.target).prop(mutation.attributeName);
console.log("Class attribute changed to:", attributeValue);
Promise.resolve().then(async () => {
//<a href="/missions/923466412/missing_vehicles" class="btn btn-xs btn-warning missing_vehicles_load btn-block">Fahrzeuganzeige begrenzt! Fehlende Fahrzeuge laden! </a>
//<a href="/missions/923466412/missing_vehicles" class="btn btn-xs missing_vehicles_load btn-block" style="display: none;">Lade...</a>
// - #mission-form > div:nth-child(7) > a
return await self.PrepareVehicleNeedList();
}).then(async () => {
return await self.PrepareVehicleNeedList();
}).then(async () => {
return await self.CollectInvolvedVehicles();
}).then(async () => {
return await self.CollectPatients();
})
.then(async () => {
return await self.ProcessEmergencyMedicalService()
})
.then(async () => {
return await self.ProcessFireDepartment()
})
.then(async () => {
return await self.ProcessPoliceDepartment()
})
.then(async () => {
return await self.ProcessTechnicalEmergencyService()
})
.then(async () => {
return await self.ProcessWaterRescue()
}).then(() => {
if (self.OweSecure) {
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();
}
if (self.OweSecure) {
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();
}
}
// TODO check cars driving or already there
if (self.MissionConfig.share) {
// console.log('self.MissionConfig.share',self.MissionConfig.share)
const elems = $('#vehicle_show_table_all tr input[type="checkbox"]:checked')
// console.log('elems', elems)
for (let i = 0; i < elems.length; i++) {
if (i === 0) {
continue;
}
$(elems[i]).click();
}
}
// 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(() => {
self.UpdateMissionsToDone(self.MissionID).then(async () => {
tellParent(`setTimeout(function(){console.log('ok:${window.name}:${self.MissionID}');},2500);`);
if (window.$("#mission-form a.btn.btn-success.btn-sm.alert_notify_alliance").length > 0 && self.MissionConfig.share) {
window.$('input[type=checkbox]').prop('checked', false);
await self.WorkVerbandMission(true);
window.$('#allianceShareText').val('Kein RD, die Patiernten gehören mir! Anonsten kann nach 2h geschlossen werden. Danke für die Aufmerksamkeit!')
window.$("#mission-form a.btn.btn-success.btn-sm.alert_notify_alliance").click();
} else {
window.$('#mission_alarm_btn').click();
}
});
}, 250);
})
}
});
});
observer.observe($div[0], {
attributes: true
});
// TODO check cars driving or already there
if (self.MissionConfig.share) {
// console.log('self.MissionConfig.share',self.MissionConfig.share)
const elems = $('#vehicle_show_table_all tr input[type="checkbox"]:checked')
// console.log('elems', elems)
for (let i = 0; i < elems.length; i++) {
if (i === 0) {
continue;
}
$(elems[i]).click();
}
}
// 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(() => {
self.UpdateMissionsToDone(self.MissionID).then(async () => {
tellParent(`setTimeout(function(){console.log('ok:${window.name}:${self.MissionID}');},2500);`);
if (window.$("#mission-form a.btn.btn-success.btn-sm.alert_notify_alliance").length > 0 && self.MissionConfig.share) {
window.$('input[type=checkbox]').prop('checked', false);
await self.WorkVerbandMission(true);
window.$('#allianceShareText').val('Kein RD, die Patiernten gehören mir! Anonsten kann nach 2h geschlossen werden. Danke für die Aufmerksamkeit!')
window.$("#mission-form a.btn.btn-success.btn-sm.alert_notify_alliance").click();
} else {
window.$('#mission_alarm_btn').click();
}
});
}, 250);
})
$div.click();
}, 500);
}
// - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --