From 4b0eda2a43298f2a3ac6c21b8d5eabe2a1590acc Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Mon, 17 Apr 2017 15:36:32 +0000 Subject: [PATCH] Add separate column for vehicle number (hidden by default) --- index.js | 20 ++++++++++++++++---- lang_en.js | 1 + index.html | 7 ++++++- index.css | 6 ++++++ lang_pl.js | 1 + 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/index.css b/index.css index 40f000e..bca5873 100644 --- a/index.css +++ b/index.css @@ -39,9 +39,15 @@ margin: -5px 0; font-size: 21px; } +#vehicle-data { + float: right; +} .bigger { font-size: 21px; } +.vehicleData { + display: none; +} /* Change navbar behavior for low media width */ .navbar-nav { diff --git a/index.html b/index.html index a2f7763..24f747d 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,7 @@ <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <link rel="stylesheet" type="text/css" href="index.css"> + <style type="text/css" id="vehicle-data-style"></style> </head> <body> <nav class="navbar navbar-default"> @@ -63,7 +64,11 @@ <thead> <tr> <th data-translate="header_line">Linia</th> - <th data-translate="header_direction">Kierunek</th> + <th> + <span data-translate="header_direction">Kierunek</span> + <a id="vehicle-data" data-translate="header_vehicle">Pojazd</span> + </th> + <th data-translate="header_vehicle" class="vehicleData">Pojazd</th> <th data-translate="header_time">Czas</th> <th data-translate="header_delay">Opóźn.</th> </tr> diff --git a/index.js b/index.js index c9d3531..acdfb24 100644 --- a/index.js +++ b/index.js @@ -37,6 +37,8 @@ var alert_close = document.getElementById('alert-close'); var nav = document.getElementsByTagName('nav')[0]; +var vehicle_data = document.getElementById('vehicle-data'); +var vehicle_data_style = document.getElementById('vehicle-data-style'); function parseStatus(status) { switch(status.status) { @@ -179,7 +181,9 @@ var tr = document.createElement('tr'); addCellWithText(tr, data.old[i].patternText); var dir_cell = addCellWithText(tr, data.old[i].direction); - dir_cell.appendChild(displayVehicle(parseVehicle(data.old[i].vehicleId))); + var vehicle = parseVehicle(data.actual[i].vehicleId); + dir_cell.appendChild(displayVehicle(vehicle)); + addCellWithText(tr, vehicle.num).className = 'vehicleData'; var status = parseStatus(data.old[i]); addCellWithText(tr, status); addCellWithText(tr, ''); @@ -193,7 +197,9 @@ var tr = document.createElement('tr'); addCellWithText(tr, data.actual[i].patternText); var dir_cell = addCellWithText(tr, data.actual[i].direction); - dir_cell.appendChild(displayVehicle(parseVehicle(data.actual[i].vehicleId))); + var vehicle = parseVehicle(data.actual[i].vehicleId); + dir_cell.appendChild(displayVehicle(vehicle)); + addCellWithText(tr, vehicle.num).className = 'vehicleData'; var status = parseStatus(data.actual[i]); var status_cell = addCellWithText(tr, status); var delay = parseDelay(data.actual[i]); @@ -425,15 +431,21 @@ loadTimes(stop_name_autocomplete.value); }); - refresh_button.addEventListener('click', function(e) { + refresh_button.addEventListener('click', function() { loadTimes(); loadRoute(); }); - alert_close.addEventListener('click', function(e) { + alert_close.addEventListener('click', function() { alert.style.display = 'none'; }); + vehicle_data.addEventListener('click', function(e) { + e.preventDefault(); + vehicle_data.style.display = 'none'; + setText(vehicle_data_style, '.vehicleData { display: table-cell; }') + }); + hash(); window.addEventListener('hashchange', hash); diff --git a/lang_en.js b/lang_en.js index 675ad2c..e527968 100644 --- a/lang_en.js +++ b/lang_en.js @@ -17,6 +17,7 @@ header_line: 'Line', header_direction: 'Direction', + header_vehicle: 'Vehicle', header_time: 'Time', header_delay: 'Delay', header_lines: 'Lines', diff --git a/lang_pl.js b/lang_pl.js index b010211..f343603 100644 --- a/lang_pl.js +++ b/lang_pl.js @@ -17,6 +17,7 @@ header_line: 'Linia', header_direction: 'Kierunek', + header_vehicle: 'Pojazd', header_time: 'Odjazd', header_delay: 'Opóźn.', header_lines: 'Linie', -- Gitblit v1.9.1