Commit c27b28e4 authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

[js] add the year filter

parent 1089e3f43a0c
......@@ -9,9 +9,6 @@ function setupFilterHighlightControls(div, timeline, bandIndices, theme) {
var td = tr.insertCell(0);
td.innerHTML = "Filter:";
td = tr.insertCell(1);
td.innerHTML = "Highlight:";
var handler = function(elmt, evt, target) {
onKeyPress(timeline, bandIndices, table);
};
......@@ -21,24 +18,41 @@ function setupFilterHighlightControls(div, timeline, bandIndices, theme) {
td = tr.insertCell(0);
// var divText = document.createElement("div");
// divText.innerHTML = "Text:";
// td.appendChild(divText);
var input = document.createElement("input");
input.type = "text";
SimileAjax.DOM.registerEvent(input, "keypress", handler);
td.appendChild(input);
for (var i = 0; i < theme.event.highlightColors.length; i++) {
td = tr.insertCell(i + 1);
input = document.createElement("input");
input.type = "text";
SimileAjax.DOM.registerEvent(input, "keypress", handler);
td.appendChild(input);
var divColor = document.createElement("div");
divColor.style.height = "0.5em";
divColor.style.background = theme.event.highlightColors[i];
td.appendChild(divColor);
}
// add year filter (lglb)
td = tr.insertCell(1);
var year_input = document.createElement("input");
year_input.type = "text";
year_input.size = 4;
td.appendChild(year_input);
// var divYear = document.createElement("div");
// divYear.innerHTML = "Year:";
// td.appendChild(divYear);
var year_button = document.createElement("button");
year_button.innerHTML = "Search Year";
SimileAjax.DOM.registerEvent(year_button, "click", handler);
//SimileAjax.DOM.registerEvent(year_input, "keypress", handler);
td.appendChild(year_button);
// for (var i = 0; i < theme.event.highlightColors.length; i++) {
// td = tr.insertCell(i + 1);
// input = document.createElement("input");
// input.type = "text";
// SimileAjax.DOM.registerEvent(input, "keypress", handler);
// td.appendChild(input);
// var divColor = document.createElement("div");
// divColor.style.height = "0.5em";
// divColor.style.background = theme.event.highlightColors[i];
// td.appendChild(divColor);
// }
td = tr.insertCell(tr.cells.length);
var button = document.createElement("button");
......@@ -77,7 +91,20 @@ function performFiltering(timeline, bandIndices, table) {
};
}
var year = cleanString(tr.cells[1].firstChild.value);
filterMatcher = null;
if (year.length > 0 && !isNaN(year)) {
var regex = new RegExp(text, "i");
filterMatcher = function(evt) {
if (regex.test(evt.getText()) || regex.test(evt.getDescription())){
centerTimeline(year);
return regex;
}
};
}
var regexes = [];
var hasHighlights = false;
for (var x = 1; x < tr.cells.length - 1; x++) {
var input = tr.cells[x].firstChild;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment