@@ -16,51 +16,51 @@ function vibrate(pattern){
1616 }
1717}
1818
19- function addWaveToPage ( wavAudio , targetEle ) {
20- var audioEle = document . createElement ( "audio" ) ;
21- audioEle . src = window . URL . createObjectURL ( ( wavAudio . constructor . name == "Blob" ) ? wavAudio : ( new Blob ( [ wavAudio ] , { type : "audio/wav" } ) ) ) ;
22- audioEle . setAttribute ( "controls" , "controls" ) ;
23- var audioBox = document . createElement ( "div" ) ;
24- audioBox . appendChild ( audioEle ) ;
25- if ( ! targetEle ) targetEle = document . getElementById ( "mainView" ) || document . body ;
26- targetEle . appendChild ( audioBox ) ;
19+ function addWaveToPage ( wavAudio ) {
20+ var targetElement = document . getElementById ( "mainView" ) || document . body ;
21+ var audioType = "audio/wav" ;
22+ SepiaFW . webAudio . addAudioElementToPage ( targetElement , wavAudio , audioType ) ;
2723}
2824
29- uPlot . lazy . colorPalette [ 0 ] = "#ceff1a" ; //default color for first line in graph
30- var fixedPlots = {
31- 1 : {
32- graph : ( new uPlot . lazy . AutoSeries ( document . getElementById ( 'chart1' ) , 150 , {
33- rememberMax : true
34- } ) ) ,
35- use : ( document . getElementById ( "usePlot1" ) ? document . getElementById ( "usePlot1" ) . checked : true )
36- } ,
37- 2 : {
38- graph : ( new uPlot . lazy . AutoSeries ( document . getElementById ( 'chart2' ) , 150 , {
39- rememberMax : true
40- } , {
41- showAxisX : false
42- } ) ) ,
43- use : ( document . getElementById ( "usePlot2" ) ? document . getElementById ( "usePlot2" ) . checked : true )
44- } ,
45- 3 : {
46- graph : ( new uPlot . lazy . AutoSeries ( document . getElementById ( 'chart3' ) , 150 , {
47- //rememberMax: true
48- } , {
49- showAxisX : false
50- //yRange: [-0.1, 1.1]
51- } ) ) ,
52- use : ( document . getElementById ( "usePlot3" ) ? document . getElementById ( "usePlot3" ) . checked : true )
53- } ,
54- 4 : {
55- graph : ( new uPlot . lazy . AutoSeries ( document . getElementById ( 'chart4' ) , 150 , {
56- rememberMax : true
57- } , {
58- fill : [ "#ceff1a1a" ]
59- } ) ) ,
60- use : ( document . getElementById ( "usePlot4" ) ? document . getElementById ( "usePlot4" ) . checked : true )
61- } ,
25+ var fixedPlots = { } ;
26+ if ( window . uPlot && uPlot . lazy ) {
27+ uPlot . lazy . colorPalette [ 0 ] = "#ceff1a" ; //default color for first line in graph
28+ fixedPlots = {
29+ 1 : {
30+ graph : ( new uPlot . lazy . AutoSeries ( document . getElementById ( 'chart1' ) , 150 , {
31+ rememberMax : true
32+ } ) ) ,
33+ use : ( document . getElementById ( "usePlot1" ) ? document . getElementById ( "usePlot1" ) . checked : true )
34+ } ,
35+ 2 : {
36+ graph : ( new uPlot . lazy . AutoSeries ( document . getElementById ( 'chart2' ) , 150 , {
37+ rememberMax : true
38+ } , {
39+ showAxisX : false
40+ } ) ) ,
41+ use : ( document . getElementById ( "usePlot2" ) ? document . getElementById ( "usePlot2" ) . checked : true )
42+ } ,
43+ 3 : {
44+ graph : ( new uPlot . lazy . AutoSeries ( document . getElementById ( 'chart3' ) , 150 , {
45+ //rememberMax: true
46+ } , {
47+ showAxisX : false
48+ //yRange: [-0.1, 1.1]
49+ } ) ) ,
50+ use : ( document . getElementById ( "usePlot3" ) ? document . getElementById ( "usePlot3" ) . checked : true )
51+ } ,
52+ 4 : {
53+ graph : ( new uPlot . lazy . AutoSeries ( document . getElementById ( 'chart4' ) , 150 , {
54+ rememberMax : true
55+ } , {
56+ fill : [ "#ceff1a1a" ]
57+ } ) ) ,
58+ use : ( document . getElementById ( "usePlot4" ) ? document . getElementById ( "usePlot4" ) . checked : true )
59+ } ,
60+ }
6261}
6362function usePlot ( index , ele ) {
63+ if ( ! ele ) return ;
6464 var p = fixedPlots [ index ] ;
6565 if ( p ) {
6666 p . use = ele . checked ;
@@ -69,18 +69,26 @@ function usePlot(index, ele){
6969 }
7070}
7171function useHeatmap ( index , ele ) {
72+ if ( ! ele ) return ;
7273 useHeatmaps [ index ] = ele . checked ;
7374 if ( heatmaps [ index ] ) heatmaps [ index ] . resetMax ( ) ;
75+ if ( ele . checked ) {
76+ }
77+ var container = document . getElementById ( "heatmap" + index ) ;
78+ if ( container ) container . style . display = ele . checked ? "" : "none" ;
7479}
7580var useHeatmaps = { } ;
76- var heatmaps = {
77- 1 : new uPlot . lazy . Heatmap ( document . getElementById ( 'heatmap1' ) , {
78- dataPixelWidth : 4 ,
79- dataPixelHeight : 4 ,
80- colorIndex : 4 ,
81- maxDataPoints : 150
82- } )
83- } ;
81+ var heatmaps = { } ;
82+ if ( window . uPlot && uPlot . lazy && uPlot . lazy . Heatmap ) {
83+ heatmaps = {
84+ 1 : new uPlot . lazy . Heatmap ( document . getElementById ( 'heatmap1' ) , {
85+ dataPixelWidth : 4 ,
86+ dataPixelHeight : 4 ,
87+ colorIndex : 4 ,
88+ maxDataPoints : 150
89+ } )
90+ } ;
91+ }
8492usePlot ( 1 , document . getElementById ( 'usePlot1' ) ) ;
8593usePlot ( 2 , document . getElementById ( 'usePlot2' ) ) ;
8694usePlot ( 3 , document . getElementById ( 'usePlot3' ) ) ;
0 commit comments