diff --git a/src/js/Content/Features/Store/Licenses/CLicenses.js b/src/js/Content/Features/Store/Licenses/CLicenses.js index 8d350ff7d..e37e89737 100644 --- a/src/js/Content/Features/Store/Licenses/CLicenses.js +++ b/src/js/Content/Features/Store/Licenses/CLicenses.js @@ -1,12 +1,12 @@ import {Context, ContextType} from "../../../modulesContent"; -import FLincensesSummary from "./FLincensesSummary"; +import {FLicensesSummary} from "./FLicensesSummary.svelte"; export class CLicenses extends Context { constructor() { super(ContextType.LICENSES, [ - FLincensesSummary, + FLicensesSummary, ]); } } diff --git a/src/js/Content/Features/Store/Licenses/FLicensesSummary.svelte b/src/js/Content/Features/Store/Licenses/FLicensesSummary.svelte new file mode 100644 index 000000000..018748c40 --- /dev/null +++ b/src/js/Content/Features/Store/Licenses/FLicensesSummary.svelte @@ -0,0 +1,117 @@ + + + + +{Localization.str.wl.label} + +{#if show} +
+ + + + + {@html tableHeader} + + + + + {@html rows} + + + + + {@html tableFooter} + + + +
{Localization.str.year}{Localization.str.all}
{Localization.str.all}{totalGlobal}
+
+{/if} + + + diff --git a/src/js/Content/Features/Store/Licenses/FLincensesSummary.js b/src/js/Content/Features/Store/Licenses/FLincensesSummary.js deleted file mode 100644 index 89d951820..000000000 --- a/src/js/Content/Features/Store/Licenses/FLincensesSummary.js +++ /dev/null @@ -1,76 +0,0 @@ -import {HTML, Localization} from "../../../../modulesCore"; -import {Feature} from "../../../modulesContent"; - -export default class FLincensesSummary extends Feature { - - apply() { - const all = document.querySelectorAll(".account_table tr[data-panel]"); - const list = {}; - const types = {}; - - for (const item of all) { - const dateStr = item.querySelector(".license_date_col").textContent.trim(); - const year = /\d{4}/.exec(dateStr)?.[0] ?? ""; - const typ = item.querySelector(".license_acquisition_col").textContent.trim(); - - (list[year] ??= {})[typ] = (list[year][typ] ?? 0) + 1; - types[typ] = (types[typ] ?? 0) + 1; - } - - const listEntries = Object.entries(list).reverse(); - const totals = listEntries.map( - ([, row]) => Object.entries(row) - .map(([, count]) => count) - .reduce((a, b) => a + b, 0) - ); - - const totalGlobal = totals.reduce((a, b) => a + b, 0); - const typesEntries = Object.entries(types); - - const tableHeader = typesEntries - .map(([name]) => `${name}`) - .join(""); - - const tableFooter = typesEntries - .map(([, value]) => `${value || "0"}`) - .join(""); - - const rows = listEntries - .map(([year, row], i) => ` - ${year} - ${typesEntries - .map(([name]) => `${row[name] || "0"}`) - .join("") - } - ${totals[i] || "0"} - `) - .join(""); - - HTML.beforeBegin( - document.querySelector(".youraccount_page > .block"), - `
-
- - - - - ${tableHeader} - - - - - ${rows} - - - - - ${tableFooter} - - - - -
-
` - ); - } -} diff --git a/src/localization/en.json b/src/localization/en.json index 11da5ae65..25c614a2f 100644 --- a/src/localization/en.json +++ b/src/localization/en.json @@ -19,6 +19,7 @@ "toomanyrequests": "Too Many Requests", "show_comments": "Show Comments", "hide_comments": "Hide Comments", + "thewordunknown": "Unknown", "calc_workshop_size": { "file_size": "File size __size__", "calc_size": "Calculate Total Size",