This repository has been archived by the owner on Oct 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 202
/
index.html
158 lines (139 loc) · 5.64 KB
/
index.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
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
157
158
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, shrink-to-fit=no, initial-scale=1">
<title>osgjs examples</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="examples/templates/css/sidebar.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- Custom CSS -->
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul id="sidebar-nav" class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
<h2>OSG.js</h2>
</a>
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<a href="#menu-toggle" class="btn btn-default" id="menu-toggle"><span class="glyphicon glyphicon-menu-hamburger"></span></a>
<iframe id="viewer" name="viewer" allowfullscreen allowvr onmousewheel=""></iframe>
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<!-- /#wrapper -->
<!-- Fill Sidebar script -->
<script src="examples/files.js"></script>
<script>
var updateIframe = function ( iframe, src ) {
var frame = iframe.cloneNode();
frame.src = baseURL + src.split( '#' )[ 1 ];
iframe.parentNode.replaceChild( frame, iframe );
return frame;
};
var sidebar = document.getElementById( 'sidebar-nav' );
var baseURL = window.location.href.split( '#' )[ 0 ]; // Returns full URL
var baseHash = window.location.hash;
var viewer = document.getElementById( 'viewer' );
for ( var key in files ) {
var category = files[ key ];
var header = document.createElement( 'a' );
h3 = document.createElement( 'h3' );
h3.textContent = key;
header.appendChild( h3 );
var li = document.createElement( 'li' );
li.setAttribute( 'data-toggle', 'collapse' );
li.setAttribute( 'data-target', '#' + key );
li.appendChild( header );
sidebar.appendChild( li );
var div = document.createElement( 'div' );
div.className = 'dropdown collapse';
div.id = key;
var ul = document.createElement( 'ul' );
div.appendChild( ul );
sidebar.appendChild( div );
for ( var i = 0; i < category.length; i++ ) {
var li = document.createElement( 'li' );
var link = document.createElement( 'a' );
link.className = 'link';
link.textContent = category[ i ];
var path = 'examples/' + category[ i ] + '/index.html';
link.href = baseURL + '#' + path;
link.addEventListener( 'click', function ( event ) {
event.preventDefault();
viewer = updateIframe( viewer, this.href );
window.history.pushState( null, null, this.href );
}.bind( link ) );
li.appendChild( link );
li.id = key;
ul.appendChild( li );
}
}
// Now add also tests
var li = document.createElement( 'li' );
var link = document.createElement( 'a' );
link.className = 'link';
var testsText = document.createElement( 'h3' );
testsText.textContent = 'Tests';
link.href = 'tests/index.html';
link.setAttribute( 'target', 'viewer' );
link.appendChild( testsText );
link.addEventListener( 'click', function ( event, link ) {
if ( event.button === 0 ) {
window.location = '#tests/index.html';
}
}.bind( link ) );
li.appendChild( link );
sidebar.appendChild( li );
// And benchmarks
var li = document.createElement( 'li' );
var link = document.createElement( 'a' );
link.className = 'link';
var benchText = document.createElement( 'h3' );
benchText.textContent = 'Benchmarks';
link.href = 'benchmarks/index.html';
link.setAttribute( 'target', 'viewer' );
link.appendChild( benchText );
link.addEventListener( 'click', function ( event, link ) {
if ( event.button === 0 ) {
window.location = '#benchmarks/index.html';
}
}.bind( link ) );
li.appendChild( link );
sidebar.appendChild( li );
// Handle refresh/reload
if ( baseHash ) {
viewer = updateIframe( viewer, window.location.href );
}
// Let's detect pop/refresh
window.addEventListener( 'popstate', function ( event ) {
var hash = window.location.hash;
if ( !hash ) window.location.href = baseURL;
viewer = updateIframe( viewer, window.location.href );
} );
</script>
<!-- Menu Toggle Script -->
<script>
$( "#menu-toggle" ).click( function ( e ) {
e.preventDefault();
$( "#wrapper" ).toggleClass( "toggled" );
} );
</script>
</body>
</html>