TeaWeb/shared/js/ui/modal/ModalAbout.ts

40 lines
1.4 KiB
TypeScript
Raw Normal View History

2020-03-30 13:44:18 +02:00
import {createModal} from "tc-shared/ui/elements/Modal";
import {LogCategory} from "tc-shared/log";
import * as log from "tc-shared/log";
2020-03-30 13:44:18 +02:00
function format_date(date: number) {
const d = new Date(date);
2019-08-21 10:00:01 +02:00
2020-03-30 13:44:18 +02:00
return ('00' + d.getDay()).substr(-2) + "." + ('00' + d.getMonth()).substr(-2) + "." + d.getFullYear() + " - " + ('00' + d.getHours()).substr(-2) + ":" + ('00' + d.getMinutes()).substr(-2);
}
2019-08-21 10:00:01 +02:00
2020-03-30 13:44:18 +02:00
export function spawnAbout() {
const connectModal = createModal({
header: tr("About"),
body: () => {
let tag = $("#tmpl_about").renderTag({
client: __build.target !== "web",
2019-08-21 10:00:01 +02:00
2020-04-09 23:09:59 +02:00
version_client: __build.target === "web" ? __build.version || "in-dev" : "loading...",
version_ui: __build.version || "in-dev",
2019-08-21 10:00:01 +02:00
2020-04-09 23:09:59 +02:00
version_timestamp: format_date(__build.timestamp)
});
2020-03-30 13:44:18 +02:00
return tag;
},
footer: null,
width: "60em"
});
connectModal.htmlTag.find(".modal-body").addClass("modal-about");
connectModal.open();
if(__build.target !== "web") {
2020-03-30 13:44:18 +02:00
(window as any).native.client_version().then(version => {
connectModal.htmlTag.find(".version-client").text(version);
}).catch(error => {
log.error(LogCategory.GENERAL, tr("Failed to load client version: %o"), error);
connectModal.htmlTag.find(".version-client").text("unknown");
});
2019-08-21 10:00:01 +02:00
}
}