Fix wrong element's dynamic identifier, semicols (#1080)

This commit is contained in:
marcomow 2021-06-17 08:23:37 +03:00 committed by GitHub
parent 10b42525ad
commit fe9ea62f61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,40 +26,40 @@
const form = document.getElementById('form') const form = document.getElementById('form')
const dynamicEvent = e => { const dynamicEvent = e => {
const target = e.target const target = e.target;
gun.get(target.id).put(null) gun.get(target.id).put(null);
target.innerHTML = document.getElementById(target.innerHTML) target.innerHTML = document.getElementById(target.id);
if (target.innerHTML === ' null' || target.innerHTML === ' ' || target.innerHTML === '') { if (target.innerHTML === ' null' || target.innerHTML === ' ' || target.innerHTML === '') {
target.style.display = 'none' target.style.display = 'none';
} else { } else {
target.style.display = 'list-item' target.style.display = 'list-item';
} }
} }
gun.map().on((thought, id) => { gun.map().on((thought, id) => {
parentList.insertAdjacentHTML('beforeend', `<li id =${id}> ${thought}</li>`) parentList.insertAdjacentHTML('beforeend', `<li id =${id}> ${thought}</li>`);
const links = parentList.getElementsByTagName('li') const links = parentList.getElementsByTagName('li');
for (const link of links) { for (const link of links) {
if (link.innerHTML === ' null' || link.innerHTML === ' ' || link.innerHTML === '') { if (link.innerHTML === ' null' || link.innerHTML === ' ' || link.innerHTML === '') {
link.style.display = 'none' link.style.display = 'none';
} else { } else {
link.style.display = 'list-item' link.style.display = 'list-item';
} }
link.ondblclick = dynamicEvent link.ondblclick = dynamicEvent;
} }
}) })
form.addEventListener('submit', e => { form.addEventListener('submit', e => {
e.preventDefault() e.preventDefault();
gun.set(input.value) gun.set(input.value);
input.value = '' input.value = '';
}) })
</script> </script>
</body> </body>
</html> </html>