@@ -30,48 +30,36 @@ window.onload = function(){
30
30
31
31
function algoChosen ( ) {
32
32
33
- try {
34
-
35
- algo = algoSelector . value ;
36
- if ( algo === null || algo === 'none' ) {
37
- clearInputDashBoard ( ) ;
38
- allDisable ( [ algoSelector ] ) ;
33
+ algo = algoSelector . value ;
34
+ if ( algo === null || algo === 'none' ) {
35
+ clearInputDashBoard ( ) ;
36
+ allDisable ( [ algoSelector ] ) ;
37
+ }
38
+ else {
39
+ if ( algo === 'BubbleSort' ) {
40
+ one = new BubbleSort ( ) ;
41
+ classOne = BubbleSort ;
39
42
}
40
- else {
41
- if ( algo === 'BubbleSort' ) {
42
- one = new BubbleSort ( ) ;
43
- classOne = BubbleSort ;
44
- }
45
- else if ( algo === 'SelectionSort' ) {
46
- one = new SelectionSort ( ) ;
47
- classOne = SelectionSort ;
48
- }
49
- else if ( algo === 'ExchangeSort' ) {
50
- one = new ExchangeSort ( ) ;
51
- classOne = ExchangeSort ;
52
- }
53
- else if ( algo === 'InsertionSort' ) {
54
- one = new InsertionSort ( ) ;
55
- classOne = InsertionSort ;
56
- }
57
- else if ( algo === 'ShakerSort' ) {
58
- one = new ShakerSort ( ) ;
59
- classOne = ShakerSort ;
60
- }
61
- else if ( algo === 'OddEvenSort' ) {
62
- one = new OddEvenSort ( ) ;
63
- classOne = OddEvenSort ;
64
- }
65
- else {
66
- window . alert ( '演算法系統錯誤,\n請按 F5 重新整理系統,再次使用。' ) ;
67
- // refresh();
68
- }
69
-
70
- allEnable ( [ goBtn ] )
43
+ else if ( algo === 'SelectionSort' ) {
44
+ one = new SelectionSort ( ) ;
45
+ classOne = SelectionSort ;
71
46
}
47
+ else if ( algo === 'ExchangeSort' ) {
48
+ one = new ExchangeSort ( ) ;
49
+ classOne = ExchangeSort ;
50
+ }
51
+ else if ( algo === 'InsertionSort' ) {
52
+ one = new InsertionSort ( ) ;
53
+ classOne = InsertionSort ;
54
+ }
55
+ else if ( algo === 'ShakerSort' ) {
56
+ one = new ShakerSort ( ) ;
57
+ classOne = ShakerSort ;
58
+ }
59
+
60
+ allEnable ( [ goBtn ] )
72
61
}
73
- catch ( e ) {
74
- }
62
+
75
63
}
76
64
77
65
function clearInputDashBoard ( ) {
@@ -133,7 +121,7 @@ function inputInvalid(entryNum , mspfNum){
133
121
}
134
122
return false ;
135
123
}
136
-
124
+
137
125
function prepareForRun ( ) {
138
126
one . entryNum = isCountInputValid ( parseInt ( countInput . value , 10 ) ) ;
139
127
one . milliSecPerFrame = isMspfInputValid ( parseInt ( mspfInput . value , 10 ) ) ;
0 commit comments