DWV display example #1.1
Simplest DWV DICOM image display example with 2 views.
by Fahd Murtaza
HTML
<script src="https://github.com/ivmartel/dwv/releases/download/v0.30.4/dwv-0.30.4.min.js"></script>
<div class="tab">
<button class="tablinks" onclick="openTab(event, 'DWV1')">DWV App 1</button>
<button class="tablinks" onclick="openTab(event, 'DWV2')">DWV App 2</button>
</div>
<!-- Tab content -->
<div id="DWV1" class="tabcontent">
<div id="dwv">
<div id="layerGroup0"></div>
</div>
</div>
<div id="DWV2" class="tabcontent">
<div id="dwv2">
<div id="layerGroup1"></div>
</div>
</div>
CSS
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
/* Style the buttons inside the tab */
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
}
/* Change background color of buttons on hover */
.tab button:hover {
background-color: #ddd;
}
/* Create an active/current tablink class */
.tab button.active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
JavaScript
function openTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
// Default open tab
document.getElementsByClassName("tablinks")[0].click();