35 lines
1.5 KiB
Plaintext
35 lines
1.5 KiB
Plaintext
CodeOceanEditorFlowr = {
|
|
isFlowrEnabled: true,
|
|
flowrResultHtml: '<div class="panel panel-default"><div id="{{headingId}}" role="tab" class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#flowrHint" href="#{{collapseId}}" aria-expanded="true" aria-controls="{{collapseId}}"></a></h4></div><div id="{{collapseId}}" role="tabpanel" aria-labelledby="{{headingId}}" class="panel-collapse collapse"><div class="panel-body"></div></div></div>',
|
|
|
|
handleStderrOutputForFlowr: function () {
|
|
if (!this.isFlowrEnabled) return;
|
|
|
|
var flowrUrl = $('#flowrHint').data('url');
|
|
var flowrHintBody = $('#flowrHint .panel-body');
|
|
var queryParameters = {
|
|
query: this.flowrOutputBuffer
|
|
};
|
|
|
|
flowrHintBody.empty();
|
|
|
|
jQuery.getJSON(flowrUrl, queryParameters, function (data) {
|
|
jQuery.each(data.queryResults, function (index, question) {
|
|
var collapsibleTileHtml = this.flowrResultHtml.replace(/{{collapseId}}/g, 'collapse-' + question).replace(/{{headingId}}/g, 'heading-' + question);
|
|
var resultTile = $(collapsibleTileHtml);
|
|
|
|
resultTile.find('h4 > a').text(question.title + ' | Found via ' + question.source);
|
|
resultTile.find('.panel-body').html(question.body);
|
|
resultTile.find('.panel-body').append('<a href="' + question.url + '" class="btn btn-primary btn-block">Open this question</a>');
|
|
|
|
flowrHintBody.append(resultTile);
|
|
});
|
|
|
|
if (data.queryResults.length !== 0) {
|
|
$('#flowrHint').fadeIn();
|
|
}
|
|
});
|
|
|
|
this.flowrOutputBuffer = '';
|
|
}
|
|
}; |