Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/packages/web/src/index.ts

48 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-01-12 01:21:31 +01:00
import { logger, field, time } from "@coder/logger";
import { load } from "@coder/vscode";
2019-01-11 19:58:25 +01:00
import "./index.scss";
2019-01-12 01:21:31 +01:00
const loadTime = time(2500);
2019-01-15 00:19:29 +01:00
logger.info("Loading IDE");
2019-01-12 01:11:34 +01:00
2019-01-11 18:50:54 +01:00
const overlay = document.getElementById("overlay");
const logo = document.getElementById("logo");
2019-01-12 01:21:31 +01:00
const msgElement = overlay
? overlay.querySelector(".message") as HTMLElement
: undefined;
2019-01-11 18:50:54 +01:00
if (overlay && logo) {
overlay.addEventListener("mousemove", (event) => {
const xPos = ((event.clientX - logo.offsetLeft) / 24).toFixed(2);
const yPos = ((logo.offsetTop - event.clientY) / 24).toFixed(2);
logo.style.transform = `perspective(200px) rotateX(${yPos}deg) rotateY(${xPos}deg)`;
});
}
2019-01-12 01:11:34 +01:00
2019-01-12 01:21:31 +01:00
load().then(() => {
if (overlay) {
overlay.style.opacity = "0";
overlay.addEventListener("transitionend", () => {
overlay.remove();
});
}
}).catch((error: Error) => {
logger.error(error.message);
if (overlay) {
overlay.classList.add("error");
}
if (msgElement) {
2019-01-15 00:19:29 +01:00
const button = document.createElement("div");
button.className = "reload-button";
button.innerText = "Reload";
button.addEventListener("click", () => {
location.reload();
});
msgElement.innerText = `Failed to load: ${error.message}.`;
msgElement.parentElement!.appendChild(button);
2019-01-12 01:21:31 +01:00
}
}).finally(() => {
logger.info("Load completed", field("duration", loadTime));
});