minor improvements

This commit is contained in:
Hauke Klement
2015-03-07 16:13:20 +01:00
parent cb2cd90fb0
commit 64365025dc

View File

@ -617,32 +617,27 @@ $(function() {
showRequestedTab(); showRequestedTab();
} }
var stderrOutput = '';
var handleStderrOutputForFlowr = function(event) { var handleStderrOutputForFlowr = function(event) {
var flowrUrl = $('#flowrHint').data('url'); var flowrUrl = $('#flowrHint').data('url');
var json = JSON.parse(event.data); var json = JSON.parse(event.data);
var stderrOutput = '';
if (json.stderr) { if (json.stderr) {
stderrOutput += json.stderr; stderrOutput += json.stderr;
} else if (json.code) { } else if (json.code) {
var flowrHintBody = $('#flowrHint .panel-body'); var flowrHintBody = $('#flowrHint .panel-body');
jQuery.getJSON(flowrUrl + '&query=' + escape(stderrOutput), function(data) { $.getJSON(flowrUrl + '&query=' + escape(stderrOutput), function(data) {
for (var question in data.queryResults) { _.each(_.compact(data.queryResults), function(question, index) {
// replace everything, not only one occurence var collapsibleTileHtml = flowrResultHtml.replace(/{{collapseId}}/g, 'collapse-' + index).replace(/{{headingId}}/g, 'heading-' + index);
var collapsibleTileHtml = flowrResultHtml.replace(/{{collapseId}}/g, 'collapse-' + question).replace(/{{headingId}}/g, 'heading-' + question);
var resultTile = $(collapsibleTileHtml); var resultTile = $(collapsibleTileHtml);
resultTile.find('h4 > a').text(question.title);
resultTile.find('h4 > a').text(data.queryResults[question].title); resultTile.find('.panel-body').append(question.body);
resultTile.find('.panel-body').append($(data.queryResults[question].body));
flowrHintBody.append(resultTile); flowrHintBody.append(resultTile);
} });
$('#flowrHint').fadeIn(); $('#flowrHint').fadeIn();
}); });
stderrOutput = '';
} }
}; };
}); });