\
\
\
\
\
\
\
';
if ( data.comment_user == username) {
_data += edit_btn +
'
';
}
_data += '
\
\
';
}
if (inline){
// Inline comment
console.log('Inline');
var field = $('[data-commit="' + data.commit_id + '"]').parent();
var id = field.children().children().attr('id').split('_')[0];
var row = $('#' + id + '_' + (parseInt(data.line) + 1)).parent().parent();
row.before(_data);
} else {
// Generic comment
console.log('generic');
var field = $('#request_comment');
field.html(field.html() + _data);
}
}
update_comment = function(data) {
console.log('Updating comment ' + data.comment_id);
var field = $('#comment-' + data.comment_id).parent();
var edited = field.find('.text-muted');
if (edited.length == 0) {
$(field.find('aside')).before(
'
Edited a just now by '
+ data.comment_editor + '');
} else {
edited.html('Edited a just now by ' + data.comment_editor)
}
field.find('.comment_body').html(data.comment_updated);
field.find('.issue_actions').show();
field.find('.issue_comment').show();
}
process_event = function(data, requestid, username){
console.log(data);
var category = null;
var originalTitle = document.title;
if (data.comment_added){
add_comment(data, username);
category = 'comment';
} else if (data.comment_updated){
update_comment(data);
category = 'Comment updated';
} else {
console.log('Unknown data');
}
if (category && !document.hasFocus()) {
var int = setInterval(function(){
var title = document.title;
document.title = (title === originalTitle) ? category : originalTitle;
}, 750);
$(window).focus(function () {
clearInterval(int);
document.title = originalTitle;
});
}
}