|
92 | 92 | const g = parseInt(fullHex.substring(2, 4), 16) || 0; |
93 | 93 | const b = parseInt(fullHex.substring(4, 6), 16) || 0; |
94 | 94 | const screensaverBackdrop = `rgba(${r}, ${g}, ${b}, ${safeAlpha})`; |
95 | | - const eventText = [config.event.textLeft, config.event.textRight].filter(Boolean).join(' ').trim(); |
| 95 | + const buildEventText = () => { |
| 96 | + const left = config.event.textLeft || ''; |
| 97 | + const right = config.event.textRight || ''; |
| 98 | + const symbolClass = (config.event.symbol || ''); |
| 99 | + const symbol = symbolClass ? `<i class="fa ${symbolClass}" aria-hidden="true"></i>` : ''; |
| 100 | + return [left, symbol, right].filter(Boolean).join(' ').trim(); |
| 101 | + }; |
| 102 | + |
| 103 | + const eventText = buildEventText(); |
96 | 104 | const showEvent = screensaverMode === 'gallery'; |
97 | 105 | const hasScreensaver = !!screensaverText; |
98 | 106 | const hasEvent = showEvent && !!eventText; |
|
108 | 116 | textBottom.hide().text(''); |
109 | 117 | }; |
110 | 118 |
|
111 | | - const setSlot = (text) => { |
| 119 | + const applyContent = ($el, content, isHtml = false) => { |
| 120 | + if (isHtml) { |
| 121 | + $el.html(content); |
| 122 | + } else { |
| 123 | + $el.text(content); |
| 124 | + } |
| 125 | + }; |
| 126 | + |
| 127 | + const setSlot = (content, isHtml = false) => { |
112 | 128 | resetSlots(); |
113 | 129 | [textTop, textCenter, textBottom].forEach(($el) => { |
114 | 130 | $el.css('background', screensaverBackdrop); |
115 | 131 | }); |
116 | 132 | if (showCenter) { |
117 | | - textCenter.text(text).show(); |
| 133 | + applyContent(textCenter, content, isHtml); |
| 134 | + textCenter.show(); |
118 | 135 | return; |
119 | 136 | } |
120 | 137 | if (showTop) { |
121 | | - textTop.text(text).show(); |
| 138 | + applyContent(textTop, content, isHtml); |
| 139 | + textTop.show(); |
122 | 140 | } |
123 | 141 | if (showBottom) { |
124 | | - textBottom.text(text).show(); |
| 142 | + applyContent(textBottom, content, isHtml); |
| 143 | + textBottom.show(); |
125 | 144 | } |
126 | 145 | }; |
127 | 146 |
|
128 | 147 | if (hasScreensaver && hasEvent) { |
129 | 148 | if (screensaverFlip) { |
130 | 149 | setSlot(screensaverText); |
131 | 150 | if (showTop && showBottom) { |
132 | | - textBottom.text(eventText).show(); |
| 151 | + applyContent(textBottom, eventText, true); |
| 152 | + textBottom.show(); |
133 | 153 | } else if (showCenter || showTop) { |
134 | | - textBottom.text(eventText).show(); |
| 154 | + applyContent(textBottom, eventText, true); |
| 155 | + textBottom.show(); |
135 | 156 | } else { |
136 | | - textTop.text(eventText).show(); |
| 157 | + applyContent(textTop, eventText, true); |
| 158 | + textTop.show(); |
137 | 159 | } |
138 | 160 | } else { |
139 | | - setSlot(eventText); |
| 161 | + setSlot(eventText, true); |
140 | 162 | if (showTop && showBottom) { |
141 | | - textBottom.text(screensaverText).show(); |
| 163 | + applyContent(textBottom, screensaverText); |
| 164 | + textBottom.show(); |
142 | 165 | } else if (showCenter || showTop) { |
143 | | - textBottom.text(screensaverText).show(); |
| 166 | + applyContent(textBottom, screensaverText); |
| 167 | + textBottom.show(); |
144 | 168 | } else { |
145 | | - textTop.text(screensaverText).show(); |
| 169 | + applyContent(textTop, screensaverText); |
| 170 | + textTop.show(); |
146 | 171 | } |
147 | 172 | } |
148 | 173 | } else { |
149 | 174 | const singleText = hasScreensaver ? screensaverText : hasEvent ? eventText : ''; |
150 | 175 | if (singleText) { |
151 | | - setSlot(singleText); |
| 176 | + setSlot(singleText, hasEvent); |
152 | 177 | } else { |
153 | 178 | resetSlots(); |
154 | 179 | } |
|
0 commit comments