-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidebar.html
95 lines (90 loc) · 3.46 KB
/
sidebar.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html class="no-js"> <!--<![endif]-->
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title></title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css"
/>
<script>
const vscode = acquireVsCodeApi();
window.addEventListener("message", (event) => {
const message = event.data; // The json data that the extension sent
switch (message.type) {
case "SIDEBAR_PREVIEW": {
initialLayout(message.value);
break;
}
case "RELOAD_SIDEBAR_PREVIEW": {
document.getElementById("sidebar-preview").src =
"https://staging.docs.setu.co/sidebar-preview?endpoints=" +
message.value;
break;
}
}
});
function initialLayout(options) {
let selectOptionHTML = getOptions(options);
document.getElementById("category").innerHTML =
selectOptionHTML;
}
function getOptions(options) {
let optionsHTML =
"<option disabled selected>Select Category</option>";
for (let index in options) {
let option = options[index];
optionsHTML += `<option value=${option.value}>${option.name}</option>`;
}
return optionsHTML;
}
function getCategory() {
let category = document.getElementById("category").value;
console.log(category);
// document.getElementById("getValue").innerText = category;
vscode.postMessage({
type: "CATEGORY_SELECTED",
value: category,
});
}
</script>
</head>
<body style="margin: 0px; padding: 0px">
<div style="text-align: center; padding: 20px">
<h3 style="margin-bottom: 10px">Sidebar Preview</h3>
<h6 id="test-path"></h6>
<h3 id="getValue"></h3>
<div class="form-group">
<label for="category">Select category</label>
<select
class="form-control"
id="category"
onchange="getCategory();"
></select>
</div>
<iframe
src=""
frameborder="0"
style="
height: 100vh;
width: 100%;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
border: 1px solid black;
"
height="100%"
width="100%"
id="sidebar-preview"
></iframe>
</div>
</body>
</html>