Remove link provider, move to linkMatcher-style [TO BE FIXED UP/CHECKED]

This commit is contained in:
Carlo Piovesan 2022-10-03 16:45:52 +02:00
parent c854fc6eb4
commit 4817e88f7a

View File

@ -196,14 +196,12 @@
" ", " ",
" TO BE ADDED: Minimal Tailscale/network info plus click on 'Login' ", " TO BE ADDED: Minimal Tailscale/network info plus click on 'Login' ",
" ", " ",
" For more information: " + underline + "https://medium.com/p/40a60170b361" + normal + " ", " Latest article: " + underline + "https://medium.com/p/40a60170b361" + normal + " ",
" ", " Repository: " + underline + "https://github.com/leaningtech/webvm" + normal + " ",
underline + "GitHub" + normal + " | " + " Discord: " + underline + "https://medium.com/p/40a60170b361" + normal + " ",
underline + "Issues" + normal + " | " + " Twitter: " + underline + "https://medium.com/p/40a60170b361" + normal + " ",
underline + "Gitter" + normal + " | " + " About us: " + underline + "https://medium.com/p/40a60170b361" + normal + " ",
underline + "Twitter" + normal + " | " + "",
underline + "Latest News" + normal + " | " +
underline + "About CheerpX" + normal + " |",
"", "",
" Welcome to WebVM (build CX_VERSION). If unsure, try these examples:", " Welcome to WebVM (build CX_VERSION). If unsure, try these examples:",
"", "",
@ -359,49 +357,6 @@
term.registerLinkMatcher(/https:\/\/medium\.com\/p\/40a60170b361/, function(mouseEvent, matchedString) { term.registerLinkMatcher(/https:\/\/medium\.com\/p\/40a60170b361/, function(mouseEvent, matchedString) {
window.open(matchedString, "_blank") window.open(matchedString, "_blank")
}); });
const textArray = new Array(6);
const linksArray = new Array(6);
const rangesArray = new Array(6);
var last = 0;
const textLinkLine = " | GitHub | Issues | Gitter | Twitter | Latest News | About CheerpX |";
const lineWithLinks = 23;
function addLink(text, website)
{
var index = textLinkLine.indexOf(text);
const start_x = index+1;
const end_x = index + text.length;
rangesArray[last] = {start: {x:start_x, y:lineWithLinks}, end: {x:end_x, y:lineWithLinks}};
linksArray[last] = website;
last++;
}
addLink("GitHub", "https://github.com/leaningtech/webvm");
addLink("Issues", "https://github.com/leaningtech/webvm/issues");
addLink("Gitter", "https://gitter.im/leaningtech/cheerpx");
addLink("Twitter", "https://twitter.com/leaningtech");
addLink("Latest News", "https://medium.com/leaningtech");
addLink("About CheerpX", "https://leaningtech.com/cheerpx");
var provider = {
provideLinks(bufferLineNum, callback) {
switch(bufferLineNum)
{
case lineWithLinks:
{
callback([
{range: rangesArray[0], activate() {window.open('' + linksArray[0], '_blank');}},
{range: rangesArray[1], activate() {window.open('' + linksArray[1], '_blank');}},
{range: rangesArray[2], activate() {window.open('' + linksArray[2], '_blank');}},
{range: rangesArray[3], activate() {window.open('' + linksArray[3], '_blank');}},
{range: rangesArray[4], activate() {window.open('' + linksArray[4], '_blank');}},
{range: rangesArray[5], activate() {window.open('' + linksArray[5], '_blank');}},
]);
break;
}
}
}
};
term.registerLinkProvider(provider);
console.log("Welcome. We appreciate curiosity, but be warned that keeping the DevTools open causes significant performance degradation and crashes."); console.log("Welcome. We appreciate curiosity, but be warned that keeping the DevTools open causes significant performance degradation and crashes.");
} }
initialMessage(); initialMessage();