initial select-options setup...
This commit is contained in:
parent
085fe055ae
commit
82e429689a
1 changed files with 23 additions and 5 deletions
|
@ -25,7 +25,16 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateFrontMatter(frontmatter, path, relpermalink, protocol) {
|
function couldHave(i, couldhave) {
|
||||||
|
couldhave.push(i)
|
||||||
|
let select = document.querySelector('select')
|
||||||
|
select.innerHTML = ""
|
||||||
|
couldhave.forEach((c)=> {
|
||||||
|
select.options[select.options.length] = new Option(c,c)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateFrontMatter(frontmatter, path, relpermalink, protocol, couldhave) {
|
||||||
let dvm = document.querySelector('form')
|
let dvm = document.querySelector('form')
|
||||||
|
|
||||||
var hiddenRelPath = document.createElement('input')
|
var hiddenRelPath = document.createElement('input')
|
||||||
|
@ -60,6 +69,7 @@
|
||||||
removeItem.setAttribute('type', 'button')
|
removeItem.setAttribute('type', 'button')
|
||||||
removeItem.addEventListener('click', (e) => {
|
removeItem.addEventListener('click', (e) => {
|
||||||
e.target.parentNode.remove()
|
e.target.parentNode.remove()
|
||||||
|
couldHave(e.target.parentNode.querySelector("input").value, couldhave)
|
||||||
disableButtons()
|
disableButtons()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -69,7 +79,6 @@
|
||||||
moveUpItem.setAttribute('type', 'button')
|
moveUpItem.setAttribute('type', 'button')
|
||||||
moveUpItem.classList.add('buttonup')
|
moveUpItem.classList.add('buttonup')
|
||||||
moveUpItem.addEventListener('click', (e) => {
|
moveUpItem.addEventListener('click', (e) => {
|
||||||
e.currentTarget.disabled = false;
|
|
||||||
let lb = document.querySelector(".listbox")
|
let lb = document.querySelector(".listbox")
|
||||||
lb.insertBefore(e.currentTarget.parentNode, e.currentTarget.parentNode.previousSibling)
|
lb.insertBefore(e.currentTarget.parentNode, e.currentTarget.parentNode.previousSibling)
|
||||||
disableButtons()
|
disableButtons()
|
||||||
|
@ -79,7 +88,6 @@
|
||||||
moveDownItem.setAttribute('type', 'button')
|
moveDownItem.setAttribute('type', 'button')
|
||||||
moveDownItem.classList.add('buttondown')
|
moveDownItem.classList.add('buttondown')
|
||||||
moveDownItem.addEventListener('click', (e) => {
|
moveDownItem.addEventListener('click', (e) => {
|
||||||
e.currentTarget.disabled = false;
|
|
||||||
let lb = document.querySelector(".listbox")
|
let lb = document.querySelector(".listbox")
|
||||||
let lblength = lb.children.length
|
let lblength = lb.children.length
|
||||||
lb.insertBefore(e.currentTarget.parentNode, e.currentTarget.parentNode.nextSibling.nextSibling)
|
lb.insertBefore(e.currentTarget.parentNode, e.currentTarget.parentNode.nextSibling.nextSibling)
|
||||||
|
@ -103,11 +111,21 @@
|
||||||
input.classList.add("hasinput")
|
input.classList.add("hasinput")
|
||||||
input.title = "[remove on click]"
|
input.title = "[remove on click]"
|
||||||
input.value = i
|
input.value = i
|
||||||
// input.addEventListener('focus', (e) => { e.target.parentNode.removeChild(e.target) })
|
let r = couldhave.indexOf(i)
|
||||||
|
if (r != -1) {
|
||||||
|
couldhave.splice(r, 1)
|
||||||
|
}
|
||||||
itemLine.prepend(input)
|
itemLine.prepend(input)
|
||||||
itemLine.prepend(removeItem)
|
itemLine.prepend(removeItem)
|
||||||
listBox.prepend(itemLine)
|
listBox.prepend(itemLine)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let select = document.createElement('select')
|
||||||
|
couldhave.forEach((c)=> {
|
||||||
|
select.options[select.options.length] = new Option(c,c)
|
||||||
|
})
|
||||||
|
listBox.append(select)
|
||||||
|
|
||||||
dvm.prepend(listBox)
|
dvm.prepend(listBox)
|
||||||
let label = document.createElement('label')
|
let label = document.createElement('label')
|
||||||
label.setAttribute('for', `${fm}[]`)
|
label.setAttribute('for', `${fm}[]`)
|
||||||
|
@ -148,7 +166,7 @@
|
||||||
}
|
}
|
||||||
path = repo.path;
|
path = repo.path;
|
||||||
console.log(JSON.stringify(repo))
|
console.log(JSON.stringify(repo))
|
||||||
generateFrontMatter(repo.frontmatter, path, repo.relpermalink, document.location.protocol.substring(0,4))
|
generateFrontMatter(repo.frontmatter, path, repo.relpermalink, document.location.protocol.substring(0,4), repo.couldhave)
|
||||||
}
|
}
|
||||||
el.src = `../js/repo/${location.hash.substring(1)}.js`
|
el.src = `../js/repo/${location.hash.substring(1)}.js`
|
||||||
document.body.appendChild(el)
|
document.body.appendChild(el)
|
||||||
|
|
Loading…
Add table
Reference in a new issue