@@ -2,124 +2,88 @@ import { h, app } from "hyperapp"
2
2
import { state , actions } from "./store"
3
3
import RowsView from "./rowsView"
4
4
5
- let startTime
6
- let lastMeasure
7
-
8
- function startMeasure ( name , cb ) {
9
- startTime = performance . now ( )
10
- lastMeasure = name
11
- cb ( )
12
- }
13
-
14
- function stopMeasure ( ) {
15
- const last = lastMeasure
16
-
17
- if ( lastMeasure ) {
18
- window . setTimeout (
19
- function metaStopMeasure ( ) {
20
- lastMeasure = null
21
- const stop = performance . now ( )
22
- const duration = 0
23
- console . log ( last + " took " + ( stop - startTime ) )
24
- } ,
25
- 0
26
- )
27
- }
28
- }
29
-
30
- function view ( state , actions ) {
31
- stopMeasure ( )
32
-
33
- return (
34
- < div class = "container" >
35
- < div class = "jumbotron" >
36
- < div class = "row" >
37
- < div class = "col-md-6" >
38
- < h1 > HyperApp</ h1 >
39
- </ div >
40
- < div class = "col-md-6" >
41
- < div class = "row" >
42
- < div class = "col-sm-6 smallpad" >
43
- < button
44
- type = "button"
45
- class = "btn btn-primary btn-block"
46
- id = "run"
47
- onclick = { _ =>
48
- startMeasure ( "run" , actions . run ) } >
49
- Create 1,000 rows
50
- </ button >
51
- </ div >
52
- < div class = "col-sm-6 smallpad" >
53
- < button
54
- type = "button"
55
- class = "btn btn-primary btn-block"
56
- id = "runlots"
57
- onclick = { _ =>
58
- startMeasure (
59
- "runLots" ,
60
- actions . runLots
61
- ) } >
62
- Create 10,000 rows
63
- </ button >
64
- </ div >
65
- < div class = "col-sm-6 smallpad" >
66
- < button
67
- type = "button"
68
- class = "btn btn-primary btn-block"
69
- id = "add"
70
- onclick = { _ =>
71
- startMeasure ( "add" , actions . add ) } >
72
- Append 1,000 rows
73
- </ button >
74
- </ div >
75
- < div class = "col-sm-6 smallpad" >
76
- < button
77
- type = "button"
78
- class = "btn btn-primary btn-block"
79
- id = "update"
80
- onclick = { _ =>
81
- startMeasure ( "update" , actions . update ) } >
82
- Update every 10th row
83
- </ button >
84
- </ div >
85
- < div class = "col-sm-6 smallpad" >
86
- < button
87
- type = "button"
88
- class = "btn btn-primary btn-block"
89
- id = "clear"
90
- onclick = { _ =>
91
- startMeasure ( "clear" , actions . clear ) } >
92
- Clear
93
- </ button >
94
- </ div >
95
- < div class = "col-sm-6 smallpad" >
96
- < button
97
- type = "button"
98
- class = "btn btn-primary btn-block"
99
- id = "swaprows"
100
- onclick = { _ =>
101
- startMeasure (
102
- "swapRows" ,
103
- actions . swapRows
104
- ) } >
105
- Swap Rows
106
- </ button >
107
- </ div >
108
- </ div >
109
- </ div >
110
- </ div >
5
+ function view ( state ) {
6
+ return (
7
+ < div class = "container" >
8
+ < div class = "jumbotron" >
9
+ < div class = "row" >
10
+ < div class = "col-md-6" >
11
+ < h1 > HyperApp</ h1 >
12
+ </ div >
13
+ < div class = "col-md-6" >
14
+ < div class = "row" >
15
+ < div class = "col-sm-6 smallpad" >
16
+ < button
17
+ type = "button"
18
+ class = "btn btn-primary btn-block"
19
+ id = "run"
20
+ onclick = { actions . run }
21
+ >
22
+ Create 1,000 rows
23
+ </ button >
24
+ </ div >
25
+ < div class = "col-sm-6 smallpad" >
26
+ < button
27
+ type = "button"
28
+ class = "btn btn-primary btn-block"
29
+ id = "runlots"
30
+ onclick = { actions . runLots }
31
+ >
32
+ Create 10,000 rows
33
+ </ button >
34
+ </ div >
35
+ < div class = "col-sm-6 smallpad" >
36
+ < button
37
+ type = "button"
38
+ class = "btn btn-primary btn-block"
39
+ id = "add"
40
+ onclick = { actions . add }
41
+ >
42
+ Append 1,000 rows
43
+ </ button >
44
+ </ div >
45
+ < div class = "col-sm-6 smallpad" >
46
+ < button
47
+ type = "button"
48
+ class = "btn btn-primary btn-block"
49
+ id = "update"
50
+ onclick = { actions . update }
51
+ >
52
+ Update every 10th row
53
+ </ button >
54
+ </ div >
55
+ < div class = "col-sm-6 smallpad" >
56
+ < button
57
+ type = "button"
58
+ class = "btn btn-primary btn-block"
59
+ id = "clear"
60
+ onclick = { actions . clear }
61
+ >
62
+ Clear
63
+ </ button >
64
+ </ div >
65
+ < div class = "col-sm-6 smallpad" >
66
+ < button
67
+ type = "button"
68
+ class = "btn btn-primary btn-block"
69
+ id = "swaprows"
70
+ onclick = { actions . swapRows }
71
+ >
72
+ Swap Rows
73
+ </ button >
74
+ </ div >
111
75
</ div >
112
- < table class = "table table-hover table-striped test-data" >
113
- < tbody >
114
- < RowsView state = { state } actions = { actions } />
115
- </ tbody >
116
- </ table >
117
- < span
118
- class = "preloadicon glyphicon glyphicon-remove"
119
- aria-hidden = "true"
120
- />
76
+ </ div >
121
77
</ div >
122
- )
78
+ </ div >
79
+ < table class = "table table-hover table-striped test-data" >
80
+ < tbody >
81
+ < RowsView data = { state . data } selected = { state . selected } />
82
+ </ tbody >
83
+ </ table >
84
+ < span class = "preloadicon glyphicon glyphicon-remove" aria-hidden = "true" />
85
+ </ div >
86
+ )
123
87
}
124
88
125
- app ( state , actions , view , document . getElementById ( "main" ) )
89
+ app ( { init : state , view, node : document . getElementById ( "main" ) } )
0 commit comments