@@ -12,57 +12,57 @@ export function ImportedCurves(curvesChanged) {
12
12
} ;
13
13
14
14
this . importCurvesFromCSV = function ( files ) {
15
- let importsLeft = maxImportCount - this . _curvesData . length ;
15
+ let importsLeft = maxImportCount - this . _curvesData . length ;
16
16
17
- for ( const file of files ) {
18
- if ( importsLeft -- == 0 ) {
19
- break ;
20
- }
21
- const reader = new FileReader ( ) ;
22
- reader . onload = function ( e ) {
23
- try {
24
- const stringRows = e . target . result . split ( "\n" ) ;
25
-
26
- const header = stringRows [ 0 ] . split ( "," ) ;
27
- if ( header . length != 2 || header [ 0 ] != "x" || header [ 1 ] != "y" ) {
28
- throw new SyntaxError ( "Wrong curves CSV data format" ) ;
29
- }
17
+ for ( const file of files ) {
18
+ if ( importsLeft -- == 0 ) {
19
+ break ;
20
+ }
21
+ const reader = new FileReader ( ) ;
22
+ reader . onload = function ( e ) {
23
+ try {
24
+ const stringRows = e . target . result . split ( "\n" ) ;
30
25
31
- stringRows . shift ( ) ;
32
- //remove bad last row
33
- if ( stringRows . at ( - 1 ) == "" ) {
34
- stringRows . pop ( ) ;
35
- }
26
+ const header = stringRows [ 0 ] . split ( "," ) ;
27
+ if ( header . length != 2 || header [ 0 ] != "x" || header [ 1 ] != "y" ) {
28
+ throw new SyntaxError ( "Wrong curves CSV data format" ) ;
29
+ }
36
30
37
- const curvesData = stringRows . map ( function ( row ) {
38
- const data = row . split ( "," ) ,
39
- x = parseFloat ( data [ 0 ] ) ,
40
- y = parseFloat ( data [ 1 ] ) ;
41
- _that . minX = Math . min ( x , _that . minX ) ;
42
- _that . maxX = Math . max ( x , _that . maxX ) ;
43
- _that . minY = Math . min ( y , _that . minY ) ;
44
- _that . maxY = Math . max ( y , _that . maxY ) ;
45
- return {
46
- x : x ,
47
- y : y ,
48
- } ;
49
- } ) ;
31
+ stringRows . shift ( ) ;
32
+ //remove bad last row
33
+ if ( stringRows . at ( - 1 ) == "" ) {
34
+ stringRows . pop ( ) ;
35
+ }
50
36
51
- const curve = {
52
- name : file . name . split ( '.' ) [ 0 ] ,
53
- points : curvesData ,
37
+ const curvesData = stringRows . map ( function ( row ) {
38
+ const data = row . split ( "," ) ,
39
+ x = parseFloat ( data [ 0 ] ) ,
40
+ y = parseFloat ( data [ 1 ] ) ;
41
+ _that . minX = Math . min ( x , _that . minX ) ;
42
+ _that . maxX = Math . max ( x , _that . maxX ) ;
43
+ _that . minY = Math . min ( y , _that . minY ) ;
44
+ _that . maxY = Math . max ( y , _that . maxY ) ;
45
+ return {
46
+ x : x ,
47
+ y : y ,
54
48
} ;
55
- _that . _curvesData . push ( curve ) ;
56
- curvesChanged ( ) ;
57
- } catch ( e ) {
58
- alert ( 'Curves data import error: ' + e . message ) ;
59
- return ;
60
- }
61
- } ;
49
+ } ) ;
62
50
63
- reader . readAsText ( file ) ;
64
- }
65
- } ;
51
+ const curve = {
52
+ name : file . name . split ( '.' ) [ 0 ] ,
53
+ points : curvesData ,
54
+ } ;
55
+ _that . _curvesData . push ( curve ) ;
56
+ curvesChanged ( ) ;
57
+ } catch ( e ) {
58
+ alert ( 'Curves data import error: ' + e . message ) ;
59
+ return ;
60
+ }
61
+ } ;
62
+
63
+ reader . readAsText ( file ) ;
64
+ }
65
+ } ;
66
66
67
67
this . addCurve = function ( points , name ) {
68
68
this . _curvesData . push ( {
@@ -76,7 +76,7 @@ export function ImportedCurves(curvesChanged) {
76
76
this . maxY = Math . max ( point . y , _that . maxY ) ;
77
77
}
78
78
curvesChanged ( ) ;
79
- }
79
+ } ;
80
80
81
81
this . isNewCurve = function ( name ) {
82
82
for ( const curve of this . _curvesData ) {
@@ -85,7 +85,7 @@ export function ImportedCurves(curvesChanged) {
85
85
}
86
86
}
87
87
return true ;
88
- }
88
+ } ;
89
89
90
90
this . removeCurves = function ( ) {
91
91
this . _curvesData . length = 0 ;
0 commit comments