Skip to content

Commit b9d1332

Browse files
author
Henrik jJaven
committed
DooHTML-non-keyed-v0.60.1
1 parent 994a9bd commit b9d1332

File tree

4 files changed

+52
-17
lines changed

4 files changed

+52
-17
lines changed

frameworks/non-keyed/doohtml/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
<link href="/css/currentStyle.css" rel="preload" as="style"/>
77
<link href="/css/currentStyle.css" rel="stylesheet"/>
88
<link href="./js/doo.html.min.js" rel="preload" as="script"/>
9-
<script src="./js/doo.html.min.js"></script>
9+
10+
<script src="./js/doo.html.min.js"></script>
11+
<!-- <script type="module" src="http://localhost:8001/src/js/doo.html.js"></script> -->
1012

1113
<script type="module" src="./js/Main.class.js" defer ></script>
1214
</head>

frameworks/non-keyed/doohtml/js/Main.class.js

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie"
88

99
const lenA = adjectives.length, lenB = colours.length, lenC = nouns.length
1010

11+
import Timer from './doo.timer.js'
12+
1113
Doo.define(
1214
class Main extends Doo {
1315
constructor() {
@@ -69,25 +71,57 @@ Doo.define(
6971
run() {
7072
this.data.rows = this.buildData()
7173
this.renderTable()
74+
if (this.tbody.childNodes.length > this.data.rows.length) {
75+
this.tbody.textContent = ''
76+
}
77+
78+
}
79+
run(e) {
80+
Timer.start('tot')
81+
this.data.rows = this.buildData()
82+
if (this.tbody.childNodes.length > this.data.rows.length) {
83+
this.tbody.textContent = ''
84+
}
85+
this.renderTable()
86+
// e.target.blur()
87+
Timer.stop('tot')
7288
}
7389

74-
add() {
90+
add(e) {
91+
Timer.start('tot')
7592
let startRow = this.data.rows.length
7693
this.data.rows = this.data.rows.concat(this.buildData())
7794
this.renderTable(this.data.rows, startRow)
78-
}
95+
Timer.stop('tot')
96+
97+
}
7998

80-
runLots() {
99+
100+
runLots(e) {
101+
this.data.rows = this.buildData(10000)
102+
if (this.tbody.childNodes.length > this.data.rows.length) {
103+
this.tbody.textContent = ''
104+
}
105+
this.renderTable()
106+
}
107+
108+
runLots(e) {
109+
Timer.start('tot')
81110
this.data.rows = this.buildData(10000)
111+
if (this.tbody.childNodes.length > this.data.rows.length) {
112+
this.tbody.textContent = ''
113+
}
82114
this.renderTable()
115+
// e.target.blur()
116+
Timer.stop('tot')
83117
}
84118

85-
update() {
86-
let tr = this.tbody.querySelectorAll('tr')
119+
update(e) {
120+
Timer.start('tot')
87121
for (let i=0, len = this.data.rows.length;i<len;i+=10) {
88-
this.data.rows[i].label += ' !!!';
89-
tr[i].childNodes[1].childNodes[0].textContent = this.data.rows[i].label
122+
this.tbody.childNodes[i].childNodes[1].childNodes[0].innerText = this.data.rows[i].label += ' !!!'
90123
}
124+
Timer.stop('tot')
91125
}
92126

93127
select(elem) {
@@ -118,25 +152,24 @@ Doo.define(
118152

119153
this.tbody.insertBefore(node2, node1)
120154
this.tbody.insertBefore(node1, this.tbody.childNodes[999])
121-
122155
}
123156
}
124157

125158
addEventListeners() {
126159
document.getElementById("main").addEventListener('click', e => {
127160
e.preventDefault();
128161
if (e.target.matches('#runlots')) {
129-
this.runLots();
162+
this.runLots(e);
130163
} else if (e.target.matches('#run')) {
131-
this.run();
164+
this.run(e);
132165
} else if (e.target.matches('#add')) {
133-
this.add();
166+
this.add(e);
134167
} else if (e.target.matches('#update')) {
135-
this.update();
168+
this.update(e);
136169
} else if (e.target.matches('#clear')) {
137170
this.clear();
138171
} else if (e.target.matches('#swaprows')) {
139-
this.swapRows();
172+
this.swapRows(e);
140173
}
141174
})
142175
}

0 commit comments

Comments
 (0)