-
Notifications
You must be signed in to change notification settings - Fork 2
/
AlloyPanel.html
78 lines (65 loc) · 2.34 KB
/
AlloyPanel.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alloy</title>
</head>
<body>
<div id='log' style="width: 100%"> </div>
<button id='btnStop' style="margin:5px 5px 5px 0px; padding:4px 11px 4px 11px;"> Stop </button>
<script>
const logPanel = document.getElementById('log');
const vscode = acquireVsCodeApi();
const btnStop = document.getElementById('btnStop');
btnStop.addEventListener("click", () => {
vscode.postMessage({ method: "stop" });
});
// Handle the message inside the webview
window.addEventListener('message', event => {
const req = event.data;
let style = "";
if(req.bold)
style += "font-weight:bold;";
if(req.messageType == 4)
style += "color: red;";
if (req.messageType == 0 || req.messageType == 1)
btnStop.hidden = false;
else if (req.messageType == 2 || req.messageType == 3)
btnStop.hidden = true;
if (req.replaceLast) {
logPanel.removeChild(logPanel.lastChild);
}
if (req.link) {
let link = document.createElement("a");
link.setAttribute("style", style);
link.innerText = req.message;
link.href = "";
vscode.postMessage({ method: "instanceCreated", data: req });
link.onclick = () => {
vscode.postMessage({ method: "model", data: req });
return false;
};
logPanel.appendChild(link);
}
else {
let text = document.createElement("span");
text.setAttribute("style", style);
text.innerHTML = req.message.replace(/\n/g, "<br>");
logPanel.appendChild(text);
}
if (req.messageType == 3) {
logPanel.appendChild(document.createElement("hr"));
}
window.scrollTo(0, document.body.scrollHeight);
});
// enum AlloyLanguageServerMessageType{
// RunStarted, 0
// RunInProgress, 1
// RunResult, 2
// RunCompleted, 3
// Warning, 4
// }
</script>
</body>
</html>