File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,27 @@ $W = {
161161 this_ . getRecentCalibrations ( "#calibration_id" ) ;
162162 } ,
163163
164+ downloadSpectrum : function ( ) {
165+ function getFormattedTime ( ) {
166+ let current_date = new Date ( ) ;
167+ let year = current_date . getFullYear ( ) ;
168+ let month = current_date . getMonth ( ) + 1 ;
169+ let day = current_date . getDate ( ) ;
170+ let hours = current_date . getHours ( ) ;
171+ let minutes = current_date . getMinutes ( ) ;
172+ let seconds = current_date . getSeconds ( ) ;
173+ return ( year + '-' + month + '-' + day + '-' + hours + '-' + minutes + '-' + seconds ) ;
174+ }
175+
176+ let base64_imgdata = $ ( '#dataurl' ) . val ( $W . canvas . toDataURL ( ) ) [ 0 ] . defaultValue ;
177+ console . log ( base64_imgdata ) ;
178+
179+ let a = document . createElement ( 'a' ) ;
180+ a . href = base64_imgdata ;
181+ a . download = ( 'spectrum_img-' + getFormattedTime ( ) + '.png' ) ;
182+ a . click ( ) ;
183+ } ,
184+
164185 getRecentCalibrations : function ( selector ) {
165186 $ . ajax ( {
166187 url : "/capture/recent_calibrations.json?calibration_id=" + $W . calibration_id ,
You can’t perform that action at this time.
0 commit comments