UPDATE: New data 4.1.5
Gitea Auto Deploy / Deploy-Container (push) Successful in 45s

This commit is contained in:
2026-03-17 19:32:21 +07:00
parent 8a497faaf7
commit 8b79c3bb12
29 changed files with 126 additions and 766 deletions
+31 -45
View File
@@ -1,52 +1,38 @@
export function replaceByParam(desc: string, params: number[]): string {
function formatParam(
indexStr: string,
format: string,
floatDigits: string | undefined,
percent: string | undefined
): string {
const i: number = parseInt(indexStr, 10) - 1;
const value: number | undefined = params[i];
if (value === undefined) return "";
if (format.startsWith("f")) {
const digits: number = parseInt(floatDigits || "1", 10);
const num: number = percent ? value * 100 : value;
return `${num.toFixed(digits)}${percent ? "%" : ""}`;
}
if (format === "i") {
return percent ? `${(value * 100).toFixed(0)}%` : `${Math.round(value)}`;
}
return `${value}`;
const formatValue = (value: number, format: string, floatDigits?: string, hasPercent?: boolean): string => {
if (format.startsWith('f')) {
const digits = parseInt(floatDigits || "1", 10);
const num = hasPercent ? value * 100 : value;
return `${num.toFixed(digits)}${hasPercent ? "%" : ""}`;
}
const desc1 = desc.replace(/<color=#[0-9a-fA-F]{8}>(.*?)<\/color>/g, (match: string, inner: string): string => {
const colorCode: string = match.match(/#[0-9a-fA-F]{8}/)?.[0] ?? "#ffffff";
const processed: string = inner
.replace(/#(\d+)\[(f(\d+)|i)\](%)?/g, (
_: string,
index: string,
format: string,
floatDigits: string | undefined,
percent: string | undefined
): string => formatParam(index, format, floatDigits, percent))
.replace(/<unbreak>(.*?)<\/unbreak>/g, "$1");
if (format === 'i') {
const num = hasPercent ? value * 100 : value;
return `${Math.round(num)}${hasPercent ? "%" : ""}`;
}
return `<span style="color:${colorCode}">${processed}</span>`;
return String(value);
};
export function replaceByParam(desc: string, params: number[]): string {
const PARAM_REGEX = /#(\d+)\[(f(\d+)|i)\](%)?/g;
const processor = (_match: string, index: string, format: string, digits?: string, percent?: string): string => {
const i = parseInt(index, 10) - 1;
const val = params[i];
return val !== undefined ? formatValue(val, format, digits, !!percent) : "";
};
let result = desc.replace(/<color=(#[0-9a-fA-F]{8})>(.*?)<\/color>/g, (_, color, inner) => {
const processedInner = inner.replace(PARAM_REGEX, processor);
return `<span style="color: ${color}">${processedInner}</span>`;
});
const desc2 = desc1.replace(/<unbreak>#(\d+)\[(f(\d+)|i)\](%)?<\/unbreak>/g, (
_: string,
index: string,
format: string,
floatDigits: string | undefined,
percent: string | undefined
): string => formatParam(index, format, floatDigits, percent));
result = result.replace(/<unbreak>(.*?)<\/unbreak>/g, (_, inner) => {
return inner.replace(PARAM_REGEX, processor);
});
const desc3 = desc2.replace(/<unbreak>(\d+)<\/unbreak>/g, (_: string, number: string): string => number);
result = result.replace(PARAM_REGEX, processor);
const desc4 = desc3.replaceAll("\\n", "<br></br>");
return desc4;
}
return result.split("\\n").join("<br/>");
}