confirm / mopidy-pummeluff

Pummeluff is a Mopidy extension which allows you to control Mopidy via RFID cards
MIT License
15 stars 15 forks source link

Modification to edit tags from the table #30

Open marten-lucas opened 2 months ago

marten-lucas commented 2 months ago

I locally added the function to click on the registry table to edit the tags in the form. But I am not able to create a pull request (noob sry).

here is the modification in the script.js

/*

document.addEventListener('DOMContentLoaded', () => { refreshActionClasses(); refreshRegistry();

const readTagInterval = 1000;
readTag();
setInterval(readTag, readTagInterval);

document.querySelector('form').addEventListener('submit', submitForm);
    // Add event listener to the tbody for click events
    document.querySelector('#tags tbody').addEventListener('click', (event) => {
        // Check if the clicked element or its parent is a tr
        const clickedRow = event.target.closest('tr');
        if (clickedRow) {
            // Extract data from the clicked row
            const cells = clickedRow.querySelectorAll('td');
            const uid = cells[1].textContent;
            const alias = cells[0].textContent;
            const action = cells[2].textContent;
            const parameter = cells[3].textContent;

            // Populate form fields with the extracted data
            document.getElementById('uid').value = uid;
            document.getElementById('alias').value = alias;
            document.getElementById('action').value = action;
            document.getElementById('parameter').value = parameter;
        }
    });
});

Here is my fork: https://github.com/marten-lucas/mopidy-pummeluff

marten-lucas commented 2 months ago

BTW: Thank you for the extension! my son loves the box I made for him using it!