Spaces:
Sleeping
Sleeping
File size: 1,641 Bytes
228bfd8 aa7c58e 228bfd8 935457c 228bfd8 895ccaa 228bfd8 935457c 228bfd8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
async () => {
document.addEventListener('click', function (event) {
let tagItem = event.target.closest('.m5dd_list')
let resultArea = event.target.closest('#m5dd_result')
if (tagItem) {
let labelItem = event.target.closest('span.label')
let upItem = event.target.closest('span.up')
let downItem = event.target.closest('span.down')
let addItem = event.target.closest('span.add')
let decItem = event.target.closest('span.dec')
let actionItem = event.target.closest('span.action')
if (labelItem) {
if (tagItem.classList.contains('use')) {
tagItem.classList.remove('use')
} else {
tagItem.classList.add('use')
}
}
if (upItem) { }
if (downItem) { }
if (addItem) {
let label = tagItem.querySelector('span.label').innerText
tagItem.querySelector('span.label').innerText = `(${label})`
}
if (decItem) {
let label = tagItem.querySelector('span.label').innerText
label = label.replace(/^\s*\(\s*(.+?)\s*\)\s*$/, '$1')
tagItem.querySelector('span.label').innerText = label
}
if (actionItem) {
document.getElementById('m5dd_result').innerText =
Array.from(document.querySelectorAll('.m5dd_list.use>span.label'))
.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
}
})
}
|