Prevent accessing /nodes/undefined/view from search pages.
`firstHit.attr('data-hit-id')` can be undefined; in that case we just ignore the siutation. Furthermore, I've removed the call to clearTimeout(), as it is only called after the timeout has been hit, and thus is a no-op.
This commit is contained in:
parent
305d9b44ec
commit
574178cffc
@ -82,17 +82,24 @@ $(document).ready(function() {
|
|||||||
firstHit.addClass('active');
|
firstHit.addClass('active');
|
||||||
firstHit.find('#search-loading').addClass('active');
|
firstHit.find('#search-loading').addClass('active');
|
||||||
|
|
||||||
var getNode = setTimeout(function() {
|
function done() {
|
||||||
$.get('/nodes/' + firstHit.attr('data-hit-id') + '/view', function(dataHtml) {
|
|
||||||
$('#search-hit-container').html(dataHtml);
|
|
||||||
})
|
|
||||||
.done(function() {
|
|
||||||
$('.search-loading').removeClass('active');
|
$('.search-loading').removeClass('active');
|
||||||
$('#search-error').hide();
|
$('#search-error').hide();
|
||||||
$('#search-hit-container').show();
|
$('#search-hit-container').show();
|
||||||
|
}
|
||||||
|
|
||||||
clearTimeout(getNode);
|
window.setTimeout(function() {
|
||||||
|
// Ignore getting that first result when there is none.
|
||||||
|
var hit_id = firstHit.attr('data-hit-id');
|
||||||
|
if (hit_id === undefined) {
|
||||||
|
done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.get('/nodes/' + hit_id + '/view', function(dataHtml) {
|
||||||
|
$('#search-hit-container').html(dataHtml);
|
||||||
})
|
})
|
||||||
|
.done(done)
|
||||||
.fail(function(data) {
|
.fail(function(data) {
|
||||||
$('.search-loading').removeClass('active');
|
$('.search-loading').removeClass('active');
|
||||||
$('#search-hit-container').hide();
|
$('#search-hit-container').hide();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user