/** Sets a status text in bottom left part of the screen. */
function setStatus(text, color) {
const status = $('#status')
status.html(text)
if (color === undefined) {
color = 'white'
}
status.css('background-color', color)
}
/** Creates a handler that will request to add or remove a line from a file. */
function makeHandler(elem, data, file, action) {
return function (ev) {
data['file'] = file
data['action'] = action
setStatus('Sending review...')
$.post('/modify/' + reportName, data, function (response) {
$(elem).html(
'Modified, if you want to ' +
'change this value, regenerate the report first',
)
const tab = $(elem).closest('div').parent()
const title = tab.children('h4')
tab.accordion('option', 'active', false)
const info = 'added ' + file
if (action == 'remove') {
info = 'undone review'
}
const newTitle =
'' + title.html() + ' ' + info
title.html(newTitle)
title.find('span').css('color', 'gray')
setStatus('Review for ' + data['package'] + ' sent.')
}).fail(function (err) {
setStatus('Failed to send review: ' + JSON.stringify(err), 'red')
})
}
}
$(function () {
$('body').prepend(
'
This review helper tool does not regenerate the ' +
'report - any changes that are applied using this tool will not be visible after ' +
'refreshing the page, until you regenerate the report by running ' +
'`openLegalReviewReport` command again.