Vibe Google Analytics
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Text.RegularExpressions;
|
||||
using Chrono.Model;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Shared.Services;
|
||||
|
||||
public class CardRenderingService
|
||||
{
|
||||
private readonly List<string> _cardNames;
|
||||
private readonly Dictionary<string, CardData> _cardLookup;
|
||||
private readonly List<string> _cardNames;
|
||||
private readonly Regex _nameRegex;
|
||||
|
||||
public CardRenderingService()
|
||||
@@ -33,7 +33,7 @@ public class CardRenderingService
|
||||
{
|
||||
return builder =>
|
||||
{
|
||||
int sequence = 0;
|
||||
var sequence = 0;
|
||||
var paragraphs = description.Split('\n', StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (var paragraph in paragraphs)
|
||||
@@ -41,31 +41,27 @@ public class CardRenderingService
|
||||
builder.OpenElement(sequence++, "p");
|
||||
|
||||
var matches = _nameRegex.Matches(paragraph);
|
||||
int lastIndex = 0;
|
||||
var lastIndex = 0;
|
||||
|
||||
foreach (Match match in matches)
|
||||
{
|
||||
if (match.Index > lastIndex)
|
||||
{
|
||||
builder.AddContent(sequence++, paragraph.Substring(lastIndex, match.Index - lastIndex));
|
||||
}
|
||||
|
||||
var cardName = match.Value;
|
||||
var card = LookupCard(cardName);
|
||||
|
||||
builder.OpenElement(sequence++, "button");
|
||||
builder.AddAttribute(sequence++, "class", "inline-card-btn");
|
||||
builder.AddAttribute(sequence++, "onclick", EventCallback.Factory.Create(this, () => onCardClick(card)));
|
||||
builder.AddAttribute(sequence++, "onclick",
|
||||
EventCallback.Factory.Create(this, () => onCardClick(card)));
|
||||
builder.AddContent(sequence++, cardName);
|
||||
builder.CloseElement();
|
||||
|
||||
lastIndex = match.Index + match.Length;
|
||||
}
|
||||
|
||||
if (lastIndex < paragraph.Length)
|
||||
{
|
||||
builder.AddContent(sequence++, paragraph.Substring(lastIndex));
|
||||
}
|
||||
if (lastIndex < paragraph.Length) builder.AddContent(sequence++, paragraph.Substring(lastIndex));
|
||||
|
||||
builder.CloseElement();
|
||||
}
|
||||
@@ -76,4 +72,4 @@ public class CardRenderingService
|
||||
{
|
||||
return _cardLookup.GetValueOrDefault(cardName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user