Transpiled version (3150L) is out of date.
1 | sS hcrud_mergeTables(S table1, S table2, S connector) { |
2 | LS tok1 = htmlTok(table1), tok2 = htmlTok(table2); |
3 | LS tbl1 = first(findContainerTag(tok1, "table")); |
4 | LS tbl2 = first(findContainerTag(tok2, "table")); |
5 | if (tbl1 == null) ret table2; |
6 | if (tbl2 == null) ret table1; |
7 | LLS rows1 = findContainerTag(tbl1, "tr"); |
8 | LLS rows2 = findContainerTag(tbl2, "tr"); |
9 | print("rows1: " + l(rows1) + ", rows2: " + l(rows2)); |
10 | int nRows = max(l(rows1), l(rows2)); |
11 | new LS rows; |
12 | for i to nRows: { |
13 | LS row1 = dropFirstTwoAndLastTwo(get(rows1, i)); |
14 | LS row2 = dropFirstTwoAndLastTwo(get(rows2, i)); |
15 | row2 = dropFirst(row2, indexOfIC(row2, "</td>")+1); // drop the 1., 2., 3. |
16 | rows.add(tr(join(concatLists(row1, ll(td(connector)), row2)))); |
17 | } |
18 | replaceTokens(tbl1, 2, l(tbl1)-2, lines(rows)); |
19 | ret join(tok1); |
20 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030003 |
Snippet name: | hcrud_mergeTables - merge tables side by side (e.g. for gazelle.rocks UserPost CRUD, dev.) |
Eternal ID of this version: | #1030003/7 |
Text MD5: | 321d927f9d5b89d0e762425035180e4f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-28 22:36:27 |
Source code size: | 840 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 206 / 324 |
Version history: | 6 change(s) |
Referenced in: | [show references] |