diff --git a/dist/autoloader.js b/dist/autoloader.js index 7719fee..f31a649 100755 --- a/dist/autoloader.js +++ b/dist/autoloader.js @@ -1,4 +1,4 @@ -/*Generated on:Wed Nov 28 2018 20:31:45 GMT+0100 (CET)*/ +/*Generated on:Wed Nov 28 2018 20:33:16 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 79ce916..8695973 100644 --- a/dist/autoloaderV2.js +++ b/dist/autoloaderV2.js @@ -1,4 +1,4 @@ -/*Generated on:Wed Nov 28 2018 20:31:45 GMT+0100 (CET)*/ +/*Generated on:Wed Nov 28 2018 20:33:16 GMT+0100 (CET)*/ /* * Dexie.js - a minimalistic wrapper for IndexedDB * =============================================== @@ -4592,2292 +4592,9 @@ class AutomaticDispose { that.CollectPoliceSprechwuensche(); } - /* - // - - // - Mission Variablen - // - - var MissionID; - var MissionType; - var MissionConfig; - var CurrentTime; - var MaxVehicleID = 86; - var OwnMissionsFrameWatchDog; - var KrankentransportFrameWatchDog; - var VerbandMissionFrameWatchDog; - var VerbandEventsFrameWatchDog; - var PlannedEventsFrameWatchDog; - - window.ADis_MissionDone = function ADis_MissionDone(WindowName) { - if (['adis-krankentransporte'].indexOf(WindowName) !== -1) { - $("#adis-krankentransporte-frame").attr("src", ""); - $("#adis-krankentransporte-frame").attr("mission_id", "empty"); - clearTimeout(KrankentransportFrameWatchDog); - ADis_OpenNextKrankentransporte(); - } else if (['adis-plannedevents'].indexOf(WindowName) !== -1) { - $("#adis-plannedevents-frame").attr("src", ""); - $("#adis-plannedevents-frame").attr("mission_id", "empty"); - clearTimeout(PlannedEventsFrameWatchDog); - } else if (['adis-ownmissions'].indexOf(WindowName) !== -1) { - $("#adis-ownmissions-frame").attr("src", ""); - $("#adis-ownmissions-frame").attr("mission_id", "empty"); - clearTimeout(OwnMissionsFrameWatchDog); - } else if (['adis-verbandmission'].indexOf(WindowName) !== -1) { - $("#adis-verbandmission-frame").attr("src", ""); - $("#adis-verbandmission-frame").attr("mission_id", "empty"); - clearTimeout(VerbandMissionFrameWatchDog); - } else if (['adis-verbandmission-event'].indexOf(WindowName) !== -1) { - $("#adis-verbandmission-event-frame").attr("src", ""); - $("#adis-verbandmission-event-frame").attr("mission_id", "empty"); - clearTimeout(VerbandEventsFrameWatchDog); - } - } - window.ADis_MissionUpdateDone = function ADis_MissionUpdateDone(WindowName, MissionID) { - if (['adis-krankentransporte'].indexOf(WindowName) !== -1) { - clearTimeout(KrankentransportFrameWatchDog); - ADis_UpdateKrankentransportToDone(MissionID).then(() => { - $("#adis-krankentransporte-frame").attr("src", ""); - $("#adis-krankentransporte-frame").attr("mission_id", "empty"); - console.log('call ADis_OpenNextKrankentransporte()'); - ADis_OpenNextKrankentransporte(); - }).catch((err)=>{ - console.error(err); - }); - } else if (['adis-plannedevents'].indexOf(WindowName) !== -1) { - $("#adis-plannedevents-frame").attr("src", ""); - $("#adis-plannedevents-frame").attr("mission_id", "empty"); - clearTimeout(PlannedEventsFrameWatchDog); - } else if (['adis-ownmissions'].indexOf(WindowName) !== -1) { - clearTimeout(OwnMissionsFrameWatchDog); - ADis_UpdateOwnMissionsToDone(MissionID).then(() => { - $("#adis-ownmissions-frame").attr("src", ""); - $("#adis-ownmissions-frame").attr("mission_id", "empty"); - console.log('call ADis_OpenNextOwnMissions()'); - ADis_OpenNextOwnMissions(); - }).catch((err)=>{ - console.error(err); - }); - } else if (['adis-verbandmission'].indexOf(WindowName) !== -1) { - $("#adis-verbandmission-frame").attr("src", ""); - $("#adis-verbandmission-frame").attr("mission_id", "empty"); - clearTimeout(VerbandMissionFrameWatchDog); - } else if (['adis-verbandmission-event'].indexOf(WindowName) !== -1) { - $("#adis-verbandmission-event-frame").attr("src", ""); - $("#adis-verbandmission-event-frame").attr("mission_id", "empty"); - clearTimeout(VerbandEventsFrameWatchDog); - } - } - - window.ADis_MissionUpdate = function ADis_MissionUpdate(WindowName, UpdateData) { - if (['adis-krankentransporte'].indexOf(WindowName) !== -1) { - ADis_UpdateKrankentransport(UpdateData); - ADis_OpenNextKrankentransporte(); - } else if (['adis-plannedevents'].indexOf(WindowName) !== -1) { - ADis_UpdatePlannedEvents(UpdateData); - } else if (['adis-ownmissions'].indexOf(WindowName) !== -1) { - ADis_UpdateOwnMissions(UpdateData); - } else if (['adis-verbandmission'].indexOf(WindowName) !== -1) { - ADis_UpdateVerbandMissions(UpdateData); - } else if (['adis-verbandmission-event'].indexOf(WindowName) !== -1) { - ADis_UpdateVerbandEvents(UpdateData); - } - } - - - window.ADis_MissionDelete = function ADis_MissionDelete(WindowName, MissionID) { - if ('adis-krankentransporte' === WindowName) { - ADis_RemoveKrankentransportFromQueue(MissionID); - console.log('call ADis_OpenNextOwnMissions()'); - ADis_OpenNextKrankentransporte(); - } else if (['adis-plannedevents'].indexOf(WindowName) !== -1) { - ADis_RemovePlannedEventsFromQueue(MissionID); - } else if (['adis-ownmissions'].indexOf(WindowName) !== -1) { - ADis_RemoveOwnMissionsFromQueue(MissionID); - ADis_OpenNextKrankentransporte(); - } else if (['adis-verbandmission'].indexOf(WindowName) !== -1) { - ADis_RemoveVerbandMissionsFromQueue(MissionID); - } else if (['adis-verbandmission-event'].indexOf(WindowName) !== -1) { - ADis_RemoveVerbandEventsFromQueue(MissionID); - } - } - - // - - // - Mission Opener - // - - if (window.location.pathname === "/" || window.location.pathname === "/#") { - $(document).ready(function () { - console.log("Manager load"); - //setInterval(ADis_GetAvailableMissions, 600000); // update availabla missions every 10 minutes - ADis_GetAvailableMissions(); // get availabla missions after page ready - }); - - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Grab Mission-Configuration from GitHub - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_GetAvailableMissions() { - // Get all available missions with there config - //$.getJSON(AutomaticDispose_URL + AutomaticDispose_Branch + "/all_missions.json", function (Response) { - for (let i in ADis_AllMissions) { - Mission = ADis_AllMissions[i]; - ADis_AddAvailableMissions(Mission); - } - //}); - } - - function ADis_CollectMissions() { - return ADisDB.transaction('rw', [ADisDB.ADisMissionsOwn, ADisDB.ADisSettings, ADisDB.ADisAvailabelMissions], () => { - ADisSettings().then((setting) => { - if (setting['MissionsOwn-Automatic'] == 'true') { - return ADisDB.ADisMissionsOwn.where({ - done: 'false' - }).limit(1) - } - }).then((Missions) => { - if (Missions === undefined) { - return; - } - return Missions.count(function (count) { - if (count > 0) { - return Missions.each(async (Mission) => { - return await ADisDB.ADisAvailabelMissions.get({ - type: Mission.type - }).then((available) => { - if (available == undefined) { - ADis_RemoveMissionFromQueue(Mission.missionID); - } - }).then(() => { - if ($("#mission_" + Mission.missionID).length == 0) { - return ADis_RemoveMissionFromQueue(Mission.missionID); - - } - }).then(() => { - - if ($("#mission_" + Mission.missionID).css("display") == "none") { - return ADis_RemoveMissionFromQueue(Mission.missionID); - - } - }).then(() => { - - $("#mission_" + Mission.id).animate({ - opacity: 0.5 - }, 500); - }); - }); - } - }) - }).then(() => { - $("#mission_list").find(".missionSideBarEntry").each(async function () { - var MissionID = $(this).attr("mission_id"); - // var MissionType = $(this).attr("mission_type_id"); - // var MissionName = $(this).find(".map_position_mover").text(); - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - Emergency Missions | Automatic - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - await ADis_AddMission(MissionID); - - }); - }); - }); - } - - function ADis_AddMission(ID) { - return ADisSettings().then((setting) => { - if (setting['MissionsOwn-Automatic'] == 'true') { - return ADisDB.ADisMissionsOwn.where({ - missionID: ID - }).limit(1) - } - }).then((Missions) => { - if (Missions === undefined) { - return; - } - return Missions.count(function (count) { - if (count > 0) { - return Missions.each((Mission) => { - var MissionElement = $("#mission_" + ID); - - var MissionID = MissionElement.attr("mission_id"); - var MissionType = MissionElement.attr("mission_type_id"); - var addr = MissionElement.find(".map_position_mover").text().split(",") - var MissionName = addr[0]; - var MissionStreet = addr[1]; - var MissionVillage = addr[2]; - - return ADisDB.ADisAvailabelMissions.get({ - type: MissionType - }).then((available) => { - return ADis_AddMissionToQueue({ - "id": MissionID, - "type": MissionType, - "name": MissionName, - "street": MissionStreet, - "village": MissionVillage, - "available": (available !== undefined), - "done": false, - "last_check": Math.floor(new Date().getTime() / 1000), - "next_check": Math.floor(new Date().getTime() / 1000) + 1 - }); - }); - }); - } else { - var MissionElement = $("#mission_" + ID); - - var MissionID = MissionElement.attr("mission_id"); - var MissionType = MissionElement.attr("mission_type_id"); - var addr = MissionElement.find(".map_position_mover").text().split(",") - var MissionName = addr[0]; - var MissionStreet = addr[1]; - var MissionVillage = addr[2]; - - return ADisDB.ADisAvailabelMissions.get({ - type: MissionType - }).then((available) => { - return ADis_AddMissionToQueue({ - "id": MissionID, - "type": MissionType, - "name": MissionName, - "street": MissionStreet, - "village": MissionVillage, - "available": (available !== undefined), - "done": false, - "last_check": Math.floor(new Date().getTime() / 1000), - "next_check": Math.floor(new Date().getTime() / 1000) + 1 - }); - }); - } - }); - }); - - } - - function ADis_AddAvailableMissions(Mission) { - return ADisDB.ADisAvailabelMissions.put({ - missionID: Mission.id, - type: Mission.type, - name: Mission.name, - jsondata: Mission - }).catch((err) => { - console.error(err) - }) - } - - function ADis_AddMissionToQueue(Mission) { - return ADisDB.ADisMissionsOwn.put({ - missionID: Mission.id, - type: Mission.type, - name: Mission.name, - available: Mission.available ? 'true' : 'false', - done: Mission.done ? 'true' : 'false', - street: Mission.street, - village: Mission.village, - last_check: Mission.last_check, - next_check: Mission.next_check - }).catch((err) => { - console.error(err) - }); - } - - function ADis_RemoveMissionFromQueue(MissionID) { - return ADisDB.ADisMissionsOwn.where({ - missionID: MissionID - }).delete(); - } - // - =require mission/opener.js - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Collect Own Missions - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_CollectOwnMissions() { - - var observer2 = new MutationObserver(function (mutations) { - if (mutations[0].type == "childList") { - if (mutations[0].addedNodes.length >= 1) { - // do it here - for (var i = 0; i < mutations[0].addedNodes.length; i++) - ADis_ReadAndAddOwnMissions(mutations[0].addedNodes[i].attributes.getNamedItem("mission_id").value) - } - } else { - console.log("DEBUG OwnMissions", mutations); - } - }); - - // Notify new alerts - var targetNode2 = document.getElementById("mission_list"); - observer2.observe(targetNode2, { - attributes: false, - //attributeFilter: ['class'], - //attributeOldValue: true, - characterData: false, - characterDataOldValue: false, - childList: true, - subtree: false - }); - - ADis_ReadAndAddOwnMissions(); - } - - function ADis_ReadAndAddOwnMissions(MissionID) { - return ADisDB.transaction('rw', [ADisDB.ADisMissionsOwn, ADisDB.ADisSettings, ADisDB.ADisAvailabelMissions], () => { - if (typeof MissionID != "undefined") { - ADis_AddMission(MissionID); - } else { - $("#mission_list").find(".missionSideBarEntry").each(function () { - MissionID = $(this).attr("mission_id"); - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Ambulance Service | Full-Automatic - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - ADis_AddMission(MissionID); - }); - } - }); - } - - window.ADis_OpenNextOwnMissions = function () { - return ADisDB.transaction('rw', [ADisDB.ADisMissionsOwn, ADisDB.ADisSettings, ADisDB.ADisAvailabelMissions], () => { - ADisSettings().then((setting) => { - if (setting['MissionsOwn-Automatic'] == 'true') { - return ADisDB.ADisMissionsOwn.where({ - done: 'false' - }).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) => { - let MissionID = myWunsch.missionID; - if ($("#adis-ownmissions-frame").attr("mission_id") == "empty") { - $("#adis-ownmissions-frame").attr("src", "https://www.leitstellenspiel.de/missions/" + MissionID); - $("#adis-ownmissions-frame").attr("mission_id", MissionID); - } - }); - } else { - return setTimeout(ADis_OpenNextOwnMissions, 5000); - } - }); - } - return setTimeout(ADis_OpenNextOwnMissions, 5000); - }); - }); - } - - window.ADis_AddMission = function ADis_AddMission(ID) { - return ADisSettings().then((setting) => { - if (setting['MissionsOwn-Automatic'] == 'true') { - return ADisDB.ADisMissionsOwn.where({ - missionID: ID - }).limit(1) - } - }).then((Missions) => { - if (Missions === undefined) { - return; - } - return Missions.count(function (count) { - if (count > 0) { - return Missions.each(() => { - var MissionElement = $("#mission_" + ID); - var _MissionID = MissionElement.attr("mission_id"); - var _MissionType = MissionElement.attr("mission_type_id"); - var addr = MissionElement.find(".map_position_mover").text().split(",") - var MissionName = addr[0]; - var MissionStreet = addr[1]; - var MissionVillage = addr[2]; - - return ADisDB.ADisAvailabelMissions.get({ - type: MissionType - }).then((available) => { - return ADis_AddMissionToQueue({ - "id": _MissionID, - "type": _MissionType, - "name": MissionName, - "street": MissionStreet, - "village": MissionVillage, - "available": (available !== undefined), - "done": false, - "last_check": Math.floor(new Date().getTime() / 1000), - "next_check": Math.floor(new Date().getTime() / 1000) + 1 - }); - }); - - }); - } else { - var MissionElement = $("#mission_" + ID); - - var MissionID = MissionElement.attr("mission_id"); - var MissionType = MissionElement.attr("mission_type_id"); - var addr = MissionElement.find(".map_position_mover").text().split(",") - var MissionName = addr[0]; - var MissionStreet = addr[1]; - var MissionVillage = addr[2]; - - return ADisDB.ADisAvailabelMissions.get({ - type: MissionType - }).then((available) => { - return ADis_AddMissionToQueue({ - "id": MissionID, - "type": MissionType, - "name": MissionName, - "street": MissionStreet, - "village": MissionVillage, - "available": (available !== undefined), - "done": false, - "last_check": Math.floor(new Date().getTime() / 1000), - "next_check": Math.floor(new Date().getTime() / 1000) + 1 - }); - }); - } - }); - }); - } - - window.ADis_AddOwnMissionsToQueue = function ADis_AddOwnMissionsToQueue(Mission) { - return ADisDB.ADisMissionsOwn.put({ - missionID: Mission.id, - type: Mission.type, - name: Mission.name, - available: Mission.available ? 'true' : 'false', - done: Mission.done ? 'true' : 'false', - street: Mission.street, - village: Mission.village, - last_check: Mission.last_check, - next_check: Mission.next_check - }).catch((err) => { - console.error(err) - }); - - } - - window.ADis_UpdateOwnMissions = function ADis_UpdateOwnMissions(Mission) { - return ADisDB.ADisMissionsOwn.put(Mission).catch((err) => {console.error(err)}) - } - - window.ADis_UpdateOwnMissionsToDone = function ADis_UpdateOwnMissionsToDone(MissionID) { - return ADisDB.ADisMissionsOwn.update(MissionID, { - last_check: Math.floor(new Date().getTime() / 1000), - next_check: Math.floor(new Date().getTime() / 1000) + 300 - }).catch((err) => {console.error(err)}) - } - - window.ADis_RemoveOwnMissionsFromQueue = function ADis_RemoveOwnMissionsFromQueue(MissionID) { - return ADisDB.ADisMissionsOwn.where({ - missionID: MissionID - }).delete(console.error(err)); - } - - $(document).ready(function () { - setTimeout(window.ADis_OpenNextOwnMissions, 5000); - setTimeout(window.ADis_CollectOwnMissions, 500); - }); - - $(document).ready(function () { - console.log('Krankentransporte geladen!'); - setTimeout(ADis_OpenNextKrankentransporte, 5000); - setTimeout(ADis_CollectKrankentransporte, 500); - }); - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Collect Krankentransporte - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_CollectKrankentransporte() { - - var observer2 = new MutationObserver(function (mutations) { - if (mutations[0].type == "childList") { - if (mutations[0].addedNodes.length >= 1) { - // do it here - for (var i = 0; i < mutations[0].addedNodes.length; i++) - ADis_ReadAndAddKrankentransporte(mutations[0].addedNodes[i].attributes.getNamedItem("mission_id").value) - } - } else { - console.log("DEBUG Krankentransporte", mutations); - } - }); - - // Notify new alerts - var targetNode2 = document.getElementById("mission_list_krankentransporte"); - observer2.observe(targetNode2, { - attributes: false, - //attributeFilter: ['class'], - //attributeOldValue: true, - characterData: false, - characterDataOldValue: false, - childList: true, - subtree: false - }); - - ADis_ReadAndAddKrankentransporte(); - } - - function ADis_ReadAndAddKrankentransporte(MissionID) { - if (typeof MissionID != "undefined") { - ADis_AddKrankentransportToQueue(MissionID); - } else { - $("#mission_list_krankentransporte").find(".missionSideBarEntry").each(function () { - MissionID = $(this).attr("mission_id"); - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Ambulance Service | Full-Automatic - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - ADis_AddKrankentransportToQueue(MissionID); - }); - } - } - - window.ADis_OpenNextKrankentransporte = function ADis_OpenNextKrankentransporte() { - return ADisDB.transaction('rw', [ADisDB.ADisKrankentransport, ADisDB.ADisSettings, ADisDB.ADisAvailabelMissions], () => { - ADisSettings().then((setting) => { - if (setting['Krankentransport-Automatic'] == 'true') { - return ADisDB.ADisKrankentransport.where({ - done: 'false' - }).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) => { - let MissionID = myWunsch.missionID; - if ($("#adis-krankentransporte-frame").attr("mission_id") == "empty") { - $("#adis-krankentransporte-frame").attr("src", "https://www.leitstellenspiel.de/missions/" + MissionID); - $("#adis-krankentransporte-frame").attr("mission_id", MissionID); - } - }); - } else { - return setTimeout(ADis_OpenNextKrankentransporte, 5000); - } - }); - } - return setTimeout(ADis_OpenNextKrankentransporte, 5000); - }); - }); - } - - - window.ADis_AddKrankentransportToQueue = function ADis_AddKrankentransportToQueue(MissionID) { - return ADisDB.ADisKrankentransport.put({ - missionID: MissionID, - last_check: Math.floor(new Date().getTime() / 1000), - next_check: Math.floor(new Date().getTime() / 1000) + 1, - done: 'false' - }).catch((err) => { - console.error(err) - }); - } - - window.ADis_UpdateKrankentransport = function ADis_UpdateKrankentransport(Mission) { - return ADisDB.ADisKrankentransport.put(Mission).catch((err) => { - console.error(err) - }) - } - - window.ADis_UpdateKrankentransportToDone = function ADis_UpdateKrankentransportToDone(MissionID) { - return ADisDB.ADisKrankentransport.update(MissionID, { - last_check: Math.floor(new Date().getTime() / 1000), - next_check: Math.floor(new Date().getTime() / 1000) + 300 - }).catch((err) => {console.error(err)}) - } - - window.ADis_RemoveKrankentransportFromQueue = function ADis_RemoveKrankentransportFromQueue(MissionID) { - return ADisDB.ADisKrankentransport.where({ - missionID: MissionID - }).delete(); - } - } - - - - // - - // - Mission Alert - // - - if (window.location.pathname.indexOf("/missions/") !== -1 && ['adis-krankentransporte', 'adis-ownmissions', 'adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) !== -1) { - console.log('load Mission Handler'); - $(document).ready(function () { - MissionType = null; - setTimeout(function () { - MissionID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1); - var help_el = $('a#mission_help'); - if (help_el.length > 0) { - MissionType = help_el[0].href.split("?")[0]; - var re = /\d+$/i; - var found = MissionType.match(re); - MissionType = Number(found[0]); - } else { - MissionType = null; - } - CurrentTime = Math.floor(new Date().getTime() / 1000); - console.log("MissionID", MissionID); - console.log("MissionType", MissionType); - console.log("CurrentTime", CurrentTime); - ADisSettings().then((setting) => { - if (setting['MissionsOwn-Automatic'] != 'true' && ['adis-ownmissions'].indexOf(window.name) != -1) { - return ADisDB.ADisMissionsOwn.where({ - missionID: MissionID, - done: 'false' - }).and(function (item) { - return item.next_check <= Math.floor(new Date().getTime() / 1000) - }).limit(1) - } else if (setting['MissionsOwn-Automatic'] != 'true' && ['adis-krankentransporte'].indexOf(window.name) != -1) { - return ADisDB.ADisKrankentransport.where({ - missionID: MissionID, - done: 'false' - }).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 MainHandler() - }); - } - return tellParent(`console.log('done:${window.name}:${MissionID}');ADis_MissionDelete('${window.name}', '${MissionID}');`); - }); - } - return tellParent(`console.log('done:${window.name}:${MissionID}');ADis_MissionDelete('${window.name}', '${MissionID}');`); - }) - }, 2000); - }); - - - function MainHandler(){ - if (includesString($('#iframe-inside-container > div.missionNotFound > div.missionNotFoundText').text(), 'Der Einsatz wurde erfolgreich abgeschlossen.')) { - console.log("DONE!"); - return tellParent(`console.log('done:${window.name}:${MissionID}');ADis_MissionDelete('${window.name}', '${MissionID}');`); // delete Mission here as completed - } - if (includesString($('#iframe-inside-container > div.alert.fade.in.alert-success').text(), "wurde erfolgreich informiert") /*|| $('#vehicle_show_table_all input[type="checkbox"]:checked').size() > 0*/ ) { - console.log("SEND"); - return tellParent(`console.log('update:${window.name}:${MissionID}');ADis_MissionUpdateDone('${window.name}', '${MissionID}');`); // update Mission here as updated or full - } else { - setTimeout(function () { - if (['adis-ownmissions', 'adis-krankentransporte'].indexOf(window.name) != -1) { - console.log("WILL SEND?") - ADis_CheckMissionAutomatic(); - } else if (['adis-verbandmission', 'adis-verbandmission-event'].indexOf(window.name) != -1) { - ADis_WorkVerbandMission(); - } - }, 250); - } - } - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Grab Run Verbands Missions - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_WorkVerbandMission() { - ADisSettings().then((setting) => { - var title = document.getElementById('missionH1'); - var isVerband = title.innerText.toLowerCase().includes("[verband]"); - if (setting['Alliance-Automatic'] == 'true' && isVerband) { - if ([52, 55, 129, 203].indexOf(MissionType) !== -1 && $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]')[0].click(); - } else if ([53, 130, 202].indexOf(MissionType) !== -1) { - if ($('#vehicle_show_table_all tr[vehicle_type="FLF"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="FLF"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="GW-A"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="GW-A"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="GW-Öl"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="GW-Öl"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="NEF"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="NEF"] input[type="checkbox"]')[0].click(); - } - } else if ([54, 56].indexOf(MissionType) !== -1) { - if ($('#vehicle_show_table_all tr[vehicle_type="FLF"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="FLF"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="GW-A"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="GW-A"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="GW-Öl"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="GW-Öl"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="LF 20"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="LF 20"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="LF 20/16"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="LF 20/16"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="HLF 20"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="HLF 20"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="TLF 8/8"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="TLF 8/8"] input[type="checkbox"]')[0].click(); - } - } else { - if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]')[0].click(); - } else if ($('#vehicle_show_table_all tr[vehicle_type="KTW Typ B"] input[type="checkbox"]').size() > 0) { - $('#vehicle_show_table_all tr[vehicle_type="KTW Typ B"] input[type="checkbox"]')[0].click(); - } - } - // Todo add alternative cars, please no LF because of Mülltonne.... - if ($('#vehicle_show_table_all input[type="checkbox"]:checked').size() > 0) { - $('#mission_alarm_btn').click(); - } - } - }); - } - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Grab Mission-Configuration from GitHub - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_CheckMissionAutomatic() { - var setOpt; - var missionLoad; - if (window.name == 'adis-ownmissions') { - setOpt = 'MissionsOwn-Automatic'; - missionLoad = 'ADisMissionsOwn'; - } else if (window.name == 'adis-krankentransporte') { - setOpt = 'Krankentransport-Automatic'; - missionLoad = 'ADisKrankentransport'; - } - if (setOpt && missionLoad) { - ADisSettings().then((setting) => { - if (setting[setOpt] == 'true') { - var coll = ADisDB[missionLoad].where({ - done: 'false' - }) - if (missionLoad != "ADisKrankentransport") { - coll = coll.and(function (item) { - return item.next_check <= Math.floor(new Date().getTime() / 1000) - }); - } - return coll.limit(1).toArray() - } - }).then((Missions) => { - if (Missions.length > 0) { - var Mission = Missions[0]; - AD_GetMissionConfiguration(missionLoad == 'ADisKrankentransport' ? 147 : Mission.type); - } - }); - } - } - - function AD_GetMissionConfiguration(MissionType) { - return ADisDB.transaction('rw', [ADisDB.ADisMissionsOwn, ADisDB.ADisSettings, ADisDB.ADisAvailabelMissions], () => { - return ADisDB.ADisAvailabelMissions.get({ - type: MissionType.toString() - }).then((availableMission) => { - if (availableMission != undefined && availableMission.jsondata) { - MissionConfig = availableMission.jsondata; - console.log('MissionConfig: ', MissionType.toString(), JSON.stringify(MissionConfig, null, 2)) - AD_StartAlarmProcess(); - } else { - var updateData = { - available: false, - next_check: CurrentTime + 60 - }; - ADis_UpdateOwnMissionsToDone(MissionID, updateData); - } - }); - }); - - } - - function AD_StartAlarmProcess() { - setTimeout(function () { - Promise.resolve().then(async () => { - return await ADis_PrepareVehicleNeedList(); - }).then(async () => { - return await ADis_CollectInvolvedVehicles(); - }).then(async () => { - return await ADis_CollectPatients(); - }) - .then(async () => { - return await ADis_ProcessEmergencyMedicalService() - }) - .then(async () => { - return await ADis_ProcessFireDepartment() - }) - .then(async () => { - return await ADis_ProcessPoliceDepartment() - }) - .then(async () => { - return await ADis_ProcessTechnicalEmergencyService() - }) - .then(async () => { - return await ADis_ProcessWaterRescue() - }).then(() => { - var updateData = { - last_check: CurrentTime, - next_check: CurrentTime + 60 - }; - - console.log("Clicked Vehicles: ", $('#vehicle_show_table_all input[type="checkbox"]:checked').size(), $('#vehicle_show_table_all input[type="checkbox"]:checked')); - if (['adis-ownmissions', 'adis-krankentransporte', 'adis-verbandmission'].indexOf(window.name) !== -1) { - console.log("WILL KLICK SEND") - setTimeout(() => { - $('#mission_alarm_btn').click(); - tellParent(`setTimeout(function(){console.log('ok:${window.name}:${MissionID}');ADis_MissionUpdateDone('${window.name}', '${MissionID}');},500);`); - }, 250); - } - }) - }, 500); - } - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Collect Involved Vehicles & Patients - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - var AD_Vehicles = {}; - var AD_Patients = {}; - - function ADis_CollectInvolvedVehicles() { - $("#mission_vehicle_driving tbody").find("tr").each(function () { - var VehicleID = $(this).find("a").first().attr("href").substr($(this).find("a").first().attr("href").lastIndexOf("/") + 1); - var VehicleName = $(this).find("a").first().text(); - var VehicleType = $(this).find("a").first().attr("vehicle_type_id"); - - AD_Vehicles[VehicleID] = { - "id": VehicleID, - "name": VehicleName, - "type": VehicleType - } - }); - - $("#mission_vehicle_at_mission tbody").find("tr").each(function () { - var VehicleID = $(this).find("a").first().attr("href").substr($(this).find("a").first().attr("href").lastIndexOf("/") + 1); - var VehicleName = $(this).find("a").first().text(); - var VehicleType = $(this).find("a").first().attr("vehicle_type_id"); - - AD_Vehicles[VehicleID] = { - "id": VehicleID, - "name": VehicleName, - "type": VehicleType - } - }); - - return AD_Vehicles; - } - - function ADis_CollectPatients() { - var PatientCounter = 0; - - $(".mission_patient").each(function () { - var PatientName = $(this).text(); - var PatientNeedRTW = false; - var PatientNeedNEF = false; - var PatientNeedRTH = false; - var PatientNeedLNA = false; - var PatientNeedOrgL = false; - var PatientNeedSEGKTWB = false; - var PatientNeedTragehilfe = false; - - // Wir benötigen einen RTW oder KTW Typ B. - if ($(this).find(".alert-danger").length > 0 && $(this).find(".alert-danger").text().indexOf("Wir benötigen einen RTW oder KTW Typ B") != -1) { - PatientNeedSEGKTWB = true; - } - - // Wir benötigen einen RTW. - if ($(this).find(".alert-danger").length > 0 && $(this).find(".alert-danger").text().indexOf("Wir benötigen ein RTW") != -1) { - PatientNeedRTW = true; - } - - // Wir benötigen einen NEF. - if ($(this).find(".alert-danger").length > 0 && $(this).find(".alert-danger").text().indexOf("Wir benötigen ein NEF") != -1) { - PatientNeedNEF = true; - } - - // Wir benötigen einen RTH. - if ($(this).find(".alert-danger").length > 0 && $(this).find(".alert-danger").text().indexOf("Wir benötigen ein RTH") != -1) { - PatientNeedRTH = true; - } - - // Wir benötigen einen LNA. - if ($(this).find(".alert-danger").length > 0 && $(this).find(".alert-danger").text().indexOf("Wir benötigen einen LNA") != -1) { - PatientNeedLNA = true; - } - - // Wir benötigen einen OrgL. - if ($(this).find(".alert-danger").length > 0 && $(this).find(".alert-danger").text().indexOf("Wir benötigen einen OrgL") != -1) { - PatientNeedOrgL = true; - } - - // Wir benötigen eine Tragehilfe (z.B. durch ein LF). - if ($(this).find(".alert-danger").length > 0 && $(this).find(".alert-danger").text().indexOf("Wir benötigen eine Tragehilfe") != -1) { - PatientNeedTragehilfe = true; - } - - AD_Patients[PatientCounter] = { - "name": PatientName, - "need_RTW": PatientNeedRTW, - "need_NEF": PatientNeedNEF, - "need_RTH": PatientNeedRTH, - "need_LNA": PatientNeedLNA, - "need_OrgL": PatientNeedOrgL, - "need_SEG_KTWB": PatientNeedSEGKTWB, - "need_Tragehilfe": PatientNeedTragehilfe - } - - PatientCounter++; - }); - - return AD_Patients; - } - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Process Emergency_Medical_Service - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_ProcessEmergencyMedicalService() { - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - // - Emergency Medical Service: Vehicles - // - - // - 38: KTW - // - 28: RTW - // - 29: NEF - // - 74: NAW - // - 73: GRTW - // - 31: RTH - // - 55: LNA - // - 56: OrgL - // - - // - 58: (SEG) KTW Typ B - // - 59: (SEG) ELW 1 - // - 60: (SEG) GW-San - // - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (typeof MissionConfig.emergency_medical_service == "object") // Wenn der EMS-Block in der Config definiert ist - { - if (Object.keys(AD_Patients).length >= 5) { // need LNA - ADis_VehiclesNeed["55"] = 1; - } - - if (Object.keys(AD_Patients).length >= 10) { // need OrgL - ADis_VehiclesNeed["56"] = 1; - } - - //$.each(AD_Patients, function (Key, Patient) { - for (var Key in AD_Patients) { - var Patient = AD_Patients[Key]; - if (MissionConfig.emergency_medical_service.use_KTW == true) { - if (!Patient.need_RTW && !Patient.need_NEF && !Patient.need_RTH) - ADis_VehiclesNeed["38"]++; - } - - if (Patient.need_LNA && ADis_VehiclesNeed["55"] < 1) - ADis_VehiclesNeed["55"] = 1; - - if (Patient.need_OrgL && ADis_VehiclesNeed["56"] < 1) - ADis_VehiclesNeed["56"] = 1; - - if (Patient.need_Tragehilfe == true) - ADis_VehiclesNeed["0"]++; - - if (MissionConfig.emergency_medical_service.use_RTW == true) - ADis_VehiclesNeed["28"]++; - - if (MissionConfig.emergency_medical_service.use_NEF == true) - ADis_VehiclesNeed["29"]++; - - if (MissionConfig.emergency_medical_service.use_RTH == true) - ADis_VehiclesNeed["31"]++; - }; - - // TODO: need to be refactored to make sure first KTW Typ B before RTW. - if (MissionConfig.emergency_medical_service.use_SEG_ELW1_Only == "true") { - ADis_VehiclesNeed["59"]++; - } else if (MissionConfig.emergency_medical_service.use_SEG_FULL == "true" || Object.keys(AD_Patients).length >= 3) { - ADis_VehiclesNeed["58"]++; - ADis_VehiclesNeed["58"]++; // 3x KTW Type B - ADis_VehiclesNeed["58"]++; - ADis_VehiclesNeed["59"]++; - ADis_VehiclesNeed["60"]++; - } - - var VehicleTable; - - if ($("#vehicle_show_table_body_all").length > 0) { - VehicleTable = $("#vehicle_show_table_body_all"); - } else { - VehicleTable = $("#vehicle_show_table_body_rett"); - } - - VehicleTable.find(".vehicle_select_table_tr").each(function () { - var VehicleID = $(this).attr("id").replace("vehicle_element_content_", ""); - // var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue"); - var VehicleType = $(this).attr("vehicle_type"); - - if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) { - return; - } - - if (VehicleType == "KTW" && ADis_VehiclesNeed["38"] > 0) { - // console.log(" Automatic Dispose: Fahrzeug " + VehicleID + " " + VehicleType + " markiert"); - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["38"]--; - } else if ((VehicleType == "LF 20" || VehicleType == "LF 10" || - VehicleType == "LF 8/6" || VehicleType == "LF 20/16" || - VehicleType == "LF 10/6" || VehicleType == "LF 16-TS" || - VehicleType == "HLF 20" || VehicleType == "TSF-W" || - VehicleType == "TLF 2000" || VehicleType == "TLF 3000" || - VehicleType == "TLF 8/8" || VehicleType == "TLF 8/18" || - VehicleType == "TLF 16/24-Tr" || VehicleType == "TLF 16/25" || - VehicleType == "TLF 16/45" || VehicleType == "TLF 20/40" || - VehicleType == "TLF 20/40-SL" || VehicleType == "TLF 16") && - ADis_VehiclesNeed["0"] + ADis_VehiclesNeed["1"] + ADis_VehiclesNeed["6"] + ADis_VehiclesNeed["7"] + - ADis_VehiclesNeed["8"] + ADis_VehiclesNeed["9"] + ADis_VehiclesNeed["30"] + ADis_VehiclesNeed["37"] + - ADis_VehiclesNeed["17"] + ADis_VehiclesNeed["18"] + ADis_VehiclesNeed["19"] + ADis_VehiclesNeed["20"] + - ADis_VehiclesNeed["21"] + ADis_VehiclesNeed["22"] + ADis_VehiclesNeed["23"] + ADis_VehiclesNeed["24"] + - ADis_VehiclesNeed["25"] + ADis_VehiclesNeed["26"] > 0) { // LF acts as 'Tragehilfe' - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["0"]--; - } else if (VehicleType == "NAW" && ADis_VehiclesNeed["28"] > 0 && ADis_VehiclesNeed["29"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["74"]--; - ADis_VehiclesNeed["28"]--; - ADis_VehiclesNeed["29"]--; - } else if (VehicleType == "GRTW" && ADis_VehiclesNeed["73"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["73"]--; - } else if (VehicleType == "RTW" && ADis_VehiclesNeed["28"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["28"]--; - } else if (VehicleType == "NEF" && ADis_VehiclesNeed["29"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["29"]--; - } else if (VehicleType == "RTH" && ADis_VehiclesNeed["31"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["31"]--; - } else if (VehicleType == "KdoW-LNA" && ADis_VehiclesNeed["55"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["55"]--; - } else if (VehicleType == "KdoW-OrgL" && ADis_VehiclesNeed["56"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["56"]--; - } else if (VehicleType == "KTW Typ B" && ADis_VehiclesNeed["58"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["58"]--; - ADis_VehiclesNeed["28"]--; // no need for RTW if KTW Type B is called - } else if (VehicleType == "ELW 1 (SEG)" && ADis_VehiclesNeed["59"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["59"]--; - } else if (VehicleType == "GW-San" && ADis_VehiclesNeed["60"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["60"]--; - ADis_VehiclesNeed["29"]--; // no need for NEF if GW-SAN is called - } - }); - return true; - } - return false; - } - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Process Fire_Department - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_ProcessFireDepartment() { - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - // - Fire Department: Vehicles - // - - // - 0: LF 20 - // - 1: LF 10 - // - 6: LF 8/6 - // - 7: LF 20/16 - // - 8: LF 10/6 - // - 9: LF 16-TS - // - 30: HLF 20 - // - 37: TSF-W - // - - // - 17: TLF 2000 - // - 18: TLF 3000 - // - 19: TLF 8/8 - // - 20: TLF 8/18 - // - 21: TLF 16/24-Tr - // - 22: TLF 16/25 - // - 23: TLF 16/45 - // - 24: TLF 20/40 - // - 25: TLF 20/40-SL - // - 26: TLF 16 - // - - // - 2: DLK 23 - // - 3: ELW 1 - // - 34: ELW 2 - // - 36: MTW - // - 57: FwK - // - - // - 4: RW - // - 5: GW-A - // - 10: GW-Öl - // - 12: GW-Mess - // - 53: GW-Dekon-P - // - 27: GW-Gefahrgut - // - 33: GW-Höhenrettung - // - - // - 11: GW-L2-Wasser - // - 13: SW 1000 - // - 14: SW 2000 - // - 15: SW 2000-Tr - // - 16: SW KatS - // - - // - 71: AB-MZB (see WaterRescue) - // - - // - 46: WLF - // - 47: AB-Rüst - // - 48: AB-Atemschutz - // - 49: AB-Öl - // - 54: AB-Dekon-P - // - 62: AB-Schlauch - // - - // - 75: FLF - // - 76: Rettungstreppe - // - 77: AB-Gefahrgut - // - 78: AB-Einsatzleitung - // - - // - 83: GW-Werkfeuerwehr - // - 84: ULF mit Löscharm - // - 85: TM 50 - // - 86: Turbolöscher - // - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (typeof MissionConfig.fire_department == "object") // Wenn der FD-Block in der Config definiert ist - { - - ADis_VehiclesNeed["0"] += parseInt(MissionConfig.fire_department.num_LF); - ADis_VehiclesNeed["3"] += parseInt(MissionConfig.fire_department.num_ELW_1); - ADis_VehiclesNeed["34"] += parseInt(MissionConfig.fire_department.num_ELW_2); - ADis_VehiclesNeed["2"] += parseInt(MissionConfig.fire_department.num_DLK); - ADis_VehiclesNeed["4"] += parseInt(MissionConfig.fire_department.num_RW); - ADis_VehiclesNeed["57"] += parseInt(MissionConfig.fire_department.num_FwK); - ADis_VehiclesNeed["5"] += parseInt(MissionConfig.fire_department.num_GW_A); - ADis_VehiclesNeed["27"] += parseInt(MissionConfig.fire_department.num_GW_G); - ADis_VehiclesNeed["10"] += parseInt(MissionConfig.fire_department.num_GW_Oel); - ADis_VehiclesNeed["12"] += parseInt(MissionConfig.fire_department.num_GW_Mess); - ADis_VehiclesNeed["11"] += parseInt(MissionConfig.fire_department.num_SW); - ADis_VehiclesNeed["33"] += parseInt(MissionConfig.fire_department.num_GW_Hoeh); - ADis_VehiclesNeed["53"] += parseInt(MissionConfig.fire_department.num_Dekon_P); - ADis_VehiclesNeed["75"] += parseInt(MissionConfig.fire_department.num_FLF); - ADis_VehiclesNeed["76"] += parseInt(MissionConfig.fire_department.num_Rettungstreppe); - ADis_VehiclesNeed["83"] += parseInt(MissionConfig.fire_department.num_GW_Werkfeuerwehr); - ADis_VehiclesNeed["84"] += parseInt(MissionConfig.fire_department.num_ULF_mit_Loescharm); - ADis_VehiclesNeed["86"] += parseInt(MissionConfig.fire_department.num_Turboloescher); - - var dangerText = $('#iframe-inside-container > div.alert.alert-danger').text(); - - if (includesString(dangerText, "Wir benötigen min.") && includesString(dangerText, "Feuerwehrleute.")) { - const weNeed = ADis_VehiclesNeed["0"]; - const regex = /(\d+) Feuerwehrleute/gm; - const newNeed = Math.ceil(Number(parseInt(dangerText.match(regex))) / 6) - weNeed; - ADis_VehiclesNeed["0"] = newNeed; - } - - $("#vehicle_show_table_body_all").find(".vehicle_select_table_tr").each(function () { - var VehicleID = $(this).attr("id").replace("vehicle_element_content_", ""); - // var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue"); - var VehicleType = $(this).attr("vehicle_type"); - - if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) { - return; - } - - if ((VehicleType == "LF 20" || VehicleType == "LF 10" || - VehicleType == "LF 8/6" || VehicleType == "LF 20/16" || - VehicleType == "LF 10/6" || VehicleType == "LF 16-TS" || - VehicleType == "HLF 20" || VehicleType == "TSF-W" || - VehicleType == "TLF 2000" || VehicleType == "TLF 3000" || - VehicleType == "TLF 8/8" || VehicleType == "TLF 8/18" || - VehicleType == "TLF 16/24-Tr" || VehicleType == "TLF 16/25" || - VehicleType == "TLF 16/45" || VehicleType == "TLF 20/40" || - VehicleType == "TLF 20/40-SL" || VehicleType == "TLF 16") && - ADis_VehiclesNeed["0"] + ADis_VehiclesNeed["1"] + ADis_VehiclesNeed["6"] + ADis_VehiclesNeed["7"] + - ADis_VehiclesNeed["8"] + ADis_VehiclesNeed["9"] + ADis_VehiclesNeed["30"] + ADis_VehiclesNeed["37"] + - ADis_VehiclesNeed["17"] + ADis_VehiclesNeed["18"] + ADis_VehiclesNeed["19"] + ADis_VehiclesNeed["20"] + - ADis_VehiclesNeed["21"] + ADis_VehiclesNeed["22"] + ADis_VehiclesNeed["23"] + ADis_VehiclesNeed["24"] + - ADis_VehiclesNeed["25"] + ADis_VehiclesNeed["26"] > 0) { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["0"]--; - - } else if (VehicleType == "HLF 20" && ADis_VehiclesNeed["4"] > 0) // HLF 20 acts as RW - { - ADis_VehiclesNeed["0"]--; - ADis_VehiclesNeed["4"]--; - $("#vehicle_checkbox_" + VehicleID).click(); - } else if ((VehicleType == "DLK 23" || VehicleType == "TM 50") && ADis_VehiclesNeed["2"] > 0) // DLK 23 - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["2"]--; - } else if (VehicleType == "AB-Einsatzleitung" && - ADis_VehiclesNeed["3"] + ADis_VehiclesNeed["34"] + ADis_VehiclesNeed["78"] > 0) // ELW 1 + ELW 2 - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["3"]--; - ADis_VehiclesNeed["34"]--; - } else if (VehicleType == "ELW 2" && ADis_VehiclesNeed["3"] + ADis_VehiclesNeed["34"] > 0) // ELW 2 - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["3"]--; - ADis_VehiclesNeed["34"]--; - } else if (VehicleType == "ELW 1" && ADis_VehiclesNeed["3"] > 0) // ELW 1 - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["3"]--; - } else if (VehicleType == "MTW" && ADis_VehiclesNeed["36"] > 0) // MTW - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["36"]--; - } else if (VehicleType == "FwK" && ADis_VehiclesNeed["57"] > 0) // FwK - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["57"]--; - } else if (VehicleType == "GWK" && - ADis_VehiclesNeed["4"] > 0) // GWK acts as RW - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["4"]--; - ADis_VehiclesNeed["39"]--; - } else if ((VehicleType == "RW" || - VehicleType == "HLF 20" || - VehicleType == "AB-Rüst") && - ADis_VehiclesNeed["4"] > 0) // RW - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["4"]--; - } else if ((VehicleType == "GW-A" || - VehicleType == "AB-Atemschutz") && - ADis_VehiclesNeed["5"] > 0) // GW-A - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["5"]--; - } else if ((VehicleType == "GW-Öl" || - VehicleType == "AB-Öl") && - ADis_VehiclesNeed["10"] > 0) // GW-Öl - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["10"]--; - } else if (VehicleType == "GW-Messtechnik" && ADis_VehiclesNeed["12"] > 0) // FwK - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["12"]--; - } else if ((VehicleType == "GW-L2-Wasser" || - VehicleType == "SW 1000" || - VehicleType == "SW 2000" || - VehicleType == "SW 2000-Tr" || - VehicleType == "SW Kats" || - VehicleType == "AB-Schlauch") && - ADis_VehiclesNeed["11"] > 0) // SW - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["11"]--; - } else if ((VehicleType == "GW-Gefahrgut" || - VehicleType == "AB-Gefahrgut") && ADis_VehiclesNeed["27"] > 0) // GW-Gefahrgut - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["27"]--; - } else if (VehicleType == "GW-Höhenrettung" && ADis_VehiclesNeed["33"] > 0) // GW-Höhenrettung - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["33"]--; - } else if ((VehicleType == "Dekon-P" || - VehicleType == "AB-Dekon-P") && - ADis_VehiclesNeed["53"] > 0) // Dekon-P - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["53"]--; - } else if (VehicleType == "GW-Werkfeuerwehr" && - ADis_VehiclesNeed["83"] > 0) // GW-Werkfeuerwehr - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["83"]--; - } else if (VehicleType == "ULF mit Löscharm" && - ADis_VehiclesNeed["84"] > 0) // ULF mit Löscharm - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["84"]--; - } - /* - else if (VehicleType == "TM 50" && - ADis_VehiclesNeed["85"] > 0) // TM 50 - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["85"]--; - } - */ - else if (VehicleType == "Turbolöscher" && - ADis_VehiclesNeed["86"] > 0) // Turbolöscher - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["86"]--; - } else if (VehicleType == "FLF" && - ADis_VehiclesNeed["75"] > 0) // FLF - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["75"]--; - } else if (VehicleType == "Rettungstreppe" && - ADis_VehiclesNeed["76"] > 0) // Rettungstreppe - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["76"]--; - } - }); - return true; - } - return false; - } - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Process Police_Department - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_ProcessPoliceDepartment() { - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - // - Fire Department: Vehicles - // - - // - 32: FuStW - // - 35: leBefKw - // - 50: GruKw - // - 51: FüKw - // - 52: GefKw - // - 72: WaWe - // - 61: Polizeihubschrauber - // - 79: SEK - ZF - // - 80: SEK - MTF - // - 81: MEK - ZF - // - 82: MEK - MTF - // - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (typeof MissionConfig.police_department == "object") // Wenn der FD-Block in der Config definiert ist - { - ADis_VehiclesNeed["32"] += parseInt(MissionConfig.police_department.num_FuStW); - ADis_VehiclesNeed["35"] += parseInt(MissionConfig.police_department.num_leBefKw); - ADis_VehiclesNeed["50"] += parseInt(MissionConfig.police_department.num_GruKw); - ADis_VehiclesNeed["51"] += parseInt(MissionConfig.police_department.num_FueKw); - ADis_VehiclesNeed["52"] += parseInt(MissionConfig.police_department.num_GefKw); - ADis_VehiclesNeed["72"] += parseInt(MissionConfig.police_department.num_WaWe); - ADis_VehiclesNeed["61"] += parseInt(MissionConfig.police_department.num_PHu); - ADis_VehiclesNeed["79"] += parseInt(MissionConfig.police_department.num_SEK_ZF); - ADis_VehiclesNeed["80"] += parseInt(MissionConfig.police_department.num_SEK_MTF); - ADis_VehiclesNeed["81"] += parseInt(MissionConfig.police_department.num_MEK_ZF); - ADis_VehiclesNeed["82"] += parseInt(MissionConfig.police_department.num_MEK_MTF); - - $("#vehicle_show_table_body_all").find(".vehicle_select_table_tr").each(function () { - var VehicleID = $(this).attr("id").replace("vehicle_element_content_", ""); - // var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue"); - var VehicleType = $(this).attr("vehicle_type"); - - if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) { - return; - } - - if (VehicleType == "FuStW" && ADis_VehiclesNeed["32"] > 0) // FuStW - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["32"]--; - } else if (VehicleType == "leBefKw" && ADis_VehiclesNeed["35"] > 0) // leBefKw - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["35"]--; - } else if (VehicleType == "GruKw" && ADis_VehiclesNeed["50"] > 0) // GruKw - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["50"]--; - } else if (VehicleType == "FüKw" && ADis_VehiclesNeed["51"] > 0) // FüKw - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["51"]--; - } else if (VehicleType == "GefKw" && ADis_VehiclesNeed["52"] > 0) // GefKw - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["52"]--; - } else if (VehicleType == "WaWe 10" && ADis_VehiclesNeed["72"] > 0) // WaWe 10 - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["72"]--; - } else if (VehicleType == "Polizeihubschrauber" && ADis_VehiclesNeed["61"] > 0) // PHu - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["61"]--; - } else if (VehicleType == "SEK - ZF" && ADis_VehiclesNeed["79"] > 0) // SEK-ZF - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["79"]--; - } else if (VehicleType == "SEK - MTF" && ADis_VehiclesNeed["80"] > 0) // SEK-MTF - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["80"]--; - } else if (VehicleType == "MEK - ZF" && ADis_VehiclesNeed["81"] > 0) // MEK-ZF - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["81"]--; - } else if (VehicleType == "MEK - MTF" && ADis_VehiclesNeed["82"] > 0) // MEK-MTF - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["82"]--; - } - }); - return true; - } - return false; - } - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Process Water_Rescue - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_ProcessWaterRescue() { - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - // - Water Rescue: Vehicles - // - - // - 63: GW-Taucher - // - 64: GW-Wasserrettung - // - 69: Tauchkraftwagen (handel it here;TechnicalEmergencyService) - // - - // - Boote: - // - - // - 66: Anh MzB (handel it here;TechnicalEmergencyService) - // - 67: Anh SchlB (handel it here;TechnicalEmergencyService) - // - 68: Anh MzAB (handel it here;TechnicalEmergencyService) - // - 70: MZB - // - 71: AB-MZB (handel it here;FireDepartment) - // - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (typeof MissionConfig.water_rescue == "object") { - ADis_VehiclesNeed["63"] += parseInt(MissionConfig.water_rescue.num_GW_T); - ADis_VehiclesNeed["64"] += parseInt(MissionConfig.water_rescue.num_GW_W); - ADis_VehiclesNeed["70"] += parseInt(MissionConfig.water_rescue.num_MzB); - - $("#vehicle_show_table_body_all").find(".vehicle_select_table_tr").each(function () { - var VehicleID = $(this).attr("id").replace("vehicle_element_content_", ""); - // var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue"); - var VehicleType = $(this).attr("vehicle_type"); - - if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) { - return; - } - - if ((VehicleType == "GW-Taucher" || - VehicleType == "Tauchkraftwagen") && ADis_VehiclesNeed["63"] > 0) // GW-Taucher - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["63"]--; - } else if (VehicleType == "GW-Wasserrettung" && ADis_VehiclesNeed["64"] > 0) // GW-Wasserrettung - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["64"]--; - } else if ((VehicleType == "MZB" || VehicleType == "Anh MzB" || - VehicleType == "Anh MzAB" || VehicleType == "Anh SchlB" || - VehicleType == "AB-MZB") && ADis_VehiclesNeed["66"] + ADis_VehiclesNeed["67"] + ADis_VehiclesNeed["68"] + - ADis_VehiclesNeed["70"] + ADis_VehiclesNeed["71"] > 0) // Boote - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["70"]--; - } - }); - return true; - } - return false; - } - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Process Technical Emergency Service - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_ProcessTechnicalEmergencyService() { - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - // - THW: Vehicles - // - - // - 39: GKW (see also FireDepartment) - // - 40: MTW-TZ - // - 41: MzKW - // - 42: LKW K 9 - // - 43: BRmG R - // - - // - 44: Anh DLE - // - 45: MLW 5 - // - 65: LKW 7 Lkr 19 tm - // - 69: Tauchkraftwagen (see WaterRescue) - // - - // - 66: Anh MzB (see WaterRescue) - // - 67: Anh SchlB (see WaterRescue) - // - 68: Anh MzAB (see WaterRescue) - // - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (typeof MissionConfig.technical_emergency_service == "object") { - ADis_VehiclesNeed["39"] += parseInt(MissionConfig.technical_emergency_service.num_GKW); - ADis_VehiclesNeed["40"] += parseInt(MissionConfig.technical_emergency_service.num_MTW_TZ); - ADis_VehiclesNeed["41"] += parseInt(MissionConfig.technical_emergency_service.num_MzKW); - ADis_VehiclesNeed["42"] += parseInt(MissionConfig.technical_emergency_service.num_LKW_K9); - ADis_VehiclesNeed["43"] += parseInt(MissionConfig.technical_emergency_service.num_BRmG_R); - ADis_VehiclesNeed["44"] += parseInt(MissionConfig.technical_emergency_service.num_Anh_DLE); - ADis_VehiclesNeed["45"] += parseInt(MissionConfig.technical_emergency_service.num_MLW_5); - ADis_VehiclesNeed["65"] += parseInt(MissionConfig.technical_emergency_service.num_LKW_7Lkr); - - $("#vehicle_show_table_body_all").find(".vehicle_select_table_tr").each(function () { - var VehicleID = $(this).attr("id").replace("vehicle_element_content_", ""); - // var VehicleDistanceTime = $("#vehicle_sort_" + VehicleID).attr("sortvalue"); - var VehicleType = $(this).attr("vehicle_type"); - - if ($("#vehicle_checkbox_" + VehicleID + ":enabled").length === 0) { - return; - } - - if (VehicleType == "GKW" && ADis_VehiclesNeed["39"] > 0) // GKW - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["39"]--; - } else if (VehicleType == "MTW-TZ" && ADis_VehiclesNeed["40"] > 0) // MTW-TZ - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["40"]--; - } else if (VehicleType == "MzKW" && ADis_VehiclesNeed["41"] > 0) // MzKW - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["41"]--; - } else if (VehicleType == "LKW K 9" && ADis_VehiclesNeed["42"] > 0) // LKW K 9 - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["42"]--; - } else if (VehicleType == "BRmG R" && ADis_VehiclesNeed["43"] > 0) // BRmG R - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["43"]--; - } else if (VehicleType == "Anh DLE" && ADis_VehiclesNeed["44"] > 0) // Anh DLE - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["44"]--; - } else if (VehicleType == "MLW 5" && ADis_VehiclesNeed["45"] > 0) // MLW 5 - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["45"]--; - } else if (VehicleType == "LKW 7 Lkr 19 tm" && ADis_VehiclesNeed["65"] > 0) // LKW 7 Lkr 19 tm - { - $("#vehicle_checkbox_" + VehicleID).click(); - ADis_VehiclesNeed["65"]--; - } - }); - return true; - } - return false; - } - - var ADis_VehiclesNeed = {}; - - function ADis_PrepareVehicleNeedList() { - for (VehicleTypeID = 0; VehicleTypeID <= MaxVehicleID; VehicleTypeID++) { - ADis_VehiclesNeed[VehicleTypeID] = 0; - } - for (VehicleTypeID = 0; VehicleTypeID <= MaxVehicleID; VehicleTypeID++) { - ADis_CountInvolvedVehiclesOfType(VehicleTypeID); - } - return true; - } - - function ADis_CountInvolvedVehiclesOfType(VehicleTypeID) { - for (var Key in AD_Vehicles) { - var Vehicle = AD_Vehicles[Key]; - if (Vehicle.type == VehicleTypeID) { - ADis_SelectCountVehicles(VehicleTypeID); - } - }; - - $("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each(function () { - if ($(this).find("a").first().attr("vehicle_type_id") == VehicleTypeID) { - ADis_SelectCountVehicles(VehicleTypeID); - } - }); - - return; - } - - function ADis_SelectCountVehicles(VehicleTypeID) { - var VehicleTypeID = Number(VehicleTypeID); - if ([38].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed[VehicleTypeID]--; - } else if ([0, 1, 6, 7, 8, 9, 30, 37, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26].indexOf(VehicleTypeID) != -1) { // LF acts as 'Tragehilfe' - // 30 acts as Rüstwagen - if ([30].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["4"]--; - ADis_VehiclesNeed["39"]--; - } - // 0 acts as all LF - ADis_VehiclesNeed["0"]--; - } else if ([74].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["74"]--; - ADis_VehiclesNeed["28"]--; - ADis_VehiclesNeed["29"]--; - } else if ([73].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["73"]--; - } else if ([28].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["28"]--; - } else if ([29].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["29"]--; - } else if ([31].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["31"]--; - } else if ([55].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["55"]--; - } else if ([56].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["56"]--; - } else if ([58].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["58"]--; - } else if ([59].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["59"]--; - } else if ([60].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["60"]--; - } else if ([2].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["2"]--; - } else if ([34, 78].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["3"]--; - ADis_VehiclesNeed["34"]--; - } else if ([3].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["3"]--; - } else if ([36].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["36"]--; - } else if ([57].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["57"]--; - } else if ([4, 39].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["4"]--; - ADis_VehiclesNeed["39"]--; - } else if ([4, 47].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["4"]--; - } else if ([5, 48].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["5"]--; - } else if ([10, 49].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["10"]--; - } else if ([12].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["12"]--; - } else if ([11, 13, 14, 15, 16].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["11"]--; - } else if ([27, 77].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["27"]--; - } else if ([33].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["33"]--; - } else if ([53, 54].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["53"]--; - } else if ([83].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["83"]--; - } else if ([84].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["84"]--; - } else if ([85].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["85"]--; - ADis_VehiclesNeed["2"]--; - } else if ([86].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["86"]--; - } else if ([75].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["75"]--; - } else if ([76].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["76"]--; - } else if ([32].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["32"]--; - } else if ([35].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["35"]--; - } else if ([50].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["50"]--; - } else if ([51].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["51"]--; - } else if ([52].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["52"]--; - } else if ([72].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["72"]--; - } else if ([61].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["61"]--; - } else if ([79].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["79"]--; - } else if ([80].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["80"]--; - } else if ([81].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["81"]--; - } else if ([82].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["82"]--; - } else if ([63, 69].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["63"]--; - } else if ([64].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["64"]--; - } else if ([66, 67, 68, 70, 71].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["70"]--; - } else if ([40].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["40"]--; - } else if ([41].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["41"]--; - } else if ([42].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["42"]--; - } else if ([43].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["43"]--; - } else if ([44].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["44"]--; - } else if ([45].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["45"]--; - } else if ([65].indexOf(VehicleTypeID) != -1) { - ADis_VehiclesNeed["65"]--; - } - } - - function ADis_CheckNeedMoreVehicles() { - var NeedMoreVehicles = false; - - for (var Key in ADis_VehiclesNeed) { - var VehicleCount = ADis_VehiclesNeed[Key]; - if (VehicleCount > 0) { - NeedMoreVehicles = true; - } - }; - - return NeedMoreVehicles; - } - } - // - - // - Sprechwunsch Variablen - // - - var Jails = []; - var JailRegEx = /\(Freie Zellen\:\s+(\d)\,\s+Entfernung\:\s+(\d+\,\d+)\s+km(?:\,\s+Abgabe an Besitzer\:\s+(\d+)%)?\)/g; - var Hospitals = []; - var RescueVehicleFrameWatchDog; - var PoliceVehicleFrameWatchDog; - - - // - - // - Sprechwunsch Queue - // - - - function ADis_RemovePoliceSprechwunschFromQueue(WunschID) { - return ADisDB.ADisSprechwunschPolice.where({ - missionID: WunschID - }).delete(); - } - function ADis_RemoveRescueSprechwunschFromQueue(WunschID) { - return ADisDB.ADisSprechwunsch.where({ - vehicleID: WunschID - }).delete(); - } - - // - - // - Sprechwunsch Opener - // - - if (window.location.pathname === "/" || window.location.pathname === "/#") { - $(document).ready(function () { - setInterval(ADis_CollectRescueSprechwuensche, 2500); - setInterval(ADis_OpenNextRescueSprechwunsch, 2500); - ADis_CollectRescueSprechwuensche(); - }); - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Assign & Unassign Missions to Dispatchers - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_CollectRescueSprechwuensche() { - new Promise(async function (resolve, reject) { - await ADisDB.ADisSprechwunsch.where({ - done: 'false' - }).each((myWunsch) => { - console.log('ADis_CollectRescueSprechwuensche: remove', myWunsch); - if ($("#vehicle_list_" + myWunsch.vehicleID).find(".building_list_fms").text() != "5") { - return ADis_RemoveRescueSprechwunschFromQueue(myWunsch.vehicleID); - } - }) - return resolve(); - }).then(() => { - $("#building_list").find(".building_list_vehicle_element").each(function () { - var VehicleStatus = $(this).find(".building_list_fms").text(); - var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id"))); - var VehicleID = $(this).attr("vehicle_id"); - if (VehicleStatus == "5" && [32, 52].indexOf(VehicleType) === -1) { - ADis_AddRescueSprechwunschToQueue(VehicleID); - } - }); - }); - } - - function ADis_OpenNextRescueSprechwunsch() { - ADisSettings().then((setting) => { - if (setting['Sprechwunsch-Automatic'] == 'true') { - return ADisDB.ADisSprechwunsch.where({ - done: 'false' - }).limit(1) - } - }).then((Wunsch) => { - if (Wunsch !== undefined) { - Wunsch.each((myWunsch) => { - let VehicleID = myWunsch.vehicleID; - ADis_UpdateRescueSprechwunschToDone(VehicleID).then(() => { - if ($("#adis-sprechwunsch-rescue-frame").attr("vehicle_id") == "empty") { - $("#adis-sprechwunsch-rescue-frame").attr("src", "https://www.leitstellenspiel.de/vehicles/" + VehicleID); - $("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", VehicleID); - - RescueVehicleFrameWatchDog = setTimeout(async function () { - ADis_RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => { - $("#adis-sprechwunsch-rescue-frame").attr("src", ""); - $("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty"); - }); - }, 1500); - } - }); - }); - } - }); - } - - function ADis_AddRescueSprechwunschToQueue(WunschID) { - return ADisDB.ADisSprechwunsch.put({ - vehicleID: WunschID, - done: 'false' - }).catch((err) => {}) - } - - - function ADis_UpdateRescueSprechwunschToDone(WunschID) { - return ADisDB.ADisSprechwunsch.put({ - vehicleID: WunschID, - done: 'true' - }).catch((err) => {}) - } - $(document).ready(function () { - setInterval(ADis_CollectPoliceSprechwuensche, 5000); - setInterval(ADis_OpenNextPoliceSprechwunsch, 5000); - ADis_CollectPoliceSprechwuensche(); - }); - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - // - - // - Assign & Unassign Missions to Dispatchers - // - - // - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - function ADis_CollectPoliceSprechwuensche() { - new Promise(async function (resolve, reject) { - await ADisDB.ADisSprechwunschPolice.where({ - done: 'false' - }).each((myWunsch) => { - if (!$("#mission_" + myWunsch.missionID).text().match(/Gefangene sollen abtransportiert werden/g)) { - $("#mission_" + myWunsch.missionID).remove(); - return ADis_RemovePoliceSprechwunschFromQueue(myWunsch.missionID); - } - }) - return resolve(); - }).then(() => { - var MOIODOS = $('div#mission_list div.missionSideBarEntry:visible'); - return MOIODOS.each(function (index) { - if ($(this).text().match(/Gefangene sollen abtransportiert werden/g)) { - var MissionID = $(this).attr("mission_id"); - ADis_AddPoliceSprechwunschToQueue(MissionID); - } - }); - }).then(() => { - $("#building_list").find(".building_list_vehicle_element").each(function () { - var VehicleStatus = $(this).find(".building_list_fms").text(); - var VehicleType = Number(parseInt($(this).find("a").attr("vehicle_type_id"))); - var VehicleID = $(this).attr("vehicle_id"); - if (VehicleStatus == "5" && [32, 52].indexOf(VehicleType) !== -1) { - var map2 = $('#radio_messages_important > li.radio_message_vehicle_' + VehicleID + ' a:contains("Zum Einsatz")'); - if (map2.length > 0) { - var _meap = String(map2.attr('href')); - var MissionID = _meap.substr(_meap.lastIndexOf("/") + 1); - if (MissionID) { - ADis_AddPoliceSprechwunschToQueue(MissionID); - } - } - } - }); - }); - } - - function ADis_OpenNextPoliceSprechwunsch() { - ADisSettings().then((setting) => { - if (setting['Sprechwunsch-Automatic'] == 'true') { - return ADisDB.ADisSprechwunschPolice.where({ - done: 'false' - }).limit(1) - } - }).then((Wunsch) => { - if (Wunsch !== undefined) { - Wunsch.each((myWunsch) => { - let MissionID = myWunsch.missionID; - ADis_UpdatePoliceSprechwunschToDone(MissionID).then(() => { - if ($("#adis-sprechwunsch-police-frame").attr("mission_id") == "empty") { - $("#adis-sprechwunsch-police-frame").attr("src", "https://www.leitstellenspiel.de/missions/" + MissionID); - $("#adis-sprechwunsch-police-frame").attr("mission_id", MissionID); - - PoliceVehicleFrameWatchDog = setTimeout(async function (MissionID) { - ADis_RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => { - $("#adis-sprechwunsch-police-frame").attr("src", ""); - $("#adis-sprechwunsch-police-frame").attr("mission_id", "empty"); - }); - }, 2500, MissionID); - } - }); - }); - } - }); - } - - function ADis_AddPoliceSprechwunschToQueue(WunschID) { - return ADisDB.ADisSprechwunschPolice.put({ - missionID: WunschID, - done: 'false' - }).catch((err) => {}) - } - - - function ADis_UpdatePoliceSprechwunschToDone(WunschID) { - console.log(WunschID, typeof WunschID); - return ADisDB.ADisSprechwunschPolice.add({ - missionID: WunschID, - done: 'true' - }).catch((err) => {}) - } - } - - // - - // - Sprechwunsch Handler Rettung - // - - if (window.location.pathname.indexOf("/vehicles/") !== -1 && window.name == 'adis-sprechwunsch-rescue') { - $(document).ready(function () { - setTimeout(function () { - ADis_Check_Call_Active(); - }, 250); - }); - - function ADis_Check_Call_Active() { - if ($("h4:contains('Eigene Krankenhäuser')").length > 0 || $("h4:contains('Verbandskrankenhäuser')").length > 0) { - ADis_Collect_Hospitals(); - } else { - VehicleID = document.location.pathname.substr(document.location.pathname.lastIndexOf("/") + 1); - ADis_RemoveRescueSprechwunschFromQueue(VehicleID).then((deleteCount) => { - $("#adis-sprechwunsch-rescue-frame").attr("src", ""); - $("#adis-sprechwunsch-rescue-frame").attr("vehicle_id", "empty"); - }); - } - } - - // Krankenhaus auswählen - function ADis_Collect_Hospitals() { - if ($("h4:contains('Eigene Krankenhäuser')").length > 0) { - $("h4:contains('Eigene Krankenhäuser')").next("table").find("tbody").find("tr").each(function () { - var HospitalHref = $(this).find("a:contains('Anfahren')").attr("href"); - var HospitalID = Number(parseInt($(this).find("a:contains('Anfahren')").attr("id").replace("btn_approach_", ""))); - var HospitalDistance = parseInt($(this).find("td").eq("1").text()); - var HospitalFreeBeds = parseInt($(this).find("td").eq("2").text()); - - var HospitalValue = HospitalDistance * 450 * -1; - HospitalValue += 2000; // Own Hospitals are better :-) - if ($(this).find(".label:contains('Ja')").length > 0) { - HospitalValue += 2000; - } - - if (HospitalFreeBeds > 0) { - Hospitals.push({ - "id": HospitalID, - "value": HospitalValue, - "distance": HospitalDistance, - "href": HospitalHref - }); - } - }); - } - - if ($("h4:contains('Verbandskrankenhäuser')").length > 0) { - $("h4:contains('Verbandskrankenhäuser')").next("table").find("tbody").find("tr").each(function () { - var HospitalHref = $(this).find("a").attr("href") - var HospitalID = Number(parseInt(HospitalHref.substr(HospitalHref.lastIndexOf("/") + 1))); - var HospitalDistance = parseInt($(this).find("td").eq("1").text()); - var HospitalFreeBeds = parseInt($(this).find("td").eq("2").text()); - var HospitalTaxes = parseInt($(this).find("td").eq("3").text()); - var HospitalSpecialDepartment = false; - - // Add Button-ID to Alliance-Hospital - $(this).find("a").attr("id", "btn_approach_" + HospitalID.toString()); - - var HospitalValue = HospitalDistance * 450 * -1; - - if ($(this).find(".label:contains('Ja')").length > 0) { - HospitalSpecialDepartment = true; - HospitalValue += 2000; - } - - if (HospitalTaxes == 0) { - HospitalValue += 2000; - } else if (HospitalTaxes > 0 && HospitalTaxes <= 10) { - HospitalValue += 1000; - } else if (HospitalTaxes > 10 && HospitalTaxes <= 20) { - HospitalValue += 0; - } else { - HospitalValue -= 5000; - } - - if (HospitalFreeBeds > 0 && HospitalSpecialDepartment) { - Hospitals.push({ - "id": HospitalID, - "value": HospitalValue, - "taxes": HospitalTaxes, - "distance": HospitalDistance, - "href": HospitalHref - }); - } - }); - } - - Hospitals.sort(function (a, b) { - return a.value - b.value; - }); - - Hospitals.reverse(); - ADis_Send_Vehicle_To_Hospital() - } - - // Krankenhaus einlieferung - function ADis_Send_Vehicle_To_Hospital() { - //var HospitalID = Hospitals[0].id; - var HospitalHref = Hospitals[0].href; - - // TODO: tellParent("ADisMissionDone(" + window.name + "," + MissionID + ");"); - document.location.href = document.location.origin + HospitalHref; - - } - } - - // - - // - Sprechwunsch Handler Polizei/Gefangene - // - - if (window.location.pathname.indexOf("/missions/") !== -1 && window.name == 'adis-sprechwunsch-police') { - $(document).ready(function () { - - console.log('Police Sprechwunsch load handler: start'); - setTimeout(function () { - ADis_Check_Call_Police_Active(); - }, 250); - }); - - function ADis_Check_Call_Police_Active() { - if ($('#h2_prisoners').length > 0) { - ADis_Collect_Jails(); - } else { - ADis_RemovePoliceSprechwunschFromQueue(MissionID).then((deleteCount) => { - $("#adis-sprechwunsch-police-frame").attr("src", ""); - $("#adis-sprechwunsch-police-frame").attr("mission_id", "empty"); - }); - } - } - - // Gefängnis auswählen - function ADis_Collect_Jails() { - var CountGefangene = Number(parseInt($('#h2_prisoners').text())); - var parentNode = $('#mission_vehicle_at_mission tr > td:nth-child(5) > a:contains("Jomaar")').parent().parent(); - var GefKw = parentNode.find('td:nth-child(2) > a[vehicle_type_id="52"]'); - var FuStW = parentNode.find('td:nth-child(2) > a[vehicle_type_id="32"]'); - var GefKwGefaegnisse = $(GefKw[0]).parent().parent().next('tr'); - var FuStWGefaegnisse = $(FuStW[0]).parent().parent().next('tr'); - - GefKwGefaegnisse.find("a:contains('Freie Zellen')").each(function () { - var JailHref = $(this).attr("href"); - var JailID = JailHref.split("/").pop(); - var JailText = $(this).text(); - var JailFreeBeds = 0; - var JailDistance = 0; - var JailTax = 0; - let m; - while ((m = JailRegEx.exec(JailText)) !== null) { - // This is necessary to avoid infinite loops with zero-width matches - if (m.index === JailRegEx.lastIndex) { - JailRegEx.lastIndex++; - } - - // The result can be accessed through the `m`-variable. - m.forEach((match, groupIndex) => { - if (groupIndex == 1) { - JailFreeBeds = parseInt(match.trim()); - } else if (groupIndex == 2) { - JailDistance = parseInt(match.trim()); - } else if (groupIndex == 3 && typeof match != "undefined") { - JailTax = parseInt(match.trim()); - } - }); - } - - var JailValue = JailDistance * 450 * -1; - JailValue += 11; //GefKw bevorzugt - - if (JailTax == 0) { - JailValue += 10000; - } else if (JailTax > 0 && JailTax <= 10) { - JailValue += 5000; - } else if (JailTax > 10 && JailTax <= 20) { - JailValue += 1000; - } else { - JailValue -= 10000; - } - - if (JailFreeBeds >= 5) { - JailValue += 15000; - } else if (JailFreeBeds >= 1) { - JailValue += 1000; - } else { - JailValue -= 5000; - } - - if (JailFreeBeds >= 5) { - Jails.push({ - "id": JailID, - "value": JailValue + 1000, - "text": JailText, - "distance": JailDistance, - "href": JailHref - }); - } else if (JailFreeBeds >= 1) { - Jails.push({ - "id": JailID, - "value": JailValue, - "text": JailText, - "distance": JailDistance, - "href": JailHref - }); - } - }); - FuStWGefaegnisse.find("a:contains('Freie Zellen')").each(function () { - var JailHref = $(this).attr("href"); - var JailID = JailHref.split("/").pop(); - var JailText = $(this).text(); - var JailFreeBeds = 0; - var JailDistance = 0; - var JailTax = 0; - let m; - while ((m = JailRegEx.exec(JailText)) !== null) { - // This is necessary to avoid infinite loops with zero-width matches - if (m.index === JailRegEx.lastIndex) { - JailRegEx.lastIndex++; - } - - // The result can be accessed through the `m`-variable. - m.forEach((match, groupIndex) => { - if (groupIndex == 1) { - JailFreeBeds = parseInt(match.trim()); - } else if (groupIndex == 2) { - JailDistance = parseInt(match.trim()); - } else if (groupIndex == 3 && typeof match != "undefined") { - JailTax = parseInt(match.trim()); - } - }); - } - - var JailValue = JailDistance * 450 * -1; - - if (JailTax == 0) { - JailValue += 10000; - } else if (JailTax > 0 && JailTax <= 10) { - JailValue += 5000; - } else if (JailTax > 10 && JailTax <= 20) { - JailValue += 1000; - } else { - JailValue -= 10000; - } - - if (JailFreeBeds >= 5) { - JailValue += 15000; - } else if (JailFreeBeds >= 1) { - JailValue += 1000; - } else { - JailValue -= 5000; - } - - if (JailFreeBeds >= CountGefangene) { - Jails.push({ - "id": JailID, - "value": JailValue + 1000, - "text": JailText, - "distance": JailDistance, - "href": JailHref - }); - } else if (JailFreeBeds >= 1) { - Jails.push({ - "id": JailID, - "value": JailValue, - "text": JailText, - "distance": JailDistance, - "href": JailHref - }); - } - }); - - Jails.sort(function (a, b) { - return a.value - b.value; - }); - - Jails.reverse(); - if (Jails.length > 0) { - ADis_Send_Vehicle_To_Jail() - } else { - $("#mission_vehicle_driving tbody, #mission_vehicle_at_mission tbody").find("tr").each(function () { - var CalledVehicleID = parseInt($(this).find("a").first().attr("vehicle_type_id")); - if (CalledVehicleID == 52) { - CountGefangene -= 5; - } else if (CalledVehicleID == 32) { - CountGefangene -= 1; - } - }); - - if ($('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').size() > 0 && CountGefangene >= 5) { - $('#vehicle_show_table_all tr[vehicle_type="GefKw"] input[type="checkbox"]').each(function () { - if (CountGefangene > 0) { - $(this).click() - CountGefangene -= 5; - } - }); - } - if ($('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').size() > 0 && CountGefangene > 0) { - $('#vehicle_show_table_all tr[vehicle_type="FuStW"] input[type="checkbox"]').each(function () { - if (CountGefangene > 0) { - $(this).click() - CountGefangene -= 1; - } - }); - } - if ($('#vehicle_show_table_all input[type="checkbox"]:checked').size() > 0) { - $('#mission_alarm_btn').click(); - } - } - } - - // Gefängnis einlieferung - function ADis_Send_Vehicle_To_Jail() { - var JailHref = Jails[0].href - document.location.href = document.location.origin + JailHref; - } - } + /** + * / /=require ../script/mission.js + * / /=require ../script/sprechwunsch.js */ }); diff --git a/src/autoloaderV2.js b/src/autoloaderV2.js index 6108067..a8c9629 100644 --- a/src/autoloaderV2.js +++ b/src/autoloaderV2.js @@ -117,9 +117,9 @@ class AutomaticDispose { that.CollectPoliceSprechwuensche(); } - /* - //=require ../script/mission.js - //=require ../script/sprechwunsch.js + /** + * / /=require ../script/mission.js + * / /=require ../script/sprechwunsch.js */ });