/* Open in Val Town: https://www.val.town/x/falken/laser-pixie/code/static/lego-wanted.js */ const forms = document.querySelectorAll('form'); for (const f of forms) { f.addEventListener('submit', function (event) { var thing = event.currentTarget.parentElement.childNodes[2].innerHTML; if (!confirm('Tick off ' + thing + ' ?')) { event.preventDefault(); } }); } const links = document.querySelectorAll('[data-href]'); for (const l of links) { l.addEventListener('click', function (event) { if (event.target.nodeName != 'INPUT') { // not the tick this off link window.open(event.currentTarget.attributes['data-href'].value, 'new'); } }); }