-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.html
More file actions
156 lines (135 loc) · 3.65 KB
/
Copy pathfile.html
File metadata and controls
156 lines (135 loc) · 3.65 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html>
<head>
<title>Generate Support Inventory</title>
<style>
/* Style the page container */
html,
body {
height: 100%;
margin: 0;
padding: 0;
display: flex;
width: 100%;
}
/* Style the top horizontal div */
.top-div {
display: flex;
justify-content: space-between;
align-items: center;
height: 50px;
padding: 0 20px;
background-color: #f1f1f1;
border-bottom: 1px solid #ccc;
box-sizing: border-box;
}
/* Style the tab container */
.tab {
display: flex;
flex-direction: column;
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
height: 100%;
max-width: 200px;
}
/* Style the tab buttons */
.tab button {
background-color: inherit;
border: none;
outline: none;
padding: 10px 16px;
margin: 0;
font-size: 17px;
cursor: pointer;
transition: 0.3s;
flex: 1;
text-align: left;
}
/* Change background color of active tab button */
.tab button.active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
height: 100%;
flex: 1;
}
/* Style the iframe container */
.iframe-container {
flex: 1;
height: 100%;
}
/* Style the iframe */
iframe {
width: 100%;
height: 100%;
border: none;
}
</style>
</head>
<body>
<!-- Define the top horizontal div -->
<div class="top-div">
<!-- <h2>Select file with the list of services</h2> -->
<input id="fileupload" type="file">
</div>
<script>
// read local file using FileReader API
// const fileInput = document.createElement('input');
// fileInput.type = 'file';
const fileInput = document.getElementById('fileupload');
fileInput.addEventListener('change', event => {
const file = event.target.files[0];
const reader = new FileReader();
reader.readAsText(file);
reader.onload = event => {
const data = event.target.result;
// parse the data and loop through the list of names
const names = data.trim().split('\n');
names.forEach(name => {
const tabMenuHtml = `<button class="tablinks active" onclick="openTab(event, '${name}')">${name}</button>`;
const tabHtml = `<div id="${name}" class="tabcontent" style="display:block">
<iframe src="out/${name}.html"></iframe>
</div>`
const tabMenuDiv = document.getElementById('services-menu');
tabMenuDiv.innerHTML += tabMenuHtml;
const tabsDiv = document.getElementById('services-tab');
tabsDiv.innerHTML += tabHtml;
});
};
});
document.body.appendChild(fileInput);
</script>
<!-- Define the tab container -->
<div id="services-menu" class="tab">
</div>
<!-- Define the iframe container -->
<div id="services-tab" class="iframe-container">
</div>
<!-- Script to handle tab switching -->
<script>
function openTab(evt, tabName) {
// Declare variables
var i, tabcontent, tablinks;
// Hide all tab content
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Deactivate all tab buttons
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the selected tab content and activate the corresponding button
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
</script>
</body>
</html>