Gazelle/static/functions/reports.js

79 lines
2.0 KiB
JavaScript
Raw Normal View History

2012-12-10 08:00:21 +00:00
function toggleNotes(id) {
var style = $('#notes_div_' + id).raw().style.display;
if (style == "none") {
$('#notes_div_' + id).raw().style.display = "block";
}
else {
$('#notes_div_' + id).raw().style.display = "none";
}
}
function saveNotes(id) {
var notes = $('#notes_' + id).raw().value;
notes = notes.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '<br />');
2013-07-01 08:01:00 +00:00
var post = new Array();
post['id'] = id;
post['notes'] = notes;
ajax.post('reports.php?action=add_notes', post, function (response) {
2012-12-10 08:00:21 +00:00
if (JSON.parse(response)['status'] != 'success') {
alert("Error, could not save notes");
}
});
}
function claim(id) {
2013-07-01 08:01:00 +00:00
var post = new Array();
post['id'] = id;
ajax.post('reports.php?action=claim', post, function (response) {
2012-12-10 08:00:21 +00:00
var json = JSON.parse(response);
if (json['status'] == 'failure') {
alert("Error, could not claim.");
}
if (json['status'] == 'dupe') {
alert("Oops, this report has already been claimed.");
}
if (json['status'] == 'success') {
var username = json['username'];
$('#claim_' + id).raw().innerHTML = '<a href="#" onclick="return false;">Claimed by ' + username + '</a>';
}
});
}
2012-12-12 08:00:17 +00:00
function unClaim(id) {
2013-07-01 08:01:00 +00:00
var post = new Array();
post['id'] = id;
post['remove'] = '1';
ajax.post('reports.php?action=unclaim', post, function (response) {
2012-12-12 08:00:17 +00:00
var json = JSON.parse(response);
if (json['status'] == 'success') {
2013-03-09 08:00:18 +00:00
$('#claimed_' + id).raw().innerHTML = '<a href="#" id="claim_' + id + '" onclick="claim(' + id + '); return false;" class="brackets">Claim</a>';
2012-12-12 08:00:17 +00:00
}
});
}
function resolve(id, claimer) {
2013-01-19 08:00:51 +00:00
var answer = true;
2012-12-12 08:00:17 +00:00
if (!claimer) {
if ($('#claimed_' + id).raw()) {
2013-03-09 08:00:18 +00:00
var answer = confirm("This is a claimed report. Are you sure you want to resolve it?");
2012-12-12 08:00:17 +00:00
if (answer)
2013-01-19 08:00:51 +00:00
answer = true;
2012-12-12 08:00:17 +00:00
else
2013-01-19 08:00:51 +00:00
answer = false;
2012-12-12 08:00:17 +00:00
}
2012-12-11 08:00:18 +00:00
}
2013-01-19 08:00:51 +00:00
if (answer) {
ajax.post('reports.php?action=resolve', 'report_form_' + id, function (response) {
var json = JSON.parse(response);
if (json['status'] == 'success') {
$('#report_' + id).remove();
} else {
alert(json['status']);
}
}
);
}
return false;
2012-12-11 08:00:18 +00:00
}