exports.stations = function(bus){ var stations = bus.stations, stationsLength = stations.length, $item, ul = ''; message.hide(); if ( 0 === stationsLength ){ message.show('ZERO'); return; } $item = createItem(); $.each( stations, function( i, station ){ if ( !station ){ return; } ul += '<li>' + renderStations( station, i ) + '</li>'; } ); $item.html( '<ul>' + ul + '</ul>' ); stationClick( $item, bus ); };
exports.lines = function(bus){ var lines = bus.lines, linesLength = lines.length, $item, ul = ''; message.hide(); if ( 0 === linesLength ){ message.show('ZERO'); return; } $item = createItem(); $.each( lines, function( i, line ){ if ( !line ){ return; } ul += '<li>' + renderLines( line, i ) + '</li>'; } ); $item.html( '<ul>' + ul + '</ul>' ); lineClick( $item, bus ); };
exports.is = function( $input ){ if ( !!$input.val() ){ message.show('SEARCHING'); return true; } $input.addClass('error'); return false; };
success: function(o){ if ( o.level !== -1 ){ data.set( address, o ); search( from, to ); return; } message.show('ERROR'); },
exports.route = function(bus){ var routes = bus.routes, routesLength = routes.length, $item, ul = ''; message.hide(); if ( 0 === routesLength ){ message.show('ZERO'); return; } $item = createItem(); $.each( routes, function( i, route ){ if ( !route ){ return; } ul += '<li>' + renderRoute(route) + '</li>'; } ); $item.html( '<ul>' + ul + '</ul>' ); };
error: function(){ message.show('ERROR'); }