Commit 7af667d5 authored by Evan Hahn's avatar Evan Hahn

WIP

parent 14f5ce73
......@@ -2,9 +2,11 @@
* b = body
* c = columns
* d = re-render
* g = new column
* h = new row
* p = data types
* r = rows
* t = <table>
* p = data types
*/
/* eslint-disable no-undef */
......@@ -28,9 +30,26 @@ r = Array(10).fill(0).map((_, index) => ([
Math.random() * 1000
]))
// Add a new column
g = () => {
c.push(['Column', p[0]])
r.map((row) => {
row.push('')
})
d()
}
// Add a new row
h = () => {
r.push(Array(c.length).fill(null))
d()
}
// Initial render
document.head.innerHTML += '<style>td,th{padding:1em;border:1px solid #000}.b{cursor:pointer;background:#ddf}</style>'
document.head.innerHTML += '<style>td,th{padding:1em;border:1px solid #000}.b{cursor:pointer;background:#ddf}input{font:inherit;width:100px}</style>'
b.innerHTML += '<table id=t style="font-family:sans-serif;border-collapse:collapse">'
......@@ -38,10 +57,10 @@ b.innerHTML += '<table id=t style="font-family:sans-serif;border-collapse:collap
;(d = () => {
let head = document.createElement('tr')
c.map((column) => {
head.innerHTML += `<th>${column[0]} (${column[1][0]})`
c.map((column, columnIndex) => {
head.innerHTML += `<th><input value="${column[0]}" onblur=c(this,${columnIndex})> (${column[1][0]})`
})
head.innerHTML += '<th class=b>+'
head.innerHTML += '<th class=b onclick=g()>+'
t.innerHTML = ''
t.appendChild(head)
......@@ -57,5 +76,5 @@ b.innerHTML += '<table id=t style="font-family:sans-serif;border-collapse:collap
t.appendChild(rowEl)
})
t.innerHTML += `<tr><th class=b colspan=${c.length}>+</th><td>`
t.innerHTML += `<tr><th class=b colspan=${c.length} onclick=h()>+</th><td>`
})()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment