@@ -41,25 +41,20 @@ const { activeProgram, channelId, channelName } = Astro.props;
41
41
selector: string,
42
42
attribute: string,
43
43
defaultValue: string = "0",
44
- detailProperty? : string,
44
+ detailProperty: string,
45
45
): void {
46
- // Use the specified detail property or fall back to the attribute name without 'data-' prefix
47
- const localStorageKey = detailProperty || attribute.replace("data-", "");
48
-
49
- const savedValue = localStorage.getItem(localStorageKey) || defaultValue;
46
+ const savedValue = localStorage.getItem(detailProperty) || defaultValue;
50
47
setAttributeOnElement(selector, attribute, savedValue);
51
48
}
52
49
53
50
function createEventListener(
54
51
eventName: string,
55
52
selector: string,
56
53
attribute: string,
57
- detailProperty? : string,
54
+ detailProperty: string,
58
55
): void {
59
56
document.addEventListener(eventName, ((e: CustomEvent) => {
60
- // Use the specified detail property or fall back to the attribute name without 'data-' prefix
61
- const propertyName = detailProperty || attribute.replace("data-", "");
62
- const value = e.detail[propertyName];
57
+ const value = e.detail[detailProperty];
63
58
setAttributeOnElement(selector, attribute, value);
64
59
}) as EventListener);
65
60
}
@@ -70,7 +65,7 @@ const { activeProgram, channelId, channelName } = Astro.props;
70
65
selector: ".scanlines",
71
66
attribute: "data-active",
72
67
defaultValue: "true",
73
- detailProperty: "enabled ",
68
+ detailProperty: "scanlines ",
74
69
},
75
70
{
76
71
event: "brightnessChange",
@@ -111,6 +106,7 @@ const { activeProgram, channelId, channelName } = Astro.props;
111
106
setting.selector,
112
107
setting.attribute,
113
108
setting.defaultValue,
109
+ setting.detailProperty,
114
110
);
115
111
});
116
112
0 commit comments