Skip to content

Commit 8c4bcc2

Browse files
Merge branch 'beta', multiple docs + ?filter= fix
1613247 - allow for multiple docids in query a95682c - when using ?filter= set the value in the searchbox
2 parents f5f4d0d + 1613247 commit 8c4bcc2

File tree

2 files changed

+56
-39
lines changed

2 files changed

+56
-39
lines changed

js/app.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ for(var idx in params) {
173173
case "hidelist": if(line[1] == "1") wvar.vlist = false; break;
174174
case "hidegraph": if(line[1] == "1") wvar.graph = false; break;
175175
case "expandgraph": if(line[1] == "1") wvar.graph_expanded = true; break;
176-
case "filter": wvar.query = decodeURIComponent(line[1]); break;
176+
case "filter":
177+
wvar.query = decodeURIComponent(line[1]);
178+
$("header .search input[type='text']").val(wvar.query);
179+
break;
177180
case "nyan": wvar.nyan = true; break;
178181
case "focus": wvar.focus = decodeURIComponent(line[1]); break;
179182
case "docid": wvar.docid = line[1]; break;

js/tracker.js

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,7 +2229,7 @@ function refresh() {
22292229

22302230
$("#stText").text("checking |");
22312231

2232-
if(/^[a-z0-9]{32}$/ig.exec(wvar.query)) {
2232+
if(/[a-z0-9]{32}/ig.exec(wvar.query)) {
22332233
tmpC.setVisible(false);
22342234
initHabitat();
22352235
return;
@@ -2322,7 +2322,7 @@ function refreshPredictions() {
23222322

23232323
function 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) {
24142414
function 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-z0-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(/\{ID\}/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(/\{ID\}/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

Comments
 (0)