Skip to content

Commit 08a8213

Browse files
authored
Merge pull request #3 from styopdev/tabs
Tabs
2 parents 4ec5870 + 2b020de commit 08a8213

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

css/style.css

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ canvas {
232232
width: 30px;
233233
height: 30px;
234234
position: absolute;
235-
top: 10px;
235+
top: 50px;
236236
right: 20px;
237237
z-index: 99;
238238
}
@@ -467,6 +467,9 @@ select:not([multiple]) {
467467
margin: 0px auto;
468468
display: block;
469469
}
470+
#tree-json {
471+
display: none;
472+
}
470473
.warning {
471474
display: flex;
472475
justify-content: center;
@@ -543,6 +546,33 @@ select:not([multiple]) {
543546
supported by Chrome and Opera */
544547
}
545548

549+
.tabs {
550+
text-align: left;
551+
}
552+
553+
.tabs .tab {
554+
width: 80px;
555+
padding: 11px 0;
556+
border: 1px solid #a6a6a6;
557+
display: inline-block;
558+
cursor: pointer;
559+
border-bottom: 0px ;
560+
text-align: center;
561+
}
562+
563+
.tabs .tab:first-child {
564+
border-top-left-radius: 5px;
565+
border-right: 1px;
566+
}
567+
568+
.tabs .tab:not(:first-child) {
569+
margin-left: -4px;
570+
border-top-right-radius: 5px;
571+
}
572+
573+
.tabs .tab.active {
574+
background-color: #ffffff;
575+
}
546576
.loading {
547577
display: none;
548578
position: absolute;

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@
141141
</div>
142142

143143
<div id="generated-tree" class="generated-tree">
144+
<div class="tabs">
145+
<a onclick="switchTab(this, 'image')" class="tab active">Image</a>
146+
<a onclick="switchTab(this, 'json')" class="tab">Json</a>
147+
</div>
144148
<a class="back cp" title="Try again">
145149
<div class="back-bg"></div>
146150
<img src="./img/reload.png" class="back-image" alt="Go back" onclick="retry()">

js/script.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,15 @@ function processFile(zip) {
109109
var canvasElement = document.createElement('canvas');
110110

111111
canvasElement.setAttribute('id', 'tree-canvas');
112+
113+
var jsonElement = document.createElement('textarea');
114+
jsonElement.setAttribute('id', 'tree-json');
115+
jsonElement.style.width = '582px';
116+
jsonElement.style.height = '600px';
117+
112118
document.getElementById('generated-tree').appendChild(canvasElement);
119+
document.getElementById('generated-tree').appendChild(jsonElement);
120+
113121
document.getElementById('zone').style.display = 'none';
114122

115123
var layout = document.getElementById("layout");
@@ -195,6 +203,22 @@ function readFile(file) {
195203
};
196204
}
197205

206+
function switchTab(elem, tabName) {
207+
document.querySelectorAll('.tabs .tab.active')
208+
.forEach(tab => tab.classList.remove('active'));
209+
elem.classList.add('active');
210+
211+
if (tabName === 'image') {
212+
document.getElementById('tree-canvas').style.display = 'block';
213+
document.getElementById('tree-json').style.display = 'none';
214+
} else {
215+
document.getElementById('tree-json').style.display = 'block';
216+
document.getElementById('tree-canvas').style.display = 'none';
217+
218+
document.getElementById('tree-json').innerHTML = JSON.stringify(fileNamesTree, undefined, 4);
219+
}
220+
}
221+
198222
Dropzone.options.myAwesomeDropzone = {
199223
paramName: "file",
200224
maxFiles: 1,

0 commit comments

Comments
 (0)