File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ export class TableData {
2+ private raw : HTMLTableElement ;
3+
4+ constructor ( element : HTMLTableElement ) {
5+ this . raw = element ;
6+ }
7+
8+ headers_element ( ) : HTMLTableHeaderCellElement [ ] {
9+ const headers_element = Array . from ( this . raw . querySelectorAll <
10+ HTMLTableHeaderCellElement
11+ > (
12+ "thead > tr:nth-of-type(1) > th" ,
13+ ) ) ;
14+ return headers_element ;
15+ }
16+
17+ headers_text ( ) : string [ ] {
18+ const headers_text = this . headers_element ( ) . map ( ( e ) => e . innerText ) ;
19+ return headers_text ;
20+ }
21+
22+ headers_action_element ( ) : HTMLTableHeaderCellElement [ ] {
23+ const headers_element = Array . from ( this . raw . querySelectorAll <
24+ HTMLTableHeaderCellElement
25+ > (
26+ "thead > tr:nth-of-type(2) > th" ,
27+ ) ) ;
28+ return headers_element ;
29+ }
30+
31+ cells_element ( ) {
32+ const rows_element = Array . from ( this . raw . querySelectorAll ( "tbody > tr" ) ) ;
33+ const cells_element = rows_element . map ( ( e ) =>
34+ Array . from ( e . querySelectorAll ( "td" ) )
35+ ) ;
36+
37+ return cells_element ;
38+ }
39+
40+ cells_text ( ) {
41+ const cells_element = this . cells_element ( ) ;
42+ const cells_text = cells_element . map ( ( row ) =>
43+ row . map ( ( cell ) => cell . innerText )
44+ ) ;
45+
46+ return cells_text ;
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments