Skip to content

Commit

Permalink
#33 adding check for repeated 'newResults' event
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisa Wagner committed Nov 10, 2015
1 parent 9e955c7 commit 063ae2d
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions SearchResultListVis/js/msgListeners.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
var lastProcessedQueryID;

window.onmessage = function (msg) {
if (msg.data.event) {
if (msg.data.event === 'eexcess.queryTriggered') {
// new search has been triggered somewhere, show loading bar or similar
$(showLoadingBar());
}

else if (msg.data.event === 'eexcess.newResults') {
if (msg.data.event && msg.data.event === 'eexcess.newResults') {
// new results are available in msg.data.data

$(addIsotopeGrid(msg));
$(logResultItemClicks(msg));

//make sure elements exist
var checkExist = setInterval(function() {
if ($('.eexcess-isotope-grid-item').length) {
clearInterval(checkExist);
$(addFilterCounter);
$(truncateTitles);
}
}, 10);
if (lastProcessedQueryID && lastProcessedQueryID === msg.data.data.queryID) {
// data already processed, do nothing
} else {
$(addIsotopeGrid(msg));
$(logResultItemClicks(msg));

//make sure elements exist
var checkExist = setInterval(function () {
if ($('.eexcess-isotope-grid-item').length) {
clearInterval(checkExist);
$(addFilterCounter);
$(truncateTitles);
}
}, 10);

lastProcessedQueryID = msg.data.data.queryID;
}

} else if (msg.data.event === 'eexcess.error') {
$(showError(msg.data.data));
}

}



}


}
Expand Down

0 comments on commit 063ae2d

Please sign in to comment.