";
snapshots = context.snapshots;
firstUploadTime0 = snapshots[0][1];
secsAgo0 = currTime - firstUploadTime0;
ageColor0 = ageColor(secsAgo0);
html += "";
html +="
";
html += "
";
}
$("#contextsTable > tbody:last").append(html);
// Select the first context as Context 1 ...
$("#contextsTable td:first input").attr("checked", "true");
if (context1() == null)
$("#div_noMatchingContexts").css("display", "block");
highlightContextsTable();
updateActions();
$("#div_availableContexts").css("display", "block");
fetchTestCases();
}
}
},
error: function(request, textStatus, errorThrown) {
descr = errorThrown;
if (errorThrown == null) {
descr = "undefined error - is the server down?";
}
updateStatus(
"fetching available contexts ... error: " + descr, false);
}
// complete: function(request, textStatus) {
// alert("complete; request.status: " + request.status)
// }
});
return false;
}
// Handles selecting another database.
function selectDatabase() {
fetchContexts();
}
function highlightContextsTable() {
// Unhighlight all selectable rows:
$("#contextsTable tr:has(input)").attr("class", "unselected");
// Highlight selected rows (prioritizing context 1):
$.each(["context2", "context1"], function(index, value) {
rows = $("#contextsTable tr:has(input[name='" + value +
"'][checked='true'])");
rows.attr("class", value);
});
// Highlight extra context 2 row (if any):
$("#extra_context2_row").attr("class", "context2");
}
// Handles clicking a context radio button.
function clickContextRadioButton(cb, col) {
// Check if the same host/platform/branch combination is selected for
// both contexts. If so, add an extra row below the selected row to enable
// selection of a different snapshot for the Context 2
// (unless such an extra row doesn't already exist):
index = cb.id.split(":")[1];
tr = $("#" + "context_row\\:" + index);
checked1 = tr.find("td:nth-child(1) input").attr("checked");
checked2 = tr.find("td:nth-child(2) input").attr("checked");
if (checked1 && checked2) {
if ($("#extra_context2_row").length == 0) {
// Get selected sha1:
sha1 = tr.find("select option:selected").attr("value");
// Append extra row:
tr.after(
"
" +
"
" +
"
");
// Clone snapshots:
tr.find("#context_snapshots\\:" + index).clone().appendTo(
"#extra_context2_snapshots");
extraSelect = $("#extra_context2_snapshots select");
extraSelect.find("option[value = '" + sha1 + "']").attr(
"selected", true);
extraSelect.attr("onchange", ""); // This is needed!
extraSelect.change(function() {
selectExtraContext2Snapshot();
});
// Initialize selected snapshot color:
selectExtraContext2Snapshot(true);
}
} else {
// Remove any extra row:
trExtra = $("#extra_context2_row");
if (trExtra.length > 0) {
mainIndex = trExtra.attr("name");
trMain = $("#" + "context_row\\:" + mainIndex);
// If Context 2 is still selected for the main row,
// select the current snapshot of the main row as the one
// selected for the extra row before removing the latter:
if (trMain.find("td:nth-child(2) input").attr("checked")) {
// Get selected sha1 in extra row:
sha1 = trExtra.find("select option:selected").attr("value");
// Select this sha1 in the main row:
trMain.find("select option[value = '" + sha1 + "']").attr(
"selected", true);
// Initialize selected snapshot color:
selectContextSnapshot(parseInt(mainIndex));
}
trExtra.remove();
}
}
highlightContextsTable();
updateActions();
fetchTestCases();
}
$(document).ready(function() {
// Set default action arguments:
$("#diff_tol option[value='1.1']").attr("selected", true);
$("#dur_tol_min option[value='3']").attr("selected", true);
$("#dur_tol_max option[value='10']").attr("selected", true);
fetchContexts();
});