some semicolons

This commit is contained in:
Ralf Teusner
2015-03-31 13:22:53 +02:00
parent d601878452
commit e6f65dd853

View File

@ -231,7 +231,7 @@ $(function() {
showTab(3); showTab(3);
}; };
var stderrOutput = '' var stderrOutput = '';
var handleStderrOutputForFlowr = function(event) { var handleStderrOutputForFlowr = function(event) {
var json = JSON.parse(event.data); var json = JSON.parse(event.data);
@ -239,35 +239,35 @@ $(function() {
stderrOutput += json.stderr; stderrOutput += json.stderr;
} else if (json.code) { } else if (json.code) {
if (stderrOutput == '') { if (stderrOutput == '') {
return return;
} }
var flowrUrl = $('#flowrHint').data('url') var flowrUrl = $('#flowrHint').data('url');
var flowrHintBody = $('#flowrHint .panel-body') var flowrHintBody = $('#flowrHint .panel-body');
var queryParameters = { var queryParameters = {
query: stderrOutput query: stderrOutput
} }
flowrHintBody.empty() flowrHintBody.empty();
jQuery.getJSON(flowrUrl, queryParameters, function(data) { jQuery.getJSON(flowrUrl, queryParameters, function(data) {
for (var question in data.queryResults) { for (var question in data.queryResults) {
var collapsibleTileHtml = flowrResultHtml.replace(/{{collapseId}}/g, 'collapse-' + question).replace(/{{headingId}}/g, 'heading-' + question) var collapsibleTileHtml = flowrResultHtml.replace(/{{collapseId}}/g, 'collapse-' + question).replace(/{{headingId}}/g, 'heading-' + question);
var resultTile = $(collapsibleTileHtml) var resultTile = $(collapsibleTileHtml);
resultTile.find('h4 > a').text(data.queryResults[question].title + ' | Found via ' + data.queryResults[question].source) resultTile.find('h4 > a').text(data.queryResults[question].title + ' | Found via ' + data.queryResults[question].source);
resultTile.find('.panel-body').html(data.queryResults[question].body) resultTile.find('.panel-body').html(data.queryResults[question].body);
resultTile.find('.panel-body').append('<a href="' + data.queryResults[question].url + '" class="btn btn-primary btn-block">Open this question</a>') resultTile.find('.panel-body').append('<a href="' + data.queryResults[question].url + '" class="btn btn-primary btn-block">Open this question</a>');
flowrHintBody.append(resultTile) flowrHintBody.append(resultTile);
} }
if (data.queryResults.length !== 0) { if (data.queryResults.length !== 0) {
$('#flowrHint').fadeIn() $('#flowrHint').fadeIn();
} }
}) })
stderrOutput = '' stderrOutput = '';
} }
}; };
@ -315,8 +315,8 @@ $(function() {
var file_id = $(element).data('file-id'); var file_id = $(element).data('file-id');
setAnnotations(editor, file_id); setAnnotations(editor, file_id);
session.on('annotationRemoval', handleAnnotationRemoval) session.on('annotationRemoval', handleAnnotationRemoval);
session.on('annotationChange', handleAnnotationChange) session.on('annotationChange', handleAnnotationChange);
// TODO refactor here // TODO refactor here
// Code for clicks on gutter / sidepanel // Code for clicks on gutter / sidepanel
@ -330,54 +330,54 @@ $(function() {
var row = e.getDocumentPosition().row; var row = e.getDocumentPosition().row;
e.stop(); e.stop();
var commentModal = $('#comment-modal') var commentModal = $('#comment-modal');
if (hasCommentsInRow(editor, row)) { if (hasCommentsInRow(editor, row)) {
var rowComments = getCommentsForRow(editor, row) var rowComments = getCommentsForRow(editor, row);
var comments = _.pluck(rowComments, 'text').join('\n') var comments = _.pluck(rowComments, 'text').join('\n');
commentModal.find('#other-comments').text(comments) commentModal.find('#other-comments').text(comments);
} else { } else {
commentModal.find('#other-comments').text('none') commentModal.find('#other-comments').text('none');
} }
commentModal.find('#addCommentButton').off('click') commentModal.find('#addCommentButton').off('click');
commentModal.find('#removeAllButton').off('click') commentModal.find('#removeAllButton').off('click');
commentModal.find('#addCommentButton').on('click', function(e){ commentModal.find('#addCommentButton').on('click', function(e){
var user_id = $(element).data('user-id') var user_id = $(element).data('user-id');
var commenttext = commentModal.find('textarea').val() var commenttext = commentModal.find('textarea').val();
if (commenttext !== "") { if (commenttext !== "") {
createComment(user_id, file_id, row, editor, commenttext) createComment(user_id, file_id, row, editor, commenttext);
commentModal.modal('hide') commentModal.modal('hide');
} }
}) })
commentModal.find('#removeAllButton').on('click', function(e){ commentModal.find('#removeAllButton').on('click', function(e){
var user_id = $(element).data('user-id') var user_id = $(element).data('user-id');
deleteComment(user_id,file_id,row,editor); deleteComment(user_id,file_id,row,editor);
commentModal.modal('hide') commentModal.modal('hide');
}) })
commentModal.modal('show') commentModal.modal('show');
}); });
}); });
}; };
var hasCommentsInRow = function (editor, row){ var hasCommentsInRow = function (editor, row){
return editor.getSession().getAnnotations().some(function(element) { return editor.getSession().getAnnotations().some(function(element) {
return element.row === row return element.row === row;
}) })
} }
var getCommentsForRow = function (editor, row){ var getCommentsForRow = function (editor, row){
return editor.getSession().getAnnotations().filter(function(element) { return editor.getSession().getAnnotations().filter(function(element) {
return element.row === row return element.row === row;
}) })
} }
var setAnnotations = function (editor, file_id){ var setAnnotations = function (editor, file_id){
var session = editor.getSession() var session = editor.getSession();
var url = "/comments"; var url = "/comments";
var jqrequest = $.ajax({ var jqrequest = $.ajax({
@ -498,7 +498,7 @@ $(function() {
$('#create-file').on('click', showFileDialog); $('#create-file').on('click', showFileDialog);
$('#destroy-file').on('click', confirmDestroy); $('#destroy-file').on('click', confirmDestroy);
$('#download').on('click', downloadCode); $('#download').on('click', downloadCode);
$('#request-for-comments').on('click', requestComments) $('#request-for-comments').on('click', requestComments);
}; };
var initializeTooltips = function() { var initializeTooltips = function() {