-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
156 lines (133 loc) · 4.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mach1 Spatial Examples</title>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="shortcut icon" href="resources/favicon.ico" />
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
<div id="panel">
<div id="header">
<h1><a href="https://www.mach1.tech"><img src="resources/logo_nobg_hori_blk.png" style="max-height:20px; padding-top: 6px;"/></a></h1>
<div id="sections">
<span class="selected">EXAMPLES</span>
</div>
<div id="expandButton">
<img src="/img/mobile-menu.svg">
</div>
</div>
<div id="panelScrim"></div>
<div id="contentWrapper">
<div id="content" class="minimal">
</div>
</div>
</div>
<iframe id="viewer" name="viewer" allowfullscreen allowvr onmousewheel=""></iframe>
<script src="files.js"></script>
<script>
var panel = document.getElementById( 'panel' );
var content = document.getElementById( 'content' );
var viewer = document.getElementById( 'viewer' );
var expandButton = document.getElementById( 'expandButton' );
var panelScrim = document.getElementById( 'panelScrim' );
var links = {};
var selected = null;
var container = document.createElement( 'div' );
init();
function init() {
content.appendChild( container );
for ( var key in files ) {
var section = files[ key ];
var header = document.createElement( 'h2' );
header.textContent = key;
header.setAttribute( 'data-category', key );
container.appendChild( header );
for ( var i = 0; i < section.length; i ++ ) {
var file = section[ i ];
var link = createLink( file );
container.appendChild( link );
links[ file ] = link;
}
}
if ( window.location.hash !== '' && links[ window.location.hash.substring( 1 ) ] ) {
loadFile( window.location.hash.substring( 1 ) );
}
expandButton.addEventListener( 'click', function ( event ) {
event.preventDefault();
panel.classList.toggle( 'open' );
} );
panelScrim.onclick = function ( event ) {
event.preventDefault();
panel.classList.toggle( 'open' );
};
// iOS iframe auto-resize workaround
if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
viewer.style.width = getComputedStyle( viewer ).width;
viewer.style.height = getComputedStyle( viewer ).height;
viewer.setAttribute( 'scrolling', 'no' );
}
}
function createLink( file ) {
var template = [
'<div class="card">',
' <a href="' + file + '.html" target="viewer">',
' <div class="cover">',
' <img src="screenshots/' + file + '.jpg" loading="lazy" width="400" />',
' </div>',
' <div class="title">' + getName( file ) + '</div>',
' </a>',
'</div>'
].join( "\n" );
var link = createElementFromHTML( template );
link.querySelector( 'a[target="viewer"]' ).addEventListener( 'click', function ( event ) {
if ( event.button !== 0 || event.ctrlKey || event.altKey || event.metaKey ) return;
selectFile( file );
} );
return link;
}
function loadFile( file ) {
selectFile( file );
viewer.src = file + '.html';
}
function selectFile( file ) {
if ( selected !== null ) links[ selected ].classList.remove( 'selected' );
links[ file ].classList.add( 'selected' );
window.location.hash = file;
viewer.focus();
panel.classList.remove( 'open' );
selected = file;
// Reveal "View source" button and set attributes to this example
}
function getName( file ) {
var name = file.split( '-' );
return name.join( ' / ' );
}
function layoutList() {
for ( var key in files ) {
var collapsed = true;
var section = files[ key ];
for ( var i = 0; i < section.length; i ++ ) {
var file = section[ i ];
if ( links[ file ].classList.contains( 'hidden' ) === false ) {
collapsed = false;
break;
}
}
var element = document.querySelector( 'h2[data-category="' + key + '"]' );
if ( collapsed ) {
element.classList.add( 'hidden' );
} else {
element.classList.remove( 'hidden' );
}
}
}
function createElementFromHTML( htmlString ) {
var div = document.createElement( 'div' );
div.innerHTML = htmlString.trim();
return div.firstChild;
}
</script>
</body>
</html>