Spaces:
Running
Running
document.addEventListener('click', function (event) { | |
let tagItem = event.target.closest('.m5dd_list') | |
let resultArea = event.target.closest('#m5dd_result') | |
if (tagItem) { | |
if (tagItem.classList.contains('use')) { | |
tagItem.classList.remove('use') | |
} else { | |
tagItem.classList.add('use') | |
} | |
document.getElementById('m5dd_result').innerText = | |
Array.from(document.querySelectorAll('.m5dd_list.use>span:nth-child(1)')) | |
.map(v => v.innerText) | |
.join(', ') | |
} else if (resultArea) { | |
const selection = window.getSelection() | |
selection.removeAllRanges() | |
const range = document.createRange() | |
range.selectNodeContents(resultArea) | |
selection.addRange(range) | |
} else { | |
return | |
} | |
}) | |