{
function choose(chooses) {
var index = Math.floor(Math.random() * chooses.length);
return chooses[index];
}
const div = html`
<center><div id="app">
<span>-------> <button id="button" style="background-color:#e95420; color:white;" type="button">???????</button> <-------</span>
<h2 id="ijbol"></h2>
</div></center>
`
const container = d3.select(div);
const button = container.select('#button');
const text = container.select('#ijbol');
const color = d3.scaleOrdinal(d3.schemeDark2);
button.on('click', () => {
var sentence = 'i'
const j = choose(['verbs', 'adverbs'])
console.log(sentence, j)
if (j == 'verbs') {
var b = 'conjunctions'
var o = 'adverbs'
var l = 'adverbs'
console.log(b, o, l)
} else {
var b = 'verbs'
var o = choose(['adjectives', 'nouns'])
var l = 'nouns'
console.log(b, o, l)
}
sentence += ` ${choose(options['j'][j])}`
sentence += ` ${choose(options['b'][b])}`
sentence += ` ${choose(options['o'][o])}`
if (o == 'nouns') {
sentence += "'s"
}
sentence += ` ${choose(options['l'][l])}`
console.log(sentence)
text.html('')
text.selectAll(null)
.data(sentence.split(' '))
.enter()
.append('span')
.text(d => `${d} `)
.style('color', d => color(d))
}
)
return container.node()
}