| | |
| | | |
| | | ttss_types.forEach(function(ttss_type) { |
| | | vehicles[ttss_type].source.forEachFeature(function(feature) { |
| | | if(feature.get('vehicle_type') && feature.get('vehicle_type').num.indexOf(query) > -1) { |
| | | if(feature.get('type') && feature.get('type').num.indexOf(query) > -1) { |
| | | features.push(feature); |
| | | } |
| | | }); |
| | |
| | | }), |
| | | text: new ol.style.Text({ |
| | | font: 'bold 10px sans-serif', |
| | | // TODO: special directions |
| | | // vehicle.line = vehicle.name.substr(0, vehicle_name_space); |
| | | // vehicle.direction = normalizeName(vehicle.name.substr(vehicle_name_space+1)); |
| | | // if(special_directions[vehicle.direction]) { |
| | | // vehicle.line = special_directions[vehicle.direction]; |
| | | // } |
| | | text: feature.get('line'), |
| | | fill: new ol.style.Fill({color: 'white'}), |
| | | }), |
| | |
| | | }, |
| | | _removeFeature: function(feature) { |
| | | if(!feature) return; |
| | | this.source.removeFeature(feature); |
| | | if(this.selectedFeatureId === feature.getId()) { |
| | | this.deselect(); |
| | | } |
| | | this.source.removeFeature(feature); |
| | | }, |
| | | loadFullData: function(data) { |
| | | var self = this; |
| | |
| | | api_url + '/positions/?type=' + this.prefix + '&last=' + this.lastUpdate |
| | | ).done(function(data) { |
| | | try { |
| | | if(data['date'] < self.lastUpdate) { |
| | | console.log('Data older than lastUpdate!'); |
| | | } |
| | | if(data['type'] == 'full') { |
| | | self.loadFullData(data['pos']); |
| | | } else { |
| | | self.loadDiffData(data['pos']); |
| | | } |
| | | self.lastUpdate = data['last']; |
| | | self.lastUpdate = data['date']; |
| | | setTimeout(self.fetchXhr.bind(self), api_refresh); |
| | | } catch(e) { |
| | | console.log(e); |
| | |
| | | var featureSource = featureDiscriminator.substr(1, 1); |
| | | |
| | | feature_xhr = $.get( |
| | | api_url + '/stop/?type=' + featureSource + '&id=' + feature.getId() |
| | | api_url + '/schedule/?type=' + featureSource + '&id=' + feature.getId() |
| | | ).done(function(data) { |
| | | deleteChildren(table); |
| | | |
| | | var all_departures = data.old.concat(data.actual); |
| | | var tr, dir_cell, vehicle, status, status_cell, delay, delay_cell; |
| | | for(var i = 0, il = all_departures.length; i < il; i++) { |
| | | for(var i = 0, il = data.length; i < il; i++) { |
| | | tr = document.createElement('tr'); |
| | | addCellWithText(tr, all_departures[i].patternText); |
| | | dir_cell = addCellWithText(tr, normalizeName(all_departures[i].direction)); |
| | | addCellWithText(tr, data[i].line); |
| | | dir_cell = addCellWithText(tr, data[i].direction); |
| | | //vehicle = vehicles_info.getParsed(all_departures[i].vehicleId); |
| | | dir_cell.appendChild(displayVehicle(vehicle)); |
| | | status = parseStatus(all_departures[i]); |
| | | status_cell = addCellWithText(tr, status); |
| | | delay = parseDelay(all_departures[i]); |
| | | delay_cell = addCellWithText(tr, delay); |
| | | |
| | | //dir_cell.appendChild(displayVehicle(vehicle)); |
| | | //status = parseStatus(all_departures[i]); |
| | | status_cell = addCellWithText(tr, data[i].time); |
| | | //delay = parseDelay(all_departures[i]); |
| | | delay_cell = addCellWithText(tr, ''); |
| | | /* |
| | | if(i < data.old.length) { |
| | | tr.className = 'active'; |
| | | } else if(status === lang.boarding_sign) { |
| | |
| | | } else if(parseInt(delay) > 3) { |
| | | tr.className = 'warning'; |
| | | } |
| | | |
| | | */ |
| | | table.appendChild(tr); |
| | | } |
| | | |
| | |
| | | |
| | | hash = new Hash(); |
| | | Deferred.all(future_requests).done(hash.ready.bind(hash)); |
| | | |
| | | setTimeout(function() { |
| | | ttss_types.forEach(function(type) { |
| | | if(vehicles_xhr[type]) { |
| | | vehicles_xhr[type].abort(); |
| | | } |
| | | if(vehicles_timer[type]) { |
| | | clearTimeout(vehicles_timer[type]); |
| | | } |
| | | }); |
| | | |
| | | fail(lang.error_refresh); |
| | | }, 1800000); |
| | | } |
| | | |
| | | init(); |