Commit 3eb910f6 authored by Caillat Michel's avatar Caillat Michel
Browse files

Added context informations to the informations exported by copy to clip board(...

Added context informations to the informations exported by copy to clip board( verbatim or json ). These are the file name and the slice index when the cube is 3D
parent d68d06a3
......@@ -30,11 +30,22 @@ class InfosBlock {
this.verbatimCopyBtn = document.getElementById('verbatimCopy');
this.jsonCopyBtn = document.getElementById('jsonCopy');
this.sliceViewer = sliceViewer;
$(sliceViewer.getMap().getTargetElement()).append($("#ModalInfosBlock"));
this.verbatimCopyBtn.onclick = this.verbatimCopy.bind(this);
this.jsonCopyBtn.onclick = this.jsonCopy.bind(this);
}
format(floatValue) {
let result = floatValue;
if (typeof result === "number" && !Number.isInteger(result)){
result = result.toExponential(4);
}
return result;
};
headline(title) {
this.infosLine.innerHTML = title;
this.infosLine.innerHTML += ' <button type="button" class="btn btn-outline-link btn-sm" data-toggle="modal" data-target="#ModalInfosBlock">etc.</button>';
......@@ -46,7 +57,7 @@ class InfosBlock {
this.collection = collection;
this.infosBlock.innerHTML = "<b>"+title+" <br><br>";
for (var k in collection) {
this.infosBlock.innerHTML += k + ":" + format(collection[k]["value"]) + " " + collection[k]["unit"] + "<br>";
this.infosBlock.innerHTML += k + ":" + this.format(collection[k]["value"]) + " " + collection[k]["unit"] + "<br>";
}
console.log("populate: exiting");
}
......@@ -54,6 +65,10 @@ class InfosBlock {
verbatimCopy() {
console.log("verbatimCopy : entering");
this.hiddenInfosBlock.value = this.title + "\r\n\r\n";
this.hiddenInfosBlock.value += "file:"+this.sliceViewer.getRelFITSFilePath()+"\r\n";
if (sliceViewer.is3D()) {
this.hiddenInfosBlock.value += "slice index:"+this.sliceViewer.getSliceIndex()+"\r\n";
}
for (var k in this.collection) {
this.hiddenInfosBlock.value += k + ":" + format(this.collection[k]["value"]) + " " + this.collection[k]["unit"] + "\r\n";
}
......@@ -69,7 +84,12 @@ class InfosBlock {
jsonCopy() {
console.log("jsonCopy : entering");
this.hiddenInfosBlock.value = JSON.stringify(this.collection);
let context = {};
context["file"]=this.sliceViewer.getRelFITSFilePath();
if (sliceViewer.is3D()) {
context["slice index"]=this.sliceViewer.getSliceIndex();
}
this.hiddenInfosBlock.value = JSON.stringify($.extend(context, this.collection));
this.hiddenInfosBlock.select();
try {
var success = document.execCommand('copy');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment