@@ -2229,7 +2229,7 @@ function refresh() {
22292229
22302230 $ ( "#stText" ) . text ( "checking |" ) ;
22312231
2232- if ( / ^ [ a - z 0 - 9 ] { 32 } $ / ig. exec ( wvar . query ) ) {
2232+ if ( / [ a - z 0 - 9 ] { 32 } / ig. exec ( wvar . query ) ) {
22332233 tmpC . setVisible ( false ) ;
22342234 initHabitat ( ) ;
22352235 return ;
@@ -2322,7 +2322,7 @@ function refreshPredictions() {
23222322
23232323function habitat_translation_layer ( json_result ) {
23242324 if ( json_result . rows . length === 0 ) {
2325- habitat_step ( true ) ;
2325+ habitat_payload_step ( true ) ;
23262326 return ;
23272327 }
23282328
@@ -2381,30 +2381,30 @@ function habitat_translation_layer(json_result) {
23812381
23822382 // next step
23832383 periodical = setTimeout ( function ( ) {
2384- habitat_step ( ) ;
2384+ habitat_payload_step ( ) ;
23852385 } , 500 ) ;
23862386}
23872387
2388- var habitat_step_data ;
2388+ var habitat_payload_step_data ;
23892389
2390- function habitat_step ( remove_current ) {
2390+ function habitat_payload_step ( remove_current ) {
23912391 remove_current = ! ! remove_current ;
23922392
23932393 if ( remove_current ) {
2394- habitat_step_data . payloads . splice ( habitat_step_data . idx , 1 ) ;
2394+ habitat_payload_step_data . payloads . splice ( habitat_payload_step_data . idx , 1 ) ;
23952395 }
23962396
2397- if ( habitat_step_data . payloads . length === 0 ) {
2397+ if ( habitat_payload_step_data . payloads . length === 0 ) {
23982398 $ ( "#stText" ) . text ( "" ) ;
23992399 return ;
24002400 }
24012401
2402- habitat_step_data . idx += 1 ;
2403- habitat_step_data . idx = habitat_step_data . idx % habitat_step_data . payloads . length ;
2402+ habitat_payload_step_data . idx += 1 ;
2403+ habitat_payload_step_data . idx = habitat_payload_step_data . idx % habitat_payload_step_data . payloads . length ;
24042404
2405- var url = habitat_step_data . payloads [ habitat_step_data . idx ] . url ;
2406- url += habitat_step_data . payloads [ habitat_step_data . idx ] . skip ;
2407- habitat_step_data . payloads [ habitat_step_data . idx ] . skip += habitat_max ;
2405+ var url = habitat_payload_step_data . payloads [ habitat_payload_step_data . idx ] . url ;
2406+ url += habitat_payload_step_data . payloads [ habitat_payload_step_data . idx ] . skip ;
2407+ habitat_payload_step_data . payloads [ habitat_payload_step_data . idx ] . skip += habitat_max ;
24082408
24092409 ajax_positions = $ . getJSON ( url , function ( response ) {
24102410 habitat_translation_layer ( response ) ;
@@ -2414,47 +2414,61 @@ function habitat_step(remove_current) {
24142414function initHabitat ( ) {
24152415 $ ( "#stText" ) . text ( "loading |" ) ;
24162416
2417+ habitat_payload_step_data = {
2418+ idx : 0 ,
2419+ payloads : [ ] ,
2420+ } ;
2421+ var habitat_docs = [ ] ;
2422+
2423+ wvar . query . split ( ";" ) . forEach ( function ( v ) {
2424+ v = v . trim ( ) ;
2425+ if ( / ^ [ a - z 0 - 9 ] { 32 } $ / ig. exec ( v ) ) habitat_docs . push ( v ) ;
2426+ } )
2427+
2428+ habitat_doc_step ( habitat_docs ) ;
2429+ }
2430+
2431+
2432+ function habitat_doc_step ( hab_docs ) {
2433+ var docid = hab_docs . shift ( ) ;
2434+
24172435 ajax_positions = $ . ajax ( {
24182436 type : "GET" ,
2419- url : habitat_url + wvar . query ,
2437+ url : habitat_url + docid ,
24202438 data : "" ,
24212439 dataType : "json" ,
24222440 success : function ( response , textStatus ) {
24232441 if ( response . type == "flight" ) {
2424- if ( response . payloads . length === 0 ) {
2425- update ( null ) ;
2426- $ ( "#stText" ) . text ( "no payloads in doc |" ) ;
2427- return ;
2428- }
2429-
2430- ts_start = convert_time ( response . start ) / 1000 ;
2431- ts_end = convert_time ( response . end ) / 1000 ;
2442+ if ( response . payloads . length > 0 ) {
2443+ ts_start = convert_time ( response . start ) / 1000 ;
2444+ ts_end = convert_time ( response . end ) / 1000 ;
24322445
2433- habitat_step_data = {
2434- idx : 0 ,
2435- payloads : [ ] ,
2436- } ;
24372446
2438- response . payloads . forEach ( function ( payload_id ) {
2439- var url = habitat_url_payload_telemetry . replace ( / \{ I D \} / g, payload_id ) ;
2440- url = url . replace ( "{START}" , ts_start ) . replace ( "{END}" , ts_end ) ;
2447+ response . payloads . forEach ( function ( payload_id ) {
2448+ var url = habitat_url_payload_telemetry . replace ( / \{ I D \} / g, payload_id ) ;
2449+ url = url . replace ( "{START}" , ts_start ) . replace ( "{END}" , ts_end ) ;
24412450
2442- habitat_step_data . payloads . push ( {
2443- url : url ,
2444- skip : 0 ,
2451+ habitat_payload_step_data . payloads . push ( {
2452+ url : url ,
2453+ skip : 0 ,
2454+ } ) ;
24452455 } ) ;
2446- } ) ;
2447-
2448- habitat_step ( ) ;
2456+ }
24492457 }
24502458 else {
2451- update ( null ) ;
2452- $ ( "#stText" ) . text ( "docid is not a flight doc |" ) ;
2459+ if ( hab_docs . length === 0 ) update ( null ) ;
2460+ console . error ( "tracker: docid" , docid , " is not a flight_doc" ) ;
2461+ }
2462+
2463+ if ( hab_docs . length === 0 ) {
2464+ habitat_payload_step ( ) ;
2465+ } else {
2466+ habitat_doc_step ( hab_docs ) ;
24532467 }
24542468 } ,
24552469 error : function ( ) {
2456- update ( null ) ;
2457- $ ( "#stText" ) . text ( "Unable to load flight doc |" ) ;
2470+ if ( hab_docs . length === 0 ) update ( null ) ;
2471+ console . error ( "tracker: error trying to load docid" , docid ) ;
24582472 } ,
24592473 complete : function ( request , textStatus ) {
24602474 }
0 commit comments