Skip to content

Commit

Permalink
Added function for downloading spectrum img
Browse files Browse the repository at this point in the history
  • Loading branch information
waridrox committed Aug 6, 2021
1 parent 1d34e11 commit 3652a39
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/capture/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,27 @@ $W = {
this_.getRecentCalibrations("#calibration_id");
},

downloadSpectrum: function() {
function getFormattedTime() {
let current_date = new Date();
let year = current_date.getFullYear();
let month = current_date.getMonth() + 1;
let day = current_date.getDate();
let hours = current_date.getHours();
let minutes = current_date.getMinutes();
let seconds = current_date.getSeconds();
return (year + '-' + month + '-' + day + '-' + hours + '-' + minutes + '-' + seconds);
}

let base64_imgdata = $('#dataurl').val($W.canvas.toDataURL())[0].defaultValue;
console.log(base64data);

let a = document.createElement('a');
a.href = base64_imgdata;
a.download = ('spectrum_img-' + getFormattedTime() + '.png');
a.click();
},

getRecentCalibrations: function(selector) {
$.ajax({
url: "/capture/recent_calibrations.json?calibration_id=" + $W.calibration_id,
Expand Down

0 comments on commit 3652a39

Please sign in to comment.