|
/* 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ä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 = " "; |
|
} |
|
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 = " "; |
|
}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 = " "; |
|
}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"); |
|
} |
|
}); |
|
} |