Skip to content

Commit 5e5547f

Browse files
author
Henrik jJaven
committed
testing 0.70.1
1 parent 8ef94eb commit 5e5547f

File tree

11 files changed

+522
-244
lines changed

11 files changed

+522
-244
lines changed

frameworks/keyed/doohtml/index.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
<title>DooHTML</title>
66
<link href="/css/currentStyle.css" rel="preload" as="style"/>
77
<link href="/css/currentStyle.css" rel="stylesheet"/>
8-
<link href="./js/doo.html.min.js" rel="preload" as="script"/>
9-
<script src="./js/doo.html.min.js"></script>
10-
<!-- <script type="module" src="http://localhost:8001/src/js/doo.html.js"></script> -->
11-
<script type="module" src="./js/Main.class.timer.js" defer ></script>
8+
<!-- <link href="./js/doo.html.js" rel="preload" as="script"/> -->
9+
<!-- <link href="./js/doo.html.0.60.1.js" rel="preload" as="script"/> -->
10+
<!-- <script type="module" src="./js/doo.html.js"></script> -->
11+
<!-- <script type="module" src="./js/doo.html.0.60.1.js"></script> -->
12+
13+
<script type="module" src="http://localhost:8001/src/js/doo.html.js"></script>
14+
<!-- <script type="module" src="./js/Main.class.timer.js" defer ></script> -->
15+
<script type="module" src="./js/Main.class.js" defer ></script>
1216

1317
</head>
1418

frameworks/keyed/doohtml/js/Main.class copy.js

Lines changed: 0 additions & 149 deletions
This file was deleted.

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

Lines changed: 63 additions & 10 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() {
@@ -79,23 +81,73 @@ Doo.define(
7981
}
8082

8183
run() {
84+
8285
this.clear()
8386
this.data.rows = this.buildData()
8487
this.renderTable()
8588

8689
}
8790

91+
run(e) {
92+
Timer.start('tot')
93+
this.clear()
94+
this.data.rows = this.buildData()
95+
this.renderTable()
96+
// e.target.blur()
97+
Timer.stop('tot')
98+
}
99+
100+
88101
add() {
89102
this.data.rows = this.data.rows.concat(this.buildData())
90103
this.renderTable(this.data.rows)
91104
}
105+
// add() {
106+
// // let startRow = this.data.rows.length
107+
// this.data.rows = this.data.rows.concat(this.buildData())
108+
// this.renderTable(this.data.rows, this.data.rows.length)
109+
110+
// }
111+
112+
92113

93114
runLots() {
94115

95116
this.clear()
96117
this.data.rows = this.buildData(10000)
97118
this.renderTable()
98119
}
120+
runLots(e) {
121+
Timer.start('tot')
122+
this.clear()
123+
this.data.rows = this.buildData(10000)
124+
this.renderTable()
125+
e.target.blur()
126+
Timer.stop('tot')
127+
}
128+
renderTable(dataSet=this.data[this.defaultDataSet], start=0) {
129+
let len = dataSet.length - start,
130+
elem = document.createElement('tbody')
131+
elem.innerHTML = this.renderNode(this.place[0], dataSet, start , len)
132+
let tableRows = elem.querySelectorAll('tr'),
133+
newElem
134+
for (let i=0;i<len;i++) {
135+
newElem = this.place[0].appendChild(tableRows.item(i))
136+
newElem.key = dataSet[i].id
137+
}
138+
// newElem = this.place[0].appendChild(tableRows.item(len-1))
139+
// newElem.key = dataSet[len-1].id
140+
141+
// for (let i=len-2;i>=0;i--) {
142+
// newElem = this.place[0].insertBefore(tableRows.item(i), this.place[0].firstChild)
143+
// newElem.key = dataSet[i].id
144+
// }
145+
146+
147+
}
148+
149+
150+
99151

100152
update() {
101153
for (let i=0, len = this.data.rows.length;i<len;i+=10) {
@@ -126,27 +178,28 @@ Doo.define(
126178
}
127179

128180
swapRows() {
129-
if (this.data.rows.length>10) {
130-
let node1 = this.tbody.childNodes[1]
131-
let node2 = this.tbody.childNodes[998]
132-
133-
let row1 = this.data.rows[1];
181+
if (this.data.rows.length > 998) {
182+
let node1 = this.tbody.firstChild.nextSibling,
183+
node2 = node1.nextSibling,
184+
node998 = this.tbody.childNodes[998],
185+
node999 = node998.nextSibling,
186+
row1 = this.data.rows[1]
187+
134188
this.data.rows[1] = this.data.rows[998];
135189
this.data.rows[998] = row1
136190

137-
this.tbody.insertBefore(node2, node1)
138-
this.tbody.insertBefore(node1, this.tbody.childNodes[999])
139-
191+
this.tbody.insertBefore(node998, node2)
192+
this.tbody.insertBefore(node1, node999)
140193
}
141194
}
142195

143196
addEventListeners() {
144197
document.getElementById("main").addEventListener('click', e => {
145198
e.preventDefault()
146199
if (e.target.matches('#runlots')) {
147-
this.runLots()
200+
this.runLots(e)
148201
} else if (e.target.matches('#run')) {
149-
this.run()
202+
this.run(e)
150203
} else if (e.target.matches('#add')) {
151204
this.add()
152205
} else if (e.target.matches('#update')) {

frameworks/keyed/doohtml/js/Main.class.timer.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,9 @@ Doo.define(
7474
if (row) {
7575
this.tbody.removeChild(row)
7676
let idx = this.getIndex(row)
77-
console.log('coolio', idx,this.data.rows.length, this.data.rows[idx].label)
7877
if (idx !== undefined) {
7978
this.data.rows.splice(idx,1)
8079
}
81-
console.log('foolio', this.data.rows.length)
82-
8380
}
8481
}
8582
run(e) {
@@ -106,11 +103,22 @@ Doo.define(
106103
this.data.rows = this.buildData(10000)
107104
this.renderTable()
108105
//e.target.blur()
109-
Timer.start('add')
110-
Timer.stop('add')
111106
Timer.stop('tot')
112107
}
113108

109+
async renderTable(dataSet=this.data[this.defaultDataSet]) {
110+
let len = dataSet.length
111+
let elem = document.createElement('tbody')
112+
elem.innerHTML = this.renderNode(this.place[0], dataSet, 0 , len)
113+
let tableRows = elem.querySelectorAll('tr')
114+
115+
for (let i=0;i<len;i++) {
116+
this.place[0].appendChild(tableRows.item(i))
117+
}
118+
return
119+
}
120+
121+
114122
update(e) {
115123
for (let i=0, len = this.data.rows.length;i<len;i+=10) {
116124
this.tbody.childNodes[i].childNodes[1].childNodes[0].innerText = this.data.rows[i].label += ' !!!'
@@ -136,11 +144,14 @@ Doo.define(
136144

137145
clear(e) {
138146
Timer.start('clear')
147+
139148
this.data.rows = []
149+
// this.data.rows = this.buildData(1)
140150
this.tbody.textContent = ''
151+
this.renderTable()
141152
Timer.stop('clear')
142153
}
143-
154+
/*
144155
swapRows(e) {
145156
if (this.data.rows.length>10) {
146157
let node1 = this.tbody.childNodes[1]
@@ -154,6 +165,24 @@ Doo.define(
154165
this.tbody.insertBefore(node1, this.tbody.childNodes[999])
155166
}
156167
}
168+
*/
169+
swapRows(e) {
170+
if (this.data.rows.length > 998) {
171+
172+
let tmp = this.data.rows[998];
173+
this.rows.data[998] = this.rows.data[1];
174+
this.rows.data[1] = tmp;
175+
176+
let a = this.tbody.firstChild.nextSibling,
177+
b = a.nextSibling,
178+
c = this.tbody.childNodes[998],
179+
d = c.nextSibling;
180+
181+
this.tbody.insertBefore(c, b);
182+
this.tbody.insertBefore(a, d);
183+
}
184+
}
185+
157186

158187
addEventListeners() {
159188
document.getElementById("main").addEventListener('click', e => {

0 commit comments

Comments
 (0)