This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathabout.ts
81 lines (74 loc) · 2.18 KB
/
about.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* @ignore
* @packageDocumentation
* @preferred
*/
import { strings } from "./strings";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
fetch("data/THIRD_PARTY.json")
.then((res) => res.json())
.then(
(
data: {
name: string;
version: string;
authors: string;
url: string;
license: string;
}[]
) => {
const creditsEle = document.getElementById("credits");
const creditsFrag = document.createDocumentFragment();
data.forEach((item) => {
const ele = createElement("div", { class: "credit " });
ele.appendChild(createElement("h3", {}, item.name));
ele.appendChild(createElement("p", { class: "authors" }, item.authors));
ele.appendChild(
createElement(
"p",
{ class: "description" },
strings.about.version(item.version, item.url)
)
);
const licenseContainer = createElement("p", { class: "description" });
const link = createElement("a", { href: "#" }, strings.about.license);
link.onclick = () => {
licenseContainer.appendChild(
createElement("pre", { class: "license" }, item.license)
);
licenseContainer.removeChild(link);
};
licenseContainer.appendChild(link);
ele.appendChild(licenseContainer);
creditsFrag.appendChild(ele);
});
creditsEle.appendChild(creditsFrag);
}
);
document.getElementById("version").innerText = CHARTICULATOR_PACKAGE.version;
document.getElementById("revision").innerText = CHARTICULATOR_PACKAGE.revision;
/**
* @ignore
*/
function createElement(name: string, attrs: any, text?: string) {
const ele = document.createElement(name);
Object.keys(attrs).forEach((attr) => {
const attrValue = attrs[attr];
ele.setAttribute(attr, attrValue);
});
if (text) {
ele.textContent = text;
}
return ele;
}
/**
* @ignore
*/
((d) => {
const wf = d.createElement("script"),
s = d.scripts[0];
wf.src = "https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js";
wf.async = true;
s.parentNode.insertBefore(wf, s);
})(document);