Aircoookie / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!
https://kno.wled.ge
MIT License
14.26k stars 3.04k forks source link

Semi-automated segment naming #3457

Open RadianM opened 8 months ago

RadianM commented 8 months ago

I'm always frustrated when adding new segments and having to name them to keep track of which effects are in which segment. I feel this could be streamlined by automatically setting the segment name to the name of the effect chosen for the segment(s). I appreciate that this might not always be desirable so have a proposal which addresses the issue to a certain extent:

Adding the following three lines at the end of function updateSelectedFx() in index.js...


        if(selectedName.search(/[^a-zA-Z\d\s:]/) != -1) selectedName=selectedName.substring(0, selectedName.search(/[^a-zA-Z\d\s:]/)-1);    //strip flag chars if any
        var segs = gId("segcont").querySelectorAll('.ptxt');    //point to edit text field class
        for (const seg of segs) seg.value=selectedName; //Set edit text field
        }
}

...Thus when the effect is selected, all "checked" segments receive the effect name in the "edit name input field" overwriting the usual placeholder string. This name is then used by default if and when the segment "tick" icon is selected.

blazoncek commented 8 months ago

That would work for all but Scrolling Text effect.

RadianM commented 8 months ago

So maybe this has uncovered a small bug... or maybe not?

I hadn't noticed it before but the same code logic I employed above is also used to hide the map2d and sound sim fields when an effect is not using them. But the querySelectorAll() function used to getElementById returns all segments - not just those with their selection checkboxes ticked. So if some segments do have sound reactive effects, setting just one segment with an effect such as Solid (no sound reactivity) hides all the sound sim fields that might be on show. They are unhidden on re-selecting those segments so it's no big deal.

I guess it'd be necessary to scan each segment for the checkbox to be ticked to ensure it needs to be changed. Not sure how to do that.