/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/licenses/agpl.txt. */ // OSRM printer // [printing support] OSRM.Printing = { windowLoaded: function(){ OSRM.printwindow.initialize(); OSRM.Printing.show( OSRM.G.response ); OSRM.printwindow.focus(); }, show: function(response) { // create route description var route_desc = ""; route_desc += ''; for(var i=0; i < response.route_instructions.length; i++){ //odd or even ? var rowstyle='results-odd'; if(i%2==0) { rowstyle='results-even'; } route_desc += ''; route_desc += '"; route_desc += '"; route_desc += '"; route_desc += ""; } route_desc += '
'; route_desc += ''; route_desc += "'; route_desc += ''; route_desc += response.route_instructions[i][0]; if( i == 0 ) route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] ); if( response.route_instructions[i][1] != "" ) { route_desc += ' on '; route_desc += '' + response.route_instructions[i][1] + ''; } //route_desc += ' for '; route_desc += ''; route_desc += "'; if( i != response.route_instructions.length-1 ) route_desc += ''+OSRM.Utils.metersToDistance(response.route_instructions[i][2])+''; route_desc += "
'; headline = ""; headline += OSRM.loc("ROUTE_DESCRIPTION")+":
"; headline += '
'; headline += "" + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + "
" + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + "
"; headline += '
'; var output = ""; output += route_desc; OSRM.printwindow.document.getElementById('description-headline').innerHTML = headline; OSRM.printwindow.document.getElementById('description').innerHTML = output; }, // react to click print: function() { OSRM.printwindow = window.open("printing/printing.html","","width=400,height=300,left=100,top=100,dependent=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes"); OSRM.printwindow.addEventListener("DOMContentLoaded", OSRM.Printing.windowLoaded, false); } };