git repos / oastat_static_web_generator

commit d5e0279e

sago007 · 2025-12-09 17:48
d5e0279e67716c1e30efdfd5e7f1b87b0f49d2aa patch · browse files
parent 345541a740f5318db3007fe5f193d454c9ac355e

Add black background to white chars in names

Changed files

M static_content/js/player-name-colors.js before
diff --git a/static_content/js/player-name-colors.js b/static_content/js/player-name-colors.js index 8b326a1..5f1eda0 100644 --- a/static_content/js/player-name-colors.js +++ b/static_content/js/player-name-colors.js
@@ -38,7 +38,8 @@ function parsePlayerNameColors(name) {
const textBefore = name.substring(lastIndex, match.index);
if (textBefore) {
if (currentColor) {
- result += `<span style="color: ${currentColor}">${escapeHtml(textBefore)}</span>`;
+ const style = getColorStyle(currentColor);
+ result += `<span style="${style}">${escapeHtml(textBefore)}</span>`;
} else {
result += escapeHtml(textBefore);
}
@@ -55,7 +56,8 @@ function parsePlayerNameColors(name) {
const remainingText = name.substring(lastIndex);
if (remainingText) {
if (currentColor) {
- result += `<span style="color: ${currentColor}">${escapeHtml(remainingText)}</span>`;
+ const style = getColorStyle(currentColor);
+ result += `<span style="${style}">${escapeHtml(remainingText)}</span>`;
} else {
result += escapeHtml(remainingText);
}
@@ -65,6 +67,19 @@ function parsePlayerNameColors(name) {
}
/**
+ * Get the style string for a color, adding black background for white text
+ * @param {string} color - The color hex code
+ * @returns {string} CSS style string
+ */
+function getColorStyle(color) {
+ // Add black background for white text to make it visible
+ if (color === '#FFFFFF') {
+ return `color: ${color}; background-color: #000000; padding: 0 2px;`;
+ }
+ return `color: ${color}`;
+}
+
+/**
* Escape HTML special characters
* @param {string} text - Text to escape
* @returns {string} Escaped text