-
Notifications
You must be signed in to change notification settings - Fork 1
/
iframe_apps.html
95 lines (91 loc) · 2.84 KB
/
iframe_apps.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>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Climate App</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<!-- <link rel='stylesheet' type='text/css' media='screen' href='main.css'> -->
<!-- <script src='main.js'></script> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
<script>
let apps = {'Carbon': 'http://127.0.0.1:9000/',
'Asset': 'http://127.0.0.1:9001/',
'Stock': 'http://127.0.0.1:9002/',
'Sentiments': 'http://127.0.0.1:9003/'}
</script>
<style>
body {
background-color: #1A1C23;
}
iframe {
background-color: #1A1C23;
width: 100%;
height: 90vh;
}
.tabs a {
color: white;
background-color: #22252B;
}
.tabs li.is-active a {
color: white;
}
#tabs {
margin: 0;
padding: 10px;
color:white;
}
.iframe-active {
display: block
}
.iframe-inactive {
display: none;
}
</style>
</head>
<body>
<div class="tabs is-toggle is-large is-centered" id="tabs">
<ul id="tabs-ul">
</ul>
</div>
</body>
<script>
function changeTab(id) {
// clear all tab elements
Object.keys(apps).forEach(function(key) {
let li = document.querySelector('#li-'+key);
let iframe = document.querySelector('#iframe-'+key);
li.className = '';
iframe.className = 'iframe-inactive';
if (key==id) {
li.classList.add('is-active');
iframe.className = 'iframe-active';
}
else {
iframe.className = 'iframe-inactive';
}
})
}
function createApps() {
let tabs_ul = document.querySelector('#tabs-ul');
for (key in apps) {
let value = apps[key];
let li = document.createElement('li');
li.setAttribute('id', 'li-'+key);
li.setAttribute('onclick', "changeTab('"+key+"')" );
let a = document.createElement('a');
a.innerHTML = key;
li.appendChild(a);
tabs_ul.appendChild(li);
let iframe = document.createElement('iframe');
let body = document.querySelector('body');
iframe.setAttribute('id', 'iframe-'+key);
iframe.setAttribute('src', value);
body.appendChild(iframe);
}
}
createApps();
changeTab(Object.keys(apps)[0]);
</script>
</html>