blob: 2c0e2564e2dd4d4334f1e8b4f56b19530ea276a4 (
plain) (
blame)
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
|
import { shell } from "electron";
export class socialLink {
constructor(
public icon: string, // has to be one from font awesome -https://fontawesome.com/icons
public tooltip: string,
public url: string
) {}
getHTML(): HTMLElement {
//<button onclick="sv.openSocialLink(this)" socialLink="abc"><i class="fa fa-user"></i></button><br>
const element = document.createElement("button");
element.onclick = () => {
this.open();
};
const icon = document.createElement("i");
icon.className = this.icon;
element.append(icon);
element.title = this.tooltip;
return element;
}
open() {
console.log("A link was clicked!", this.url);
if (this.url)
shell.openExternal(
this.url.indexOf("://") !== -1 ? this.url : `https://${this.url}`
);
}
}
|