@@ -1836,8 +1836,9 @@ function BlackboxLogViewer() {
18361836 if ( graph == null && field == null ) return false ; // no pen specified, just exit
18371837
18381838 if ( graph != null && field == null ) {
1839+ const gi = Number . parseInt ( graph , 10 ) ;
18391840 // save ALL pens within group
1840- for ( const configField of graphConfig [ Number . parseInt ( graph ) ] . fields ) {
1841+ for ( const configField of graphConfig [ gi ] . fields ) {
18411842 if ( configField . default == null ) {
18421843 configField . default = [ ] ;
18431844 configField . default . smoothing = configField . smoothing ;
@@ -1847,17 +1848,13 @@ function BlackboxLogViewer() {
18471848 return "<h4>Stored defaults for all pens</h4>" ;
18481849 }
18491850 if ( graph != null && field != null ) {
1851+ const gi = Number . parseInt ( graph , 10 ) ;
1852+ const fi = Number . parseInt ( field , 10 ) ;
18501853 // restore single pen
1851- if (
1852- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . default == null
1853- ) {
1854- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . default = [ ] ;
1855- graphConfig [ Number . parseInt ( graph ) ] . fields [
1856- Number . parseInt ( field )
1857- ] . default . smoothing =
1858- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . smoothing ;
1859- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . default . power =
1860- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . curve . power ;
1854+ if ( graphConfig [ gi ] . fields [ fi ] . default == null ) {
1855+ graphConfig [ gi ] . fields [ fi ] . default = [ ] ;
1856+ graphConfig [ gi ] . fields [ fi ] . default . smoothing = graphConfig [ gi ] . fields [ fi ] . smoothing ;
1857+ graphConfig [ gi ] . fields [ fi ] . default . power = graphConfig [ gi ] . fields [ fi ] . curve . power ;
18611858 return "<h4>Stored defaults for single pen</h4>" ;
18621859 }
18631860 }
@@ -1874,8 +1871,9 @@ function BlackboxLogViewer() {
18741871 if ( graph == null && field == null ) return false ; // no pen specified, just exit
18751872
18761873 if ( graph != null && field == null ) {
1874+ const gi = Number . parseInt ( graph , 10 ) ;
18771875 // restore ALL pens within group
1878- for ( const configField of graphConfig [ Number . parseInt ( graph ) ] . fields ) {
1876+ for ( const configField of graphConfig [ gi ] . fields ) {
18791877 if ( configField . default != null ) {
18801878 configField . smoothing = configField . default . smoothing ;
18811879 configField . curve . power = configField . default . power ;
@@ -1884,16 +1882,12 @@ function BlackboxLogViewer() {
18841882 return "<h4>Restored defaults for all pens</h4>" ;
18851883 }
18861884 if ( graph != null && field != null ) {
1885+ const gi = Number . parseInt ( graph , 10 ) ;
1886+ const fi = Number . parseInt ( field , 10 ) ;
18871887 // restore single pen
1888- if (
1889- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . default != null
1890- ) {
1891- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . smoothing =
1892- graphConfig [ Number . parseInt ( graph ) ] . fields [
1893- Number . parseInt ( field )
1894- ] . default . smoothing ;
1895- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . curve . power =
1896- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . default . power ;
1888+ if ( graphConfig [ gi ] . fields [ fi ] . default != null ) {
1889+ graphConfig [ gi ] . fields [ fi ] . smoothing = graphConfig [ gi ] . fields [ fi ] . default . smoothing ;
1890+ graphConfig [ gi ] . fields [ fi ] . curve . power = graphConfig [ gi ] . fields [ fi ] . default . power ;
18971891 return "<h4>Restored defaults for single pen</h4>" ;
18981892 } else return false ;
18991893 }
@@ -1917,37 +1911,30 @@ function BlackboxLogViewer() {
19171911
19181912 let changedValue = "<h4>Smoothing</h4>" ;
19191913 if ( graph != null && field == null ) {
1914+ const gi = Number . parseInt ( graph , 10 ) ;
19201915 // change ALL pens within group
1921- for ( const configField of graphConfig [ Number . parseInt ( graph ) ] . fields ) {
1916+ for ( const configField of graphConfig [ gi ] . fields ) {
19221917 configField . smoothing += delta ? - scroll : + scroll ;
19231918 configField . smoothing = constrain (
19241919 configField . smoothing ,
19251920 range . min ,
19261921 range . max
19271922 ) ;
1928- changedValue += `${ configField . friendlyName } ${ (
1929- configField . smoothing / 100
1930- ) . toFixed ( 2 ) } %\n`;
1923+ changedValue += `${ configField . friendlyName } ${ ( configField . smoothing / 100 ) . toFixed ( 2 ) } %\n` ;
19311924 }
19321925 return changedValue ;
19331926 }
19341927 if ( graph != null && field != null ) {
1928+ const gi = Number . parseInt ( graph , 10 ) ;
1929+ const fi = Number . parseInt ( field , 10 ) ;
19351930 // change single pen
1936- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . smoothing += delta
1937- ? - scroll
1938- : + scroll ;
1939- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . smoothing =
1940- constrain (
1941- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . smoothing ,
1942- range . min ,
1943- range . max
1944- ) ;
1945- return `${
1946- changedValue +
1947- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . friendlyName
1948- } ${ (
1949- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . smoothing / 100
1950- ) . toFixed ( 2 ) } %\n`;
1931+ graphConfig [ gi ] . fields [ fi ] . smoothing += delta ? - scroll : + scroll ;
1932+ graphConfig [ gi ] . fields [ fi ] . smoothing = constrain (
1933+ graphConfig [ gi ] . fields [ fi ] . smoothing ,
1934+ range . min ,
1935+ range . max
1936+ ) ;
1937+ return `${ changedValue + graphConfig [ gi ] . fields [ fi ] . friendlyName } ${ ( graphConfig [ gi ] . fields [ fi ] . smoothing / 100 ) . toFixed ( 2 ) } %\n` ;
19511938 }
19521939 return false ; // nothing was changed
19531940 }
@@ -1967,27 +1954,23 @@ function BlackboxLogViewer() {
19671954 zoomScaleIn = 1.0 / zoomScaleOut ;
19681955 let changedValue = "<h4></h4>" ;
19691956 if ( graph != null && field == null ) {
1957+ const gi = Number . parseInt ( graph , 10 ) ;
19701958 // change ALL pens within group
19711959 changedValue += delta ? "Zoom out:\n" : "Zoom in:\n" ;
1972- for ( const configField of graphConfig [ Number . parseInt ( graph ) ] . fields ) {
1960+ for ( const configField of graphConfig [ gi ] . fields ) {
19731961 configField . curve . MinMax . min *= delta ? zoomScaleOut : zoomScaleIn ;
19741962 configField . curve . MinMax . max *= delta ? zoomScaleOut : zoomScaleIn ;
19751963 changedValue += `${ configField . friendlyName } \n` ;
19761964 }
19771965 return changedValue ;
19781966 }
19791967 if ( graph != null && field != null ) {
1968+ const gi = Number . parseInt ( graph , 10 ) ;
19801969 // change single pen
1981- graphConfig [ Number . parseInt ( graph ) ] . fields [ field ] . curve . MinMax . min *= delta
1982- ? zoomScaleOut
1983- : zoomScaleIn ;
1984- graphConfig [ Number . parseInt ( graph ) ] . fields [ field ] . curve . MinMax . max *= delta
1985- ? zoomScaleOut
1986- : zoomScaleIn ;
1970+ graphConfig [ gi ] . fields [ field ] . curve . MinMax . min *= delta ? zoomScaleOut : zoomScaleIn ;
1971+ graphConfig [ gi ] . fields [ field ] . curve . MinMax . max *= delta ? zoomScaleOut : zoomScaleIn ;
19871972 changedValue += delta ? "Zoom out:\n" : "Zoom in:\n" ;
1988- changedValue += `${
1989- graphConfig [ Number . parseInt ( graph ) ] . fields [ field ] . friendlyName
1990- } \n`;
1973+ changedValue += `${ graphConfig [ gi ] . fields [ field ] . friendlyName } \n` ;
19911974 return changedValue ;
19921975 }
19931976 return false ; // nothing was changed
@@ -2010,36 +1993,30 @@ function BlackboxLogViewer() {
20101993
20111994 let changedValue = "<h4>Expo</h4>" ;
20121995 if ( graph != null && field == null ) {
1996+ const gi = Number . parseInt ( graph , 10 ) ;
20131997 // change ALL pens within group
2014- for ( const configField of graphConfig [ Number . parseInt ( graph ) ] . fields ) {
1998+ for ( const configField of graphConfig [ gi ] . fields ) {
20151999 configField . curve . power += delta ? - scroll : + scroll ;
20162000 configField . curve . power = constrain (
20172001 configField . curve . power ,
20182002 range . min ,
20192003 range . max
20202004 ) ;
2021- changedValue += `${ gconfigField . friendlyName } ${ (
2022- configField . curve . power * 100
2023- ) . toFixed ( 2 ) } %\n`;
2005+ changedValue += `${ configField . friendlyName } ${ ( configField . curve . power * 100 ) . toFixed ( 2 ) } %\n` ;
20242006 }
20252007 return changedValue ;
20262008 }
20272009 if ( graph != null && field != null ) {
2010+ const gi = Number . parseInt ( graph , 10 ) ;
2011+ const fi = Number . parseInt ( field , 10 ) ;
20282012 // change single pen
2029- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . curve . power +=
2030- delta ? - scroll : + scroll ;
2031- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . curve . power =
2032- constrain (
2033- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . curve . power ,
2034- range . min ,
2035- range . max
2036- ) ;
2037- return `${
2038- changedValue +
2039- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . friendlyName
2040- } ${ (
2041- graphConfig [ Number . parseInt ( graph ) ] . fields [ Number . parseInt ( field ) ] . curve . power * 100
2042- ) . toFixed ( 2 ) } %\n`;
2013+ graphConfig [ gi ] . fields [ fi ] . curve . power += delta ? - scroll : + scroll ;
2014+ graphConfig [ gi ] . fields [ fi ] . curve . power = constrain (
2015+ graphConfig [ gi ] . fields [ fi ] . curve . power ,
2016+ range . min ,
2017+ range . max
2018+ ) ;
2019+ return `${ changedValue + graphConfig [ gi ] . fields [ fi ] . friendlyName } ${ ( graphConfig [ gi ] . fields [ fi ] . curve . power * 100 ) . toFixed ( 2 ) } %\n` ;
20432020 }
20442021 return false ; // nothing was changed
20452022 }
0 commit comments