- Check for color 0 in JS

- Fix error with frag usage
This commit is contained in:
Infi
2024-08-30 14:18:33 +02:00
parent c7b596289e
commit c4d5bfaf36
2 changed files with 12 additions and 4 deletions
@@ -65,6 +65,8 @@ public struct MessageTemplate()
/// <summary> /// <summary>
/// Used for text and url /// Used for text and url
///
/// Ignore if 0!
/// </summary> /// </summary>
[JsonProperty("color")] public uint Color; [JsonProperty("color")] public uint Color;
+10 -4
View File
@@ -147,7 +147,7 @@
const frag = document.createDocumentFragment(); const frag = document.createDocumentFragment();
for( const template of templates ) { for( const template of templates ) {
const spanElement = frag.createElement('span'); const spanElement = document.createElement('span');
switch (template.payload) { switch (template.payload) {
case 'text': case 'text':
this.processTextTemplate(template, spanElement); this.processTextTemplate(template, spanElement);
@@ -165,7 +165,7 @@
continue; continue;
} }
frag.appendChild(this.processTemplate(template)); frag.appendChild(spanElement);
} }
return frag; return frag;
@@ -173,7 +173,10 @@
processTextTemplate(template, spanContent) { processTextTemplate(template, spanContent) {
spanContent.innerText = template.content; spanContent.innerText = template.content;
this.processColor(template, spanContent); if (template.color !== 0)
{
this.processColor(template, spanContent);
}
} }
processUrlTemplate(template, spanContent) { processUrlTemplate(template, spanContent) {
@@ -182,7 +185,10 @@
urlElement.href = encodeURI(template.content); urlElement.href = encodeURI(template.content);
urlElement.target = '_blank' urlElement.target = '_blank'
this.processColor(template, spanContent); if (template.color !== 0)
{
this.processColor(template, spanContent);
}
} }
// converts a RGBA uint number to components // converts a RGBA uint number to components