Looks nicer
This commit is contained in:
parent
5112113aae
commit
ab08d745a1
6 changed files with 279 additions and 79 deletions
|
|
@ -1,35 +1,6 @@
|
|||
export class Application {
|
||||
constructor() {
|
||||
this.addTopHandlers()
|
||||
this.moveRecords()
|
||||
}
|
||||
|
||||
moveRecords() {
|
||||
const records = Array.from(document.querySelectorAll('.record'))
|
||||
|
||||
records.sort((a, b) => {
|
||||
if (a.innerText < b.innerText) return 1
|
||||
if (a.innerText > b.innerText) return -1
|
||||
return 0
|
||||
})
|
||||
|
||||
for (const r of records) {
|
||||
const subTops = document.querySelectorAll(`.top[data-top="${r.dataset.top}"] + .type`)
|
||||
if (subTops === null) {
|
||||
continue
|
||||
}
|
||||
|
||||
let lastSubTop = subTops.item(subTops.length - 1)
|
||||
if (lastSubTop === null) {
|
||||
lastSubTop = document.querySelector(`.top[data-self="${r.dataset.top}"] + .type`)
|
||||
}
|
||||
|
||||
if (lastSubTop !== null) {
|
||||
const other = Array.from(document.querySelectorAll(`[data-i="${r.dataset.i}"]`))
|
||||
console.log(other)
|
||||
lastSubTop.after(...other)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addTopHandlers() {
|
||||
|
|
@ -39,10 +10,40 @@ export class Application {
|
|||
|
||||
handlerTop(event) {
|
||||
const topEl = event.target.closest('.top')
|
||||
console.log(topEl.dataset.self)
|
||||
|
||||
const records = document.querySelectorAll(`.record[data-top="${topEl.dataset.self}"]`)
|
||||
for (const r of records) {
|
||||
r.classList.toggle('show')
|
||||
let records, types, values
|
||||
if (topEl.classList.contains('open')) {
|
||||
records = document.querySelectorAll(`[data-top$="${topEl.dataset.self}"]`)
|
||||
types = document.querySelectorAll(`[data-top$="${topEl.dataset.self}"] + .type`)
|
||||
values = document.querySelectorAll(`[data-top$="${topEl.dataset.self}"] + .type + .value`)
|
||||
|
||||
for (const r of records) {
|
||||
r.classList.remove('show')
|
||||
r.classList.remove('open')
|
||||
}
|
||||
|
||||
for (const r of types)
|
||||
r.classList.remove('show')
|
||||
for (const r of values)
|
||||
r.classList.remove('show')
|
||||
|
||||
topEl.classList.remove('open')
|
||||
} else {
|
||||
records = document.querySelectorAll(`[data-top="${topEl.dataset.self}"]`)
|
||||
types = document.querySelectorAll(`[data-top="${topEl.dataset.self}"] + .type`)
|
||||
values = document.querySelectorAll(`[data-top="${topEl.dataset.self}"] + .type + .value`)
|
||||
|
||||
for (const r of records)
|
||||
r.classList.add('show')
|
||||
for (const r of types)
|
||||
r.classList.add('show')
|
||||
for (const r of values)
|
||||
r.classList.add('show')
|
||||
|
||||
topEl.classList.add('open')
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue