- Check for color 0 in JS
- Fix error with frag usage
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user