Skip to content

Instantly share code, notes, and snippets.

@derhuerst
Created March 22, 2019 13:59
Show Gist options
  • Save derhuerst/7e0cc85569c1fea71c07d624a62aa21b to your computer and use it in GitHub Desktop.
Save derhuerst/7e0cc85569c1fea71c07d624a62aa21b to your computer and use it in GitHub Desktop.
strecken.info HAFAS JS code
Hafas.Texts.himPriorities = {
'2' : 'Ausfall'
,'8' : 'Teilausfall'
,'16' : 'Zurückhalten von Zügen'
,'23' : 'Umleitung'
,'24' : 'Totalsperrung'
,'25' : 'Streckenruhe'
,'37' : 'Fahren auf dem Gegengleis mit Zs 8 oder Befehl'
,'60' : 'Umleitung unter erleichterten Bedingungen'
,'63' : 'Fahrzeitverlängerung auf Regellaufweg'
,'65' : 'Fahren auf dem Gegengleis mit Zs 6'
,'70' : 'Sonstiges'
,'80' : 'Abweichung vom Fahrplan für Zugmeldestellen'
,'90' : 'Ohne Abweichung des Laufwegs'
};
function initHimFunctionality(map){
// var init dates
var coeff = 1000 * 60 * 30;
var fromDate = new Date();
fromDate.setSeconds(0);
fromDate.setMilliseconds(0);
fromDate = new Date(Math.round(fromDate.getTime() / coeff) * coeff)
// 2-Stndige Periode default
var toDate = new Date();
toDate.setHours(23);
toDate.setMinutes(59);
toDate.setSeconds(0);
toDate.setMilliseconds(0);
if(typeof Hafas.Modules.Him != 'undefined' && Hafas.Modules.Him.getState() == 'ready'){
var himCategories = [
{ value: '0', selected: true } ,   // Stg
{ value: '1', selected: true }    // Baumaahme
];
himCategories.push({ value: '2', selected: false }); // Streckenruhe
try{
himSearch = Hafas.Core.newType("hafasHim",{
map: map,
dateB: fromDate,
dateE: toDate,
priority: 100,
himCategories: himCategories,
durationFltr:0,
prodclass: 3
});
}catch(e){
console.log(e);
}
var switches = Hafas.Core.newType('hafasModule');
var templates = Hafas.Core.newType('hafasModule');
switches.hafasIntegration = '';
switches.useRealTime = '1';
switches.useReverseLookup = '';
switches.useGisRouting = '';
switches.disableAllFeatures = '';
switches.useHafasRingFunctionality = 'no';
switches.useTravelplanner = '';
switches.useStationboard = '';
switches.useTrainsearch = '';
switches.useTraininfo = '';
switches.useFeedback = '';
switches.usePrint2Web = '';
switches.useNavigationSlider = '';
switches.useApproxTimeInformation = '';
switches.useClientHAFAS = 'yes';
switches.useClientEUSPIRIT = 'no';
switches.RINGINFO_METHOD_HAFAS = 1;
switches.RINGINFO_METHOD_EUSPIRIT = 2;
switches.valueRingMethod = 5;
var suggest = Hafas.Core.newType('hafasModule');
suggest.minChar          = 4;
suggest.type             = 255;
suggest.delay            = 400;
suggest.requestType      = 'ajax';
suggest.detachable       = false;
suggest.mapViaButton     = true;
suggest.miniMap          = true;
suggest.highlighting     = true;
suggest.highlightType   = 'bold';
suggest.resultAmount     = 12;
suggest.showWeight       = true;
suggest.showLocType      = true;
suggest.filter           = false;
suggest.showProducts     = true;
suggest.category         = false;
suggest.houseNumber      = true;
suggest.furtherMatches   = true;
suggest.wrap             = false;
suggest.topFavorites     = true;
suggest.autoFillIn       = true;
suggest.appendElement    = '"main"';
config.loadHistory            = false;
config.virtualServer          = "hci";
config.tpJsonUrl               = "http://db-zugradar.hafas.de/bin/query.exe/dny?ld=std&seqnr=1&ident=cc.04251.1550946577&";
config.baseUrl                = "http://db-livemaps.hafas.de";
config.urlTravelPlanner       = "/bin/query.exe/dn?";
config.urlTravelPlannerJSON   = config.urlTravelPlanner.substr(0,config.urlTravelPlanner.length-1);
config.urlStationQuery        = "/bin/stboard.exe/dn?";
config.urlAjaxGetStop         = "/bin/ajax-getstop.exe/dn?";
config.urlTimetableBooklet    = "http://db-zugradar.hafas.de/bin/tb/query-p2w.exe/dn?whichTask=pf&";
config.urlTrainSearch         = "/bin/trainsearch.exe/dn?";
config.urlTrainInfo           = "/bin/traininfo.exe/dn/";
config.urlProfile             = "/bin/profile.exe/dn?";
config.urlEuSpirit            = "";
config.urlHelp                = "/bin/help.exe/dn?";
config.urlMgate               = "/bin/mgate.exe";
config.catenateSeqnr          = "seqnr=1&";
config.catenateIdent          = "ident=cc.04251.1550946577&";
config.catenateLayout         = "";
config.language               = "d";
config.browser                = "n";
config.queryPath              = "/bin/query.exe";
config.stboardPath           = "/bin/stboard.exe";
config.trainsearchPath       = "/bin/trainsearch.exe";
config.traininfoPath         = "/bin/traininfo.exe";
config.profilePath           = "/bin/profile.exe";
config.helpPath              = "/bin/help.exe";
config.urlPrefix              = "";
config.imagePath              = "/hafas-res/20120521121325/img/";
config.scriptPath             = "http://db-livemaps.hafas.de/hafas-res/20120521121325/js/";
config.cssPath                = "http://db-livemaps.hafas.de/hafas-res/20120521121325/css/";
config.jsMapImagePath         = "http://db-livemaps.hafas.de/hafas-res/20120521121325/img/js/";
config.dynamicTileParameterGoogle = 'proj=google&';
config.dynamicTileParameterPTV = 'proj=ptv&';
config.staticTileURL           = "/";
config.urlHaiti                = "http://demo.hafas.de/haiti-pub/wsgi-bin/haiti.wsgi?requrl=std40&";
config.cookiePrefix             = "dbZugradar"
config.cloudLoginUrl           = "http://db-livemaps.hafas.de/bin/help.exe/dny?tpl=cloud"
config.guiVersion = 'guiV=4.6.4&';
config.hciVersion             = '1.15';
config.hciExt                 = 'DBNETZZUGRADAR.2';
config.hciCfg                 = {"cfgGrpL":[],"cfgHash":"i74dckao7PmBwS0rbk0p"};
config.hciLang  = "deu";
config.cssLayoutPath           = 'http://db-livemaps.hafas.de/hafas-res/20120521121325/css/';
config.imageLayoutPath         = '/hafas-res/20120521121325/img/';
config.scriptLayoutPath        = 'http://db-livemaps.hafas.de/hafas-res/20120521121325/js/hci/';
config.jsDebug = 10;
config.useDebugTrafficLayer = false;
var products = [];
products.push({value:1,name:""});products.push({value:2,name:""});products.push({value:4,name:""});products.push({value:8,name:""});products.push({value:16,name:""});products.push({value:128,name:""});products.push({value:256,name:""});products.push({value:512,name:""});products.push({value:1024,name:""});config.productBitsArray = [];
config.productBitsArray.push(1);
config.productBitsArray.push(2);
config.productBitsArray.push(4);
config.productBitsArray.push(8);
config.productBitsArray.push(16);
config.productBitsArray.push();
config.productBitsArray.push(128);
config.productBitsArray.push(256);
config.productBitsArray.push(512);
config.livemap = {
lineColorMapping:{
A: "#D1302F",
B: "#427DBD",
C: "#FCD946",
D: "#5E9620",
E: "#BD76A1",
H: "#7B4339",
J: "#CDCD00",
K: "#C7B300",
L: "#7584BC",
N: "#00A092",
P: "#F0B600",
R: "#E4B4D1",
U: "#D60058"
},
livemapExCanvasRendering: true
,maxTrains: 1000
,showNames: true
,showDirection: false
,showRealtime: true
,useDataTiles: false
,showAgeOfReport: true
,overdueMessageTime: 5
,products:[
{
name: "",
minZoom: 2550000
}
,{
name: "",
minZoom: 2550000
}
,{
name: "",
minZoom: 2000000
}
,{
name: "",
minZoom: 400000
}
,{
name: "",
minZoom: 52500
}
,{
name: "",
minZoom: 52500
}
,{
name: "",
minZoom: 52500
}
,{
name: "",
minZoom: 2550000
}
,{
name: "",
minZoom: 2550000
}
]
};
config.hciIconReferences = {
"DB": "products2014/suggest/prod_db.png",
"WALK": "mobilityRadarProducts/b_walk.png",
"HIM14050":"/hafas-res/20120521121325/img/him/Baustelle/rot/01_Zurueckhalten_A_rot.png"
,"HIM04050":"/hafas-res/20120521121325/img/him/Baustelle/rot/01_Zurueckhalten_A_rot.png"
,"HIM02050":"/hafas-res/20120521121325/img/him/Baustelle/rot/01_Zurueckhalten_A_rot.png"
,"HIM00316":"/hafas-res/20120521121325/img/him/messages/him00316.png"
,"HIM01316":"/hafas-res/20120521121325/img/him/messages/him01316.png"
,"HIM10316":"/hafas-res/20120521121325/img/him/messages/him10316.png"
,"HIM11316":"/hafas-res/20120521121325/img/him/messages/him11316.png"
,"HIM00307":"/hafas-res/20120521121325/img/him/messages/him00307.png"
,"HIM01307":"/hafas-res/20120521121325/img/him/messages/him01307.png"
,"HIM10307":"/hafas-res/20120521121325/img/him/messages/him10307.png"
,"HIM11307":"/hafas-res/20120521121325/img/him/messages/him11307.png"
,"HIM00203":"/hafas-res/20120521121325/img/him/messages/him00203.png"
,"HIM01203":"/hafas-res/20120521121325/img/him/messages/him01203.png"
,"HIM10203":"/hafas-res/20120521121325/img/him/messages/him10203.png"
,"HIM11203":"/hafas-res/20120521121325/img/him/messages/him11203.png"
,"HIM00215":"/hafas-res/20120521121325/img/him/messages/him00215.png"
,"HIM01215":"/hafas-res/20120521121325/img/him/messages/him01215.png"
,"HIM10215":"/hafas-res/20120521121325/img/him/messages/him10215.png"
,"HIM11215":"/hafas-res/20120521121325/img/him/messages/him11215.png"
,"HIM00206":"/hafas-res/20120521121325/img/him/messages/him00206.png"
,"HIM01206":"/hafas-res/20120521121325/img/him/messages/him01206.png"
,"HIM10206":"/hafas-res/20120521121325/img/him/messages/him10206.png"
,"HIM11206":"/hafas-res/20120521121325/img/him/messages/him11206.png"
,"HIM00202":"/hafas-res/20120521121325/img/him/messages/him00202.png"
,"HIM01202":"/hafas-res/20120521121325/img/him/messages/him01202.png"
,"HIM10202":"/hafas-res/20120521121325/img/him/messages/him10202.png"
,"HIM11202":"/hafas-res/20120521121325/img/him/messages/him11202.png"
,"HIM00013":"/hafas-res/20120521121325/img/him/messages/him00013.png"
,"HIM01013":"/hafas-res/20120521121325/img/him/messages/him01013.png"
,"HIM10013":"/hafas-res/20120521121325/img/him/messages/him10013.png"
,"HIM11013":"/hafas-res/20120521121325/img/him/messages/him11013.png"
,"HIM00012":"/hafas-res/20120521121325/img/him/messages/him00012.png"
,"HIM01012":"/hafas-res/20120521121325/img/him/messages/him01012.png"
,"HIM10012":"/hafas-res/20120521121325/img/him/messages/him10012.png"
,"HIM11012":"/hafas-res/20120521121325/img/him/messages/him11012.png"
,"HIM00005":"/hafas-res/20120521121325/img/him/messages/him00005.png"
,"HIM01005":"/hafas-res/20120521121325/img/him/messages/him01005.png"
,"HIM10005":"/hafas-res/20120521121325/img/him/messages/him10005.png"
,"HIM11005":"/hafas-res/20120521121325/img/him/messages/him11005.png"
,"HIM00001":"/hafas-res/20120521121325/img/him/messages/him00001.png"
,"HIM01001":"/hafas-res/20120521121325/img/him/messages/him01001.png"
,"HIM10001":"/hafas-res/20120521121325/img/him/messages/him10001.png"
,"HIM11001":"/hafas-res/20120521121325/img/him/messages/him11001.png"
,"HIM00010":"/hafas-res/20120521121325/img/him/messages/him00010.png"
,"HIM01010":"/hafas-res/20120521121325/img/him/messages/him01010.png"
,"HIM10010":"/hafas-res/20120521121325/img/him/messages/him10010.png"
,"HIM11010":"/hafas-res/20120521121325/img/him/messages/him11010.png"
,"HIM00011":"/hafas-res/20120521121325/img/him/messages/him00011.png"
,"HIM01011":"/hafas-res/20120521121325/img/him/messages/him01011.png"
,"HIM10011":"/hafas-res/20120521121325/img/him/messages/him10011.png"
,"HIM11011":"/hafas-res/20120521121325/img/him/messages/him11011.png"
,"HIM00216":"/hafas-res/20120521121325/img/him/messages/him00216.png"
,"HIM01216":"/hafas-res/20120521121325/img/him/messages/him01216.png"
,"HIM10216":"/hafas-res/20120521121325/img/him/messages/him10216.png"
,"HIM11216":"/hafas-res/20120521121325/img/him/messages/him11216.png"
,"HIM00209":"/hafas-res/20120521121325/img/him/messages/him00209.png"
,"HIM01209":"/hafas-res/20120521121325/img/him/messages/him01209.png"
,"HIM10209":"/hafas-res/20120521121325/img/him/messages/him10209.png"
,"HIM11209":"/hafas-res/20120521121325/img/him/messages/him11209.png"
,"HIM00204":"/hafas-res/20120521121325/img/him/messages/him00204.png"
,"HIM01204":"/hafas-res/20120521121325/img/him/messages/him01204.png"
,"HIM10204":"/hafas-res/20120521121325/img/him/messages/him10204.png"
,"HIM11204":"/hafas-res/20120521121325/img/him/messages/him11204.png"
,"HIM00208":"/hafas-res/20120521121325/img/him/messages/him00208.png"
,"HIM01208":"/hafas-res/20120521121325/img/him/messages/him01208.png"
,"HIM10208":"/hafas-res/20120521121325/img/him/messages/him10208.png"
,"HIM11208":"/hafas-res/20120521121325/img/him/messages/him11208.png"
};
config.productImages[1] = '';
config.productImagesStop[1] = '';
config.productImagesHTML[1] = "";
config.productImagesTP[1] = "";
config.productColors[1] = "BD332D";
config.productImagesMap[1] = '';
config.productImages[2] = '';
config.productImagesStop[2] = '';
config.productImagesHTML[2] = "";
config.productImagesTP[2] = "";
config.productColors[2] = "126897";
config.productImagesMap[2] = '';
config.productImages[4] = '';
config.productImagesStop[4] = '';
config.productImagesHTML[4] = "";
config.productImagesTP[4] = "";
config.productColors[4] = "126897";
config.productImagesMap[4] = '';
config.productImages[8] = '';
config.productImagesStop[8] = '';
config.productImagesHTML[8] = "";
config.productImagesTP[8] = "";
config.productColors[8] = "200295";
config.productImagesMap[8] = '';
config.productImages[16] = '';
config.productImagesStop[16] = '';
config.productImagesHTML[16] = "";
config.productImagesTP[16] = "";
config.productColors[16] = "509D24";
config.productImagesMap[16] = '';
config.productImages[128] = '';
config.productImagesStop[128] = '';
config.productImagesHTML[128] = "";
config.productImagesTP[128] = "";
config.productColors[128] = "F9BC00";
config.productImagesMap[128] = '';
config.productImages[256] = '';
config.productImagesStop[256] = '';
config.productImagesHTML[256] = "";
config.productImagesTP[256] = "";
config.productColors[256] = "DF8023";
config.productImagesMap[256] = '';
config.productImages[512] = '';
config.productImagesStop[512] = '';
config.productImagesHTML[512] = "";
config.productImagesTP[512] = "";
config.productColors[512] = "8B5A00";
config.productImagesMap[512] = '';
config.productImages[1024] = '';
config.productImagesStop[1024] = '';
config.productImagesHTML[1024] = "";
config.productImagesTP[1024] = "";
config.productColors[1024] = "C4835A";
config.productImagesMap[1024] = '';
config.periodBegin = new Date(2019, 2 - 1, 19);
config.periodEnd = new Date(2019, 5 - 1, 13);
/* CSV Export */
var messagesArrayCSV = [];
var expertMode = false;
var curr_app_drag = null;
var showStopsInMap = false;
var currentStopsInMap = [];
/* Rendert Listen Ansicht , bereitet CSV Array vor*/
function renderHimTextView(renderData){
if(renderData == null) {
document.getElementById('himMessageList').innerHTML = '<div class="hfs_NoCategoryError">Es wurde keine Kategorie ausgew&auml;hlt.';
return;
}
var himMsgL = renderData.svcResL[0].res.msgRefL;
var common = renderData.svcResL[0].res.common;
messagesArrayCSV = [];
var html = '';
html += '<div>';
html += '<table style="width:100%" class="hfs_himListTable" cellspacing="0">';
if(typeof himMsgL != 'undefined' && himMsgL.length > 0 ){
document.getElementById('csvHimExport').style.visibility = 'visible';
for(var n=0; n < himMsgL.length;n++){
var himMsg = common.himL[himMsgL[n]];
var iconImg = common.icoL[himMsg.icoX];
var head = himMsg.head;
var text = himMsg.text;
var prio = himMsg.prio;
var periodHTMLOutput = '';
var infrastructure = '';
var comma = '';
var infraStructureArray = [];
var sectionNumsArray = [];
if(typeof himMsg.eventRefL != 'undefined') {
for(var k = 0 ; k < himMsg.eventRefL.length;k++) {
var event = common.himMsgEventL[himMsg.eventRefL[k]];
var sectionNums = event.sectionNums;
var sectionNumsString = '';
var sectionNumComma = '';
if(typeof sectionNums != 'undefined') {
for(var g=0; g < sectionNums.length;g++) {
sectionNumsString += sectionNumComma;
sectionNumsString += sectionNums[g];
sectionNumComma = ', ';
}
sectionNumsArray.push(sectionNumsString);
}
}
}else{
sectionNumsString = null;
}
var messageCategory = '';
var additionalInformation = {};
if(typeof himMsg.rRefL != 'undefined') {
for(var f=0; f < himMsg.rRefL.length;f++) {
var tmpRemark = common.remL[himMsg.rRefL[f]];
additionalInformation[tmpRemark.code] = tmpRemark;
}
}
if(typeof himMsg.edgeRefL != 'undefined') {
for(var u=0; u < himMsg.edgeRefL.length;u++) {
var edge = common.himMsgEdgeL[himMsg.edgeRefL[u]];
var currentInfraStructure = '';
infrastructure += comma;
var fromLoc = common.locL[edge.fLocX];
if(typeof edge.tLocX != 'undefined') {
var toLoc = common.locL[edge.tLocX];
}
if((typeof toLoc != 'undefined' && toLoc != null) && edge.fLocX != edge.tLocX) {
infrastructure += fromLoc.name + " - " + toLoc.name;
currentInfraStructure += fromLoc.name + " - " + toLoc.name;
}else{
infrastructure += fromLoc.name;
currentInfraStructure += fromLoc.name;
}
infraStructureArray.push(currentInfraStructure);
comma = ', ';
}
}
if(typeof himMsg.regionRefL != 'undefined') {
for(var u=0; u < himMsg.regionRefL.length;u++) {
var region = common.himMsgRegionL[himMsg.regionRefL[u]];
infrastructure += region.name;
}
}
var infrastructureHTML = '<div class="hfs_himText">' + infrastructure;
if(typeof sectionNumsString != 'undefined' && sectionNumsString != null && sectionNumsString.length > 0) {
infrastructureHTML += ' (' + sectionNumsString + ')'
}
infrastructureHTML += '</div>';
if(parseInt(himMsg.prio) == 1) {
infrastructureHTML += '<div class="hfs_himText">Sammelmeldung</div>';
}
var periodCheckBoxStyle = '';
if(document.getElementById('showPeriods').checked == false) {
periodCheckBoxStyle = 'style="display:none;"';
}
var periodStringTextMemory = {};
periodHTMLOutput += '<div class="hfs_himPeriodText" ' + periodCheckBoxStyle + ' data-him="period">';
if(typeof himMsg.eventRefL != 'undefined') {
for(var k = 0 ; k < himMsg.eventRefL.length;k++) {
var event = common.himMsgEventL[himMsg.eventRefL[k]];
var fromDateString = Hafas.Util.date.hciDate2string(event.fDate);
var toDateString = Hafas.Util.date.hciDate2string(event.tDate);
var fromTime = Hafas.Util.parseHCITime(event.fTime);
var toTime = Hafas.Util.parseHCITime(event.tTime);
var fromTimeString = Hafas.Util.date.pad(fromTime.hours) + ':' + Hafas.Util.date.pad(fromTime.minutes);
var toTimeString = Hafas.Util.date.pad(toTime.hours) + ':' + Hafas.Util.date.pad(toTime.minutes);
if(fromDateString != toDateString) {
var periodString = fromDateString + ' ' + fromTimeString + ' - ' + toDateString + ' ' + toTimeString;
}else{
var periodString = fromDateString + ' ' + fromTimeString + ' - ' + toTimeString;
}
if(typeof periodStringTextMemory[periodString] == 'undefined') {
periodHTMLOutput += '<div>' + periodString + '</div>';
}
periodStringTextMemory[periodString] = true;
for(var f=0; f < infraStructureArray.length;f++){
var csvPeriodFrom = fromDateString + ' ' + fromTimeString;
var csvPeriodTo = toDateString + ' ' + toTimeString;
var csvSectionNum = sectionNumsArray[k];
var csvLocation = infraStructureArray[f];
if(typeof csvSectionNum != 'undefined' && csvSectionNum.length > 0) {
csvLocation += ' (' + csvSectionNum + ')';
}
//var csvArbeiten = head + ' ' + text;
if(typeof additionalInformation['dbnetz_subcategory1stLevel'] != 'undefined'){
var csvArbeiten = additionalInformation['dbnetz_subcategory1stLevel'].txtN;
}else{
var csvArbeiten = '';
}
if(typeof additionalInformation['dbnetz_subcategory2ndLevel'] != 'undefined' && additionalInformation['dbnetz_subcategory2ndLevel'].txtN.length > 0) {
csvArbeiten += ', ' + additionalInformation['dbnetz_subcategory2ndLevel'].txtN;
}
if(typeof himMsg.text != 'undefined' && himMsg.text.length > 0 && parseInt(himMsg.cat) == 0) {
csvArbeiten += ', ' + himMsg.text;
}
if(typeof additionalInformation['dbnetz_effect'] != 'undefined'){
var csvWirkung = additionalInformation['dbnetz_effect'].txtN;
if(typeof additionalInformation['dbnetz_additionalEffects'] != 'undefined' && additionalInformation['dbnetz_additionalEffects'].txtN.length > 0) {
csvWirkung += ' (' + additionalInformation['dbnetz_additionalEffects'].txtN + ')';
}
}else{
var csvWirkung = '';
}
if(typeof additionalInformation['externalId'] != 'undefined') {
var csvBaustellenID = additionalInformation['externalId'].txtN;
}else{
var csvBaustellenID = '';
}
var csvEntry = [ csvLocation, csvBaustellenID, csvArbeiten, csvPeriodFrom ,csvPeriodTo, csvWirkung];
messagesArrayCSV.push(csvEntry);
}
}
}
if(himMsg.prio == 1) {
if(typeof additionalInformation['dbnetz_effect'] == 'undefined') {
var additionalInfoEffect = '';
}else{
var additionalInfoEffect = additionalInformation['dbnetz_effect'].txtN;
}
var csvGlobalEntry = [ "Sammelmeldung", additionalInformation['dbnetz_subcategory1stLevel'].txtN, "" ,"", additionalInfoEffect];
messagesArrayCSV.push(csvGlobalEntry);
}
if(typeof himMsg.regionRefL != 'undefined' && himMsg.regionRefL.length > 0) {
for(var r=0; r < himMsg.regionRefL.length;r++) {
var region = common.himMsgRegionL[himMsg.regionRefL[r]];
for(var rm=0; rm < region.msgRefL.length;rm++) {
var regionMessage = common.himL[region.msgRefL[rm]];
for(var y = 0 ; y < regionMessage.eventRefL.length;y++) {
var eventRegion = common.himMsgEventL[regionMessage.eventRefL[y]];
var fromDateString = Hafas.Util.date.hciDate2string(eventRegion.fDate);
var toDateString = Hafas.Util.date.hciDate2string(eventRegion.tDate);
var fromTime = Hafas.Util.parseHCITime(eventRegion.fTime);
var toTime = Hafas.Util.parseHCITime(eventRegion.tTime);
var fromTimeString = Hafas.Util.date.pad(fromTime.hours) + ':' + Hafas.Util.date.pad(fromTime.minutes);
var toTimeString = Hafas.Util.date.pad(toTime.hours) + ':' + Hafas.Util.date.pad(toTime.minutes);
var csvPeriodFrom = fromDateString + ' ' + fromTimeString;
var csvPeriodTo = toDateString + ' ' + toTimeString;
var regionAdditionalInfo = {};
for(var s=0; s < regionMessage.rRefL.length;s++) {
regionAdditionalInfo[common.remL[regionMessage.rRefL[s]].code] = common.remL[regionMessage.rRefL[s]];
}
var csvWorks = additionalInformation['dbnetz_subcategory1stLevel'].txtN;
if(typeof additionalInformation['dbnetz_subcategory2ndLevel'] != 'undefined') {
csvWorks += ', ' + additionalInformation['dbnetz_subcategory2ndLevel'].txtN;
}
if(typeof himMsg.text != 'undefined' && parseInt(himMsg.cat) == 0) {
csvWorks += ', ' + himMsg.text;
}
if(typeof additionalInformation['dbnetz_effect'] != 'undefined') {
var addInfoEffect = additionalInformation['dbnetz_effect'].txtN;
}else{
var addInfoEffect = '';
}
var csvRegionEntry = [ region.name, csvWorks , csvPeriodFrom ,csvPeriodTo, addInfoEffect];
messagesArrayCSV.push(csvRegionEntry);
}
}
//console.dir(region);
}
}
periodHTMLOutput += '</div>';
if(typeof Hafas.Config.hciIconReferences[iconImg.res] != 'undefined'){
var iconUrl = Hafas.Config.hciIconReferences[iconImg.res];
}else{
var iconUrl = Hafas.Config.imagePath + 'him/him_icon_gross.png';
}
html += '<tr>';
html += '<td class="himIcon"><img height="30" src="' + iconUrl + '"/></td>';
html += '<td class="himMessage">';
if(typeof additionalInformation['dbnetz_effect'] != 'undefined'){
html += '<div class="hfs_himHeadline">' + additionalInformation['dbnetz_effect'].txtN;
if(typeof additionalInformation['dbnetz_additionalEffects'] != 'undefined' && additionalInformation['dbnetz_additionalEffects'].txtN.length > 0){
html += ' (' + additionalInformation['dbnetz_additionalEffects'].txtN + ')';
}
html += '</div>';
}
html += infrastructureHTML;
html += periodHTMLOutput;
/*html += '<div class="hfs_himMsgText">' + head + '</div>';
html += '<div class="hfs_himMsgText">' + text + '</div>';*/
if(typeof additionalInformation['dbnetz_subcategory1stLevel'] != 'undefined'){
html += '<div class="hfs_himMsgText">' + additionalInformation['dbnetz_subcategory1stLevel'].txtN + '</div>';
}
if(typeof additionalInformation['dbnetz_subcategory2ndLevel'] != 'undefined') {
html += '<div class="hfs_himText">' + additionalInformation['dbnetz_subcategory2ndLevel'].txtN + '</div>';
}
if(typeof himMsg.text != 'undefined' && parseInt(himMsg.cat) == 0) {
html += '<div class="hfs_himText">' + himMsg.text + '</div>';
}
html += '</td>';
html += '</tr>';
if(typeof Hafas.Config.hciIconReferences[iconImg.res] == 'undefined'){
console.log("Icon not configured: " + iconImg.res);
}
}
}else{
html += '<tr>';
html += '<td class="hfs_noMessages">' + Hafas.Texts.baustellen.noMessages + '</td>';
html += '</tr>';
document.getElementById('csvHimExport').style.visibility = 'hidden';
}
html += '</table>';
html += '</div>';
document.getElementById('himMessageList').innerHTML = html;
}
function togglePeriods(boolval){
Hafas('[data-him="period"]',true).forEach(function(elem){
if(boolval) {
elem.style.display = '';
}else{
elem.style.display = 'none';
}
});
}
function chooseExpertNow(){
Hafas.ps.pub('/himSearch/chooseNow');
Hafas.ps.pub('/himSearch/toggleSelectionMode',['expert']);
}
function updatePrioFilterSettings(){
var zoom = himSearch.getMap().getZoom("api");
if(zoom <= 7 ) {
var maxSliderVal = 0;
}else if(zoom <= 8){
var maxSliderVal = 1;
}else{
var maxSliderVal = 3;
}
if(typeof useZoomLevelDependentPriority != 'undefined' && useZoomLevelDependentPriority == false) {
maxSliderVal = 3;
}
var prioSlider = Hafas.Modules.Slider.getInstance("himPrioSlider");
var currentSliderValue = prioSlider.getValue();
var newValue = Math.min(maxSliderVal,currentSliderValue);
if(newValue != currentSliderValue) {
prioSlider.setValue(newValue);
}
prioSlider.setMax(maxSliderVal);
//prioSlider.max = maxSliderVal;
}
function exportCSV(head,data){
var csvExportData = [];
csvExportData.push(head);
csvExportData = csvExportData.concat(data);
var csvContent ="";
csvExportData.forEach(function(infoArray, index){
dataString = infoArray.join(";");
csvContent += dataString+ "\n";
});
var encodedUri = encodeURI(csvContent);
var currentDate = new Date();
var fileName = "BaustellenCSVExport - " + currentDate.getFullYear() + "_" + (currentDate.getMonth() + 1) + "_" +
currentDate.getDate() + "_" + currentDate.getHours() + "_" +
currentDate.getMinutes() + "_" + currentDate.getSeconds() + ".csv";
Hafas.Util.downloadAsFile(csvContent,fileName);
}
function updateExpertDate(date,type){
// Update expert date
expertMode = true;
var update = false;
if(expertMode){
console.log("date.selectedDate.getTime(): ", date.selectedDate.getTime(), himSearch.getPeriodFltr('dateB').getTime());
//if(type == 'From' && date.selectedDate.getTime() != himSearch.getPeriodFltr('dateB').getTime()) {
if(type == 'From' && (date.selectedDate.getDate() != himSearch.getPeriodFltr('dateB').getDate())
|| date.selectedDate.getMonth() != himSearch.getPeriodFltr('dateB').getMonth()
|| date.selectedDate.getFullYear() != himSearch.getPeriodFltr('dateB').getFullYear()) {
update = true;
var currentDateB = date.selectedDate;
var newDateB = new Date(Hafas.Modules.Calendar.getCalendarInstanceById('hfsHimDateInput_From').selectedDate.getTime());
var previousDate = new Date(himSearch.getPeriodFltr('dateB').getTime());
//newDateB.setHours(currentDateB.getHours());
newDateB.setHours(previousDate.getHours());
//newDateB.setMinutes(currentDateB.getMinutes());
newDateB.setMinutes(previousDate.getMinutes());
newDateB.setSeconds(currentDateB.getSeconds());
newDateB.setMilliseconds(currentDateB.getMilliseconds());
himSearch.setPeriodFltr('dateB',newDateB);
var dayExpertB = himSearch.period.dateB.getDate();
var monthExpertB = himSearch.period.dateB.getMonth()+1;
var yearExpertB = himSearch.period.dateB.getFullYear();
var dateExpertB = Hafas.Util.date.pad(dayExpertB) + '.' + Hafas.Util.date.pad(monthExpertB) + '.' + yearExpertB.toString().substr(2,2);
Hafas('#hfsHimDateInput_From').value = dateExpertB;
}/*else if(type == 'To' && date.selectedDate.getTime() != himSearch.getPeriodFltr('dateE').getTime()){*/
else if(type == 'To' &&
(date.selectedDate.getDate() != himSearch.getPeriodFltr('dateE').getDate()) ||
(date.selectedDate.getMonth() != himSearch.getPeriodFltr('dateE').getMonth()) ||
(date.selectedDate.getFullYear() != himSearch.getPeriodFltr('dateE').getFullYear()) ){
update = true;
var currentDateE = himSearch.getPeriodFltr('dateE');
var newDateE = new Date(Hafas.Modules.Calendar.getCalendarInstanceById('hfsHimDateInput_To').selectedDate.getTime());
var previousDate = new Date(himSearch.getPeriodFltr('dateE').getTime());
//newDateE.setHours(currentDateE.getHours());
newDateE.setHours(previousDate.getHours());
//newDateE.setMinutes(currentDateE.getMinutes());
newDateE.setMinutes(previousDate.getMinutes());
newDateE.setSeconds(currentDateE.getSeconds());
newDateE.setMilliseconds(currentDateE.getMilliseconds());
himSearch.setPeriodFltr('dateE',newDateE);
var dayExpertE = himSearch.period.dateE.getDate();
var monthExpertE = himSearch.period.dateE.getMonth()+1;
var yearExpertE = himSearch.period.dateE.getFullYear();
var dateExpertE = Hafas.Util.date.pad(dayExpertE) + '.' + Hafas.Util.date.pad(monthExpertE) + '.' + yearExpertE.toString().substr(2,2);
Hafas('#hfsHimDateInput_To').value = dateExpertE;
}
/*himSearch.setPeriodFltr('dateB',Hafas.Modules.Calendar.getCalendarInstanceById('hfsHimDateInput_From').selectedDate);
himSearch.setPeriodFltr('dateE',Hafas.Modules.Calendar.getCalendarInstanceById('hfsHimDateInput_To').selectedDate);*/
if(update) {
himSearch.getHimMessagesByBoundingBox();
}
}
}
function roundToNearestMin(dateTime,minDef){
var remainder = minDef - (start.minute()+ start.second()/60) % minDef ;
remainder = (remainder > minDef/2) ? remainder = -minDef + remainder : remainder;
const changedDate = moment(start).add(remainder, "minutes" ).seconds(0).format("DD.MM.YYYY HH:mm:ss");
}
function updateExperTimeFilter(elem,time){
if(elem.id == 'himTimeInputB'){
var currentPeriodB = himSearch.getPeriodFltr('dateB');
var currentPeriodE = himSearch.getPeriodFltr('dateE');
var timeObj = Hafas.Util.parseHCITime(time);
currentPeriodB.setHours(timeObj.hours);
currentPeriodB.setMinutes(timeObj.minutes);
currentPeriodB.setSeconds(timeObj.seconds);
himSearch.setPeriodFltr('dateB', currentPeriodB);
/*if(currentPeriodB.getTime() > currentPeriodE.getTime()) {
}*/
}else if(elem.id == 'himTimeInputE'){
var currentPeriodB = himSearch.getPeriodFltr('dateB');
var currentPeriodE = himSearch.getPeriodFltr('dateE');
var timeObj = Hafas.Util.parseHCITime(time);
currentPeriodE.setHours(timeObj.hours);
currentPeriodE.setMinutes(timeObj.minutes);
currentPeriodE.setSeconds(timeObj.seconds);
himSearch.setPeriodFltr('dateE', currentPeriodE);
}
himSearch.getHimMessagesByBoundingBox();
}
function zerofiyDate(jsDate){
jsDate.setHours(0);
jsDate.setMinutes(0);
jsDate.setSeconds(0);
jsDate.setMilliseconds(0);
return jsDate;
}
function toggleSelectionMode(mode){
if(mode == 'expert'){
expertMode = true;
Hafas('#quickSelMode').style.display = 'none';
Hafas('#expertMode').style.display = '';
// aktuelle Datums/Zeiteinstellungen aus HIM-Suche übernehmen
var currentSelectedDateBegin = new Date(himSearch.period.dateB.getTime());
currentSelectedDateBegin = zerofiyDate(currentSelectedDateBegin);
var currentSelectedDateEnd = new Date(himSearch.period.dateE.getTime());
currentSelectedDateEnd = zerofiyDate(currentSelectedDateEnd);
var hoursBeginExpert = himSearch.period.dateB.getHours();
var minutesBeginExpert = himSearch.period.dateB.getMinutes();
var dayExpertB = himSearch.period.dateB.getDate();
var monthExpertB = himSearch.period.dateB.getMonth()+1;
var yearExpertB = himSearch.period.dateB.getFullYear();
var dateExpertB = Hafas.Util.date.pad(dayExpertB) + '.' + Hafas.Util.date.pad(monthExpertB) + '.' + yearExpertB.toString().substr(2,2);
var hoursEndExpert = himSearch.period.dateE.getHours();
var minutesEndExpert = himSearch.period.dateE.getMinutes();
var dayExpertE = himSearch.period.dateE.getDate();
var monthExpertE = himSearch.period.dateE.getMonth()+1;
var yearExpertE = himSearch.period.dateE.getFullYear();
var dateExpertE = Hafas.Util.date.pad(dayExpertE) + '.' + Hafas.Util.date.pad(monthExpertE) + '.' + yearExpertE.toString().substr(2,2);
Hafas('#himTimeInputB').value = hoursBeginExpert + ':' + Hafas.Util.date.pad(minutesBeginExpert);
Hafas('#himTimeInputE').value = hoursEndExpert + ':' + Hafas.Util.date.pad(minutesEndExpert);
Hafas('#hfsHimDateInput_From').value = dateExpertB;
Hafas('#hfsHimDateInput_To').value = dateExpertE;
}else if(mode == 'quickSel'){
expertMode = false;
Hafas('#quickSelMode').style.display = '';
Hafas('#expertMode').style.display = 'none';
Hafas.ps.pub('/himSearch/chooseNow');
}
}
function showListLoader(){
Hafas('#himMessageList').innerHTML = '<div class="hfs_listLoader"><img src="' + Hafas.Config.imagePath + 'livemap/ajax_loader_greybackground.gif"/></div>';
}
function drag_app(evt){
if(!evt)
evt = event;
if(curr_app_drag == null)
return;
var curr_x = Event.pointerX(evt);
var curr_y = Event.pointerY(evt);
var shift_x = curr_x - curr_app_drag.click_x;
var shift_y = curr_y - curr_app_drag.click_y;
var new_x = (curr_app_drag.start_x + shift_x);
var new_y = (curr_app_drag.start_y + shift_y);
curr_app_drag.app.style.left = new_x + 'px';
curr_app_drag.app.style.top = new_y + 'px';
curr_app_drag.cur_x = new_x;
curr_app_drag.cur_y = new_y;
if(document.selection && document.selection.removeAllRanges)
document.selection.removeAllRanges();
if(window.getSelection && window.getSelection().removeAllRanges)
window.getSelection().removeAllRanges();
}
function start_drag(evt, appname){
if(!evt){
evt = event;
}
var screen = document.getElementById('screenDiv');
curr_app_drag = {};
curr_app_drag.app = document.getElementById('app_'+appname+'_div');
screen.onmousemove = drag_app;
screen.onmouseup = stop_drag;
curr_app_drag.click_x = Event.pointerX(evt);
curr_app_drag.click_y = Event.pointerY(evt);
curr_app_drag.start_x = curr_app_drag.app.offsetLeft;
curr_app_drag.start_y = curr_app_drag.app.offsetTop;
curr_app_drag.cur_x = curr_app_drag.start_x;
curr_app_drag.cur_y = curr_app_drag.start_y;
curr_app_drag.appname = appname;
}
function stop_drag(event){
var expireDate = new Date();
var expire = expireDate.getTime() + (365 * 24 * 60 * 60 * 1000);
expireDate.setTime(expire);
setCookie(curr_app_drag.appname+'_data', curr_app_drag.cur_x+"#"+curr_app_drag.cur_y,expireDate);
curr_drag_app = null;
var screen = document.getElementById('screenDiv');
screen.onmousemove = function() {};
screen.onmouseup = function() {};
}
function toogle_app_content(appname){
close_all_apps();
var content = document.getElementById('app_'+appname+'_content');
if(content.style.display == 'none'){
content.style.display = 'block';
}else{
content.style.display = 'none';
}
}
function hide_app_content(appname){
var content = document.getElementById('app_'+appname+'_content');
content.style.display = 'none';
var hideButton = document.getElementById('app_'+appname+'_hide');
hideButton.style.display = 'none';
var showButton = document.getElementById('app_'+appname+'_show');
showButton.style.display = 'block';
}
function minimize_app_content(appname){
document.getElementById("app_"+appname+"_div").style.display = 'none';
document.getElementById("appMinifiedIcon_"+appname).style.display = 'block';
Livemap_map.minimized = true;
}
function maximize_app_content(appname){
document.getElementById("app_"+appname+"_div").style.display = 'block';
document.getElementById("appMinifiedIcon_"+appname).style.display = 'none';
Livemap_map.minimized = false;
}
function close_all_apps(){
for(var i=0; i < registeredApps.length; i++){
document.getElementById(registeredApps[i] + '_content').style.display = 'none';
document.getElementById(registeredApps[i]+'_hide').style.display = 'none';
document.getElementById(registeredApps[i]+'_show').style.display = 'block';
}
}
function show_app_content(appname){
var content = document.getElementById('app_'+appname+'_content');
content.style.display = 'block';
var hideButton = document.getElementById('app_'+appname+'_hide');
hideButton.style.display = 'block';
var showButton = document.getElementById('app_'+appname+'_show');
showButton.style.display = 'none';
}
function add_app(appname){
var app = document.getElementById('app_'+appname+'_div');
eval('var add_func = add_'+appname+'_app');
if(typeof add_func == "function")
add_func();
}
function remove_app(appname){
var app = document.getElementById('app_'+appname+'_div');
app.style.display = "none";
eval('var close_func = close_'+appname+'_app');
if(typeof close_func == "function")
close_func();
}
function moveAppToCustomerPosition(appname){
var value = getCookie(appname+'_data');
if(value == null)
return;
var app = document.getElementById('app_'+appname+'_div');
var x_y = value.split('#');
app.style.left = x_y[0] + 'px';
app.style.top = x_y[1] + 'px';
}
function set_app_opacity(appname, isOpacity){
var app = document.getElementById('app_'+appname+'_div');
if(isOpacity)
app.style.opacity = 0.8;
else
app.style.opacity = 1;
}
function showTooltip(id){
Hafas('[data-tooltip="' + id + '"]',true).forEach(function(elem){
elem.style.display = 'block';
elem.style.top = (-elem.clientHeight - 10) + "px";
});
}
function hideTooltip(id){
Hafas('[data-tooltip="' + id + '"]',true).forEach(function(elem){
elem.style.display = 'none';
});
}
function updateStops(){
var map = Hafas.Modules.Maps.getMapById('embeddedLivemap');
if(map.getZoom("api") >= 10) {
document.getElementById('showstopsmap').disabled = false;
if(showStopsInMap){
requestStops();
}else{
hideStops();
}
}else{
document.getElementById('showstopsmap').disabled = true;
hideStops();
}
}
function requestStops(){
var map = Hafas.Modules.Maps.getMapById('embeddedLivemap');
var bb = map.getBoundingBox();
var ll = {
x : bb.sw.getLon(),
y : bb.sw.getLat()
};
var ur = {
x : bb.ne.getLon(),
y : bb.ne.getLat()
};
Hafas.ps.pub("/app/onbeforeloadstops",[this]);
var reqParams = {
request : "LocGeoPos",
requestType: "hci",
requestobj: {
rect: {
llCrd : ll,
urCrd : ur
}
},
callback : Hafas.bind(function(data){
if(typeof data.svcResL != 'undefined' && data.svcResL.length > 0 && data.svcResL[0].err == "OK" ) {
var result = data.svcResL[0].res;
Hafas.ps.pub("/app/stopsLoaded",[this]);
hideStops();
drawStops(result,map);
}
},this)
};
reqParams.cfg = Hafas.Config.hciCfg;
Hafas.Core.newType("hafasRequest", reqParams);
}
function hideStops(){
var map = Hafas.Modules.Maps.getMapById('embeddedLivemap');
for(var s=0; s < currentStopsInMap.length;s++) {
map.hideContent(currentStopsInMap[s]);
map.removeContent(currentStopsInMap[s]);
}
currentStopsInMap = [];
}
function drawStops(result,map){
currentStopsInMap
var locL = result.locL;
var common = result.common;
for(var s=0; s < locL.length;s++) {
var tmpLoc = locL[s];
var locIcoResolved = common.icoL[tmpLoc.icoX];
var tmpMapLoc = map.createContent({
type: 'location',
coord: Hafas.Util.geo.hciCrdToHafasCoord(tmpLoc.crd),
imageurl: Hafas.Config.imagePath + 'icons/haf_map_halt.png',
imageheight: 20,
imagewidth: 20,
hotspot: {x:10,y:10},
text: tmpLoc.name,
infotitle: tmpLoc.name,
infocontent: tmpLoc.name
});
map.showContent(tmpMapLoc);
currentStopsInMap.push(tmpMapLoc);
}
}
function enableStopsInMap(boolval){
showStopsInMap = boolval;
if(!boolval) {
hideStops();
}else{
requestStops();
}
}
function renderStopDetails(data){
var html = "";
var lastProduct = "";
var progTypeChange = -1;
for(var k=data.stopL.length-1; k > 0;k--) {
if(progTypeChange == -1){
if((data.stopL[k].dProgType == "REPORTED") || (data.stopL[k].aProgType == "REPORTED")) {
progTypeChange = k;
}
}
}
var journeyHasNotStarted = false;
// journey is about to start
if(data.stopIndexRT == -1) {
data.stopIndexRT = 0;
journeyHasNotStarted = true;
}
for(var j=0; j < data.stopL.length;j++) {
/* skip stops if needed */
if((data.showall == false) && (j != 0) && (j != (data.stopL.length-1) && (j != data.stopIndexRT) && (j != (data.stopIndexRT+1)) )) {
continue;
}
var trainrouteRowIdx = ((j % 2) + 1);
var loc = data.locL[data.stopL[j].locX];
if((typeof data.prodL[data.stopL[j].dProdX] != "undefined") && (data.prodL[data.stopL[j].dProdX].name != lastProduct)) {
var productName = data.prodL[data.stopL[j].dProdX].name;
lastProduct = productName;
}else{
var productName = "&nbsp;";
}
var currentRenderer = data.renderer || "trainroute_stop";
var stopRenderHTML = Hafas.Modules.Renderer.getRendererString({module:"Livemap",renderer:currentRenderer});
stopRenderHTML = stopRenderHTML.replace(/{locIdx}/g, data.stopL[j].locX);
stopRenderHTML = stopRenderHTML.replace(/{trainrouteStopName}/g,loc.name);
stopRenderHTML = stopRenderHTML.replace(/{trainrouteRowIdx}/g,trainrouteRowIdx);
stopRenderHTML = stopRenderHTML.replace(/{trainrouteProduct}/g, productName);
stopRenderHTML = stopRenderHTML.replace(/{trainroutePushBtn}/g, "<td></td>");
if(j >= progTypeChange){
stopRenderHTML = stopRenderHTML.replace(/{prognosisCSSdep}/g, "prognosis");
stopRenderHTML = stopRenderHTML.replace(/{prognosisCSSarr}/g, "prognosis");
}else{
/*stopRenderHTML = stopRenderHTML.replace(/{prognosisCSSdep}/g, "");
stopRenderHTML = stopRenderHTML.replace(/{prognosisCSSarr}/g, "");*/
stopRenderHTML = stopRenderHTML.replace(/{prognosisCSSdep}/g, "prognosis");
stopRenderHTML = stopRenderHTML.replace(/{prognosisCSSarr}/g, "prognosis");
}
if((data.stopL[j].aOutS) == true && (data.stopL[j].dInS == true)) {
stopRenderHTML = stopRenderHTML.replace(/{trainrouteHighlightCSS}/g, "highlight");
}else{
stopRenderHTML = stopRenderHTML.replace(/{trainrouteHighlightCSS}/g, "");
}
if(data.showall) {
if(j == 0) {
var coverUp = Hafas.Modules.Renderer.getRendererString({module:"Livemap",renderer:"coverup_start"});
coverUp = coverUp.replace(/{locIdx}/g, data.stopL[j].locX);
var pearlImage = Hafas.Config.baseUrl + Hafas.Config.imagePath + 'pearl_start.gif';
stopRenderHTML = stopRenderHTML.replace(/{trainrouteCoverUp}/g, coverUp);
}else if(j == data.stopL.length-1){
var coverUp = Hafas.Modules.Renderer.getRendererString({module:"Livemap",renderer:"coverup_end"});
coverUp = coverUp.replace(/{locIdx}/g, data.stopL[j].locX);
var pearlImage = Hafas.Config.baseUrl + Hafas.Config.imagePath + 'pearl_end_'+trainrouteRowIdx+'.gif';
stopRenderHTML = stopRenderHTML.replace(/{trainrouteCoverUp}/g, coverUp);
}else{
if((data.stopL[j].aOutS) == true && (data.stopL[j].dInS == true)) {
var pearlImage = Hafas.Config.baseUrl + Hafas.Config.imagePath + 'pearl_middle_highlight.gif';
}else{
var pearlImage = Hafas.Config.baseUrl + Hafas.Config.imagePath + 'pearl_middle_'+trainrouteRowIdx+'.gif';
}
stopRenderHTML = stopRenderHTML.replace(/{trainrouteCoverUp}/g, '');
}
}else{
if(j == 0) {
var pearlImage = Hafas.Config.baseUrl + Hafas.Config.imagePath + 'ori_RouteStart.png';
}else if(j == data.stopL.length-1){
var pearlImage = Hafas.Config.baseUrl + Hafas.Config.imagePath + 'ori_RouteEnd.png';
}else{
var pearlImage = Hafas.Config.baseUrl + Hafas.Config.imagePath + 'RouteStop.png';
}
}
stopRenderHTML = stopRenderHTML.replace(/{trainRoutePearlImage}/g, pearlImage);
/*if((typeof this.trainContainer[data.journey.jid] != "undefined") && ((typeof this.trainContainer[data.journey.jid].isRepLate == "undefined") || (this.trainContainer[data.journey.jid].isRepLate == false))) {*/
if(j == data.stopIndexRT) {
if(journeyHasNotStarted) {
stopRenderHTML = stopRenderHTML.replace(/{trainRouteStopExtraClass}/g, "separatorLinePopupTop");
}else{
stopRenderHTML = stopRenderHTML.replace(/{trainRouteStopExtraClass}/g, "separatorLinePopup");
}
}else{
stopRenderHTML = stopRenderHTML.replace(/{trainRouteStopExtraClass}/g, "");
}
/*}else{
if(j == progTypeChange) {
stopRenderHTML = stopRenderHTML.replace(/{trainRouteStopExtraClass}/g, "separatorLinePopupProgChange");
}else{
stopRenderHTML = stopRenderHTML.replace(/{trainRouteStopExtraClass}/g, "");
}
}*/
if((data.stopL[j].aOutS == false) || (typeof data.stopL[j].aTimeS == "undefined")) {
var aScheduled = "&nbsp;";
}else{
var aScheduled = Hafas.Util.date.jsDate2timeString(Hafas.Util.date.hciDate2jsDate(data.date,data.stopL[j].aTimeS));
}
stopRenderHTML = stopRenderHTML.replace(/{trainrouteStopArrScheduled}/g,aScheduled);
if(typeof data.stopL[j].aTimeR != "undefined"){
var aRealtime = Hafas.Util.getHciTimeDiff(data.stopL[j].aTimeR,data.stopL[j].aTimeS);
var aRealtimeAbsolute = Hafas.Util.date.jsDate2timeString(Hafas.Util.date.hciDate2jsDate(data.date,data.stopL[j].aTimeR))
if(aRealtime <= 0) {
aRealtimeAbsolute = '<span class="ontime">' + aRealtimeAbsolute + '</span>';
}else{
aRealtimeAbsolute = '<span class="prognosis">' + aRealtimeAbsolute + '</span>';
}
stopRenderHTML = stopRenderHTML.replace(/{trainrouteStopArrRealtime}/g,aRealtimeAbsolute);
if(aRealtime <= 0) {
stopRenderHTML = stopRenderHTML.replace(/{trainrouteArrRT_CSS}/g,"lc_ontime");
}else if(aRealtime > 0){
aRealtime = "+" + aRealtime;
stopRenderHTML = stopRenderHTML.replace(/{trainrouteArrRT_CSS}/g,"lc_delayed");
}
}else{
//var aRealtime = aScheduled;
var aRealtime = "-";
stopRenderHTML = stopRenderHTML.replace(/{trainrouteArrRT_CSS}/g,"lc_blank");
stopRenderHTML = stopRenderHTML.replace(/{trainrouteStopArrRealtime}/g,"");
}
if(aRealtime <= 0) {
aRealtime = '<span class="ontime">' + aRealtime + '</span>';
}
stopRenderHTML = stopRenderHTML.replace(/{trainrouteStopArrRT}/g,aRealtime);
if((data.stopL[j].dOutS == false) || (typeof data.stopL[j].dTimeS == "undefined") ) {
var dScheduled = "&nbsp;";
}else{
var dScheduled = Hafas.Util.date.jsDate2timeString(Hafas.Util.date.hciDate2jsDate(data.date,data.stopL[j].dTimeS));
}
stopRenderHTML = stopRenderHTML.replace(/{trainrouteStopDepScheduled}/g,dScheduled);
if(typeof data.stopL[j].dTimeR != "undefined"){
var dRealtime = Hafas.Util.getHciTimeDiff(data.stopL[j].dTimeR,data.stopL[j].dTimeS);
var dRealtimeAbsolute = Hafas.Util.date.jsDate2timeString(Hafas.Util.date.hciDate2jsDate(data.date,data.stopL[j].dTimeR))
if(dRealtime <= 0) {
dRealtimeAbsolute = '<span class="ontime">' + dRealtimeAbsolute + '</span>';
}else{
dRealtimeAbsolute = '<span class="prognosis">' + dRealtimeAbsolute + '</span>';
}
stopRenderHTML = stopRenderHTML.replace(/{trainrouteStopDepRealtime}/g,dRealtimeAbsolute);
if(dRealtime <= 0) {
stopRenderHTML = stopRenderHTML.replace(/{trainrouteDepRT_CSS}/g,"lc_ontime");
}else if(dRealtime > 0){
dRealtime = "+" + dRealtime;
stopRenderHTML = stopRenderHTML.replace(/{trainrouteDepRT_CSS}/g,"lc_delayed");
}
}else{
//var dRealtime = dScheduled;
var dRealtime = "-";
stopRenderHTML = stopRenderHTML.replace(/{trainrouteDepRT_CSS}/g,"lc_blank");
stopRenderHTML = stopRenderHTML.replace(/{trainrouteStopDepRealtime}/g,"");
}
if(dRealtime <= 0) {
dRealtime = '<span class="ontime">' + dRealtime + '</span>';
}
stopRenderHTML = stopRenderHTML.replace(/{trainrouteStopDepRT}/g,dRealtime);
html+= stopRenderHTML;
}
return html;
}
function resolveHimMsgFromUrl(himId){
console.log("resolveHimMsgFromUrl: ", himId);
console.log(himSearch);
var himMsgCrds = [];
himSearch.getHimMessages([himId],function(data){
console.log("himDetailsData: ", data);
if(data.svcResL.length > 0) {
if(data.svcResL[0].err == 'OK') {
var result = data.svcResL[0].res;
var common = result.common;
for(var r = 0; r < result.msgRefL.length;r++) {
var tmpMsgRef = result.msgRefL[r];
var message = common.himL[tmpMsgRef];
if(typeof message.edgeRefL != 'undefined') {
for(var m=0; m < message.edgeRefL.length;m++) {
var edge = common.himMsgEdgeL[m];
var crd = Hafas.Core.newType("hafasCCoord",{lon: edge.icoCrd.x, lat: edge.icoCrd.y });
himMsgCrds.push(crd);
}
}
}
}
}
if(himMsgCrds.length > 0) {
Hafas.Modules.Maps.getMapById('embeddedLivemap').centerToGeo(himMsgCrds[0]);
Hafas.Modules.Maps.getMapById('embeddedLivemap').setZoom(15,"api");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment