Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 127 additions & 106 deletions templatesAndSettings/templates/chartAnnotation.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,116 +180,137 @@ <h1>{{ "site_header"|get_title:6 }}</h1>
$(document).ready(function() {
$('#annotationButton').click(function () {
//console.log('hello');
var $report= $('#report');
var annotation = $("#annotation").val();
var cvqualitycode = $("#SelectedQualityCode").val();
var setNaN = document.getElementById('setNaN').checked //$("#setNaN").checked;
//console.log('annotate');
var selectedResult = {{SelectedResults|safe}};
//console.log(selectedResult);
//$report.html('annotation \'' + annotation + '\' saved.');
//console.log(cvqualitycode);
//var annotationButton = document.getElementById("annotationButton"); //$("#email_data");
//annotationButton.firstChild.data = "annotation saved";
var annotationButton = document.getElementById("annotationButton");
annotationButton.disabled = true;
annotationButton.firstChild.data = "annotating values";
$.ajax({
url: "{{prefixpath}}../addannotation/",
type: "POST",
timeout: 0,
data: {
'resultidu': selectedResult,
'annotationvals': annotationvals,
'cvqualitycode': cvqualitycode,
'annotation': annotation,
'setNaN': setNaN,
'csrfmiddlewaretoken': '{{ csrf_token }}',
},
cache:false,
success: function(json) {
var annotationButton = document.getElementById("annotationButton");
//clearSelectPoints();
if (typeof json.error != "undefined"){
annotationButton.firstChild.data = "Values added: "+json.error + " reloading page";
} else if(setNaN){
annotationButton.firstChild.data = "reloading page";
}else{
annotationButton.firstChild.data = "Annotation complete, add another";
}
annotationButton.disabled = false;
if(setNaN){
location.reload();
}
},
});
if(annotationvals.length > 0){
var report= document.getElementById('report');
report.firstChild.innerHTML = '';
var annotation = $("#annotation").val();
var cvqualitycode = $("#SelectedQualityCode").val();
var setNaN = document.getElementById('setNaN').checked //$("#setNaN").checked;
//console.log('annotate');
var selectedResult = {{SelectedResults|safe}};
//console.log(selectedResult);
//$report.html('annotation \'' + annotation + '\' saved.');
//console.log(cvqualitycode);
//var annotationButton = document.getElementById("annotationButton"); //$("#email_data");
//annotationButton.firstChild.data = "annotation saved";
var annotationButton = document.getElementById("annotationButton");
annotationButton.disabled = true;
annotationButton.firstChild.data = "annotating values";
$.ajax({
url: "{{prefixpath}}../addannotation/",
type: "POST",
timeout: 0,
data: {
'resultidu': selectedResult,
'annotationvals': annotationvals,
'cvqualitycode': cvqualitycode,
'annotation': annotation,
'setNaN': setNaN,
'csrfmiddlewaretoken': '{{ csrf_token }}',
},
cache:false,
success: function(json) {
var annotationButton = document.getElementById("annotationButton");
//clearSelectPoints();
if (typeof json.error != "undefined"){
annotationButton.firstChild.data = "Values added: "+json.error + " reloading page";
} else if(setNaN){
annotationButton.firstChild.data = "reloading page";
}else{
annotationButton.firstChild.data = "Annotation complete, add another";
}
annotationButton.disabled = false;
if(setNaN){
location.reload();
}
},
});
} else{
var report= document.getElementById('report');
report.firstChild.innerHTML = 'you must select points to annotate above.';
};
});
$('#offsetButton').click(function () {
//console.log('hello');
var $report= $('#report');
var offset = $("#offset").val();
//console.log('annotate');
var selectedResult = {{SelectedResults|safe}};
//console.log(selectedResult);
//$report.html('annotation \'' + annotation + '\' saved.');
var offsetButton = document.getElementById("offsetButton");
offsetButton.disabled = true;
offsetButton.firstChild.data = "offsetting values";
//console.log(annotationvals);
$.ajax({
url: "{{prefixpath}}../addoffset/",
type: "POST",
cache:false,
data: {
'resultidu': selectedResult,
'offsetvals': annotationvals,
'offset': offset,
'csrfmiddlewaretoken': '{{ csrf_token }}',
},
success: function(json) {
//console.log("success");
var offsetButton = document.getElementById("offsetButton");
offsetButton.firstChild.data = "reloading page";
offsetButton.disabled = false;
//offsetPoints(parseFloat(offset));
//setTimeout(function(){location.reload();},100);
location.reload();
},
});
if(annotationvals.length > 0){
var report= document.getElementById('report');
report.firstChild.innerHTML = '';
//console.log('hello');
var $report= $('#report');
var offset = $("#offset").val();
//console.log('annotate');
var selectedResult = {{SelectedResults|safe}};
//console.log(selectedResult);
//$report.html('annotation \'' + annotation + '\' saved.');
var offsetButton = document.getElementById("offsetButton");
offsetButton.disabled = true;
offsetButton.firstChild.data = "offsetting values";
//console.log(annotationvals);
$.ajax({
url: "{{prefixpath}}../addoffset/",
type: "POST",
cache:false,
data: {
'resultidu': selectedResult,
'offsetvals': annotationvals,
'offset': offset,
'csrfmiddlewaretoken': '{{ csrf_token }}',
},
success: function(json) {
//console.log("success");
var offsetButton = document.getElementById("offsetButton");
offsetButton.firstChild.data = "reloading page";
offsetButton.disabled = false;
//offsetPoints(parseFloat(offset));
//setTimeout(function(){location.reload();},100);
location.reload();
},
});
} else{
var report= document.getElementById('report');
report.firstChild.innerHTML = 'you must select points to offset above.';

};
});
$('#shiftValuesButton').click(function () {
var $report= $('#report');
var shift = $("#shiftValues").val();
var selectedResult = {{SelectedResults|safe}};
var shiftValuesButton = document.getElementById("shiftValuesButton");
var radios = document.getElementsByName("shiftdirection");
var direction = "forward";
for (var i = 0, length = radios.length; i<length; i++){
if (radios[i].checked){
direction = radios[i].value;
if(annotationvals.length > 0){
var report= document.getElementById('report');
report.firstChild.innerHTML = '';
var $report= document.getElementById("$report");
var shift = $("#shiftValues").val();
var selectedResult = {{SelectedResults|safe}};
var shiftValuesButton = document.getElementById("shiftValuesButton");
var radios = document.getElementsByName("shiftdirection");
var direction = "forward";
for (var i = 0, length = radios.length; i<length; i++){
if (radios[i].checked){
direction = radios[i].value;
}
}
}
shiftValuesButton.disabled = true;
shiftValuesButton.firstChild.data = "shifting values";

$.ajax({
url: "{{prefixpath}}../addshiftvals/",
type: "POST",
data: {
'resultidu': selectedResult,
'shiftvals': annotationvals,
'shift': shift,
'direction' : direction,
'csrfmiddlewaretoken': '{{ csrf_token }}',
},
success: function(json) {
//console.log("success");
var shiftValuesButton = document.getElementById("shiftValuesButton");
shiftValuesButton.firstChild.data = "reloading page";
shiftValuesButton.disabled = false;
location.reload();
},
});
shiftValuesButton.disabled = true;
shiftValuesButton.firstChild.data = "shifting values";

$.ajax({
url: "{{prefixpath}}../addshiftvals/",
type: "POST",
data: {
'resultidu': selectedResult,
'shiftvals': annotationvals,
'shift': shift,
'direction' : direction,
'csrfmiddlewaretoken': '{{ csrf_token }}',
},
success: function(json) {
//console.log("success");
var shiftValuesButton = document.getElementById("shiftValuesButton");
shiftValuesButton.firstChild.data = "reloading page";
shiftValuesButton.disabled = false;
location.reload();
},
});
} else {
var report= document.getElementById('report');
report.firstChild.innerHTML = 'you must select points to drift correct above.';
};
});
//createL1
$('#createL1').click(function () {
Expand Down Expand Up @@ -492,7 +513,7 @@ <h1>{{ "site_header"|get_title:6 }}</h1>
{% if useDataset %}
{{datasetAbstract}}
{% endif %}
<div id="report" ></div>
<div id="report" class="deletelink"><p></p></div>
<table>
<th>Add an annotation for the selected points</th>
<tr><td colspan="3">to see more details about how to add annotations see <a target="_blank" href="http://odm2.github.io/ODM2-Admin/DataQAQC.html">The CZ Manager docs</a></td></tr>
Expand Down