提交 ece65153 编写于 作者: J Jaume Sanchez 提交者: Mr.doob

Added support for search param to examples (#9157)

* fix for retina screens

* q param to prepopulate filter on examples

* removed polyfill

* added to /docs too
上级 6df2c331
......@@ -224,6 +224,15 @@
<script src="list.js"></script>
<script>
function extractQuery() {
var p = window.location.search.indexOf( '?q=' )
if( p !== -1 ) {
return window.location.search.substr( 3 );
}
return ''
}
var panel = document.getElementById( 'panel' );
var viewer = document.getElementById( 'viewer' );
......@@ -240,6 +249,7 @@
var MEMBER_DELIMITER = '.';
var nameCategoryMap = {};
var sections = [];
var selected = null;
var content = document.getElementById( 'content' );
......@@ -328,6 +338,14 @@
function updateFilter() {
var v = filterInput.value;
if( v !== '' ) {
window.history.replaceState( {} , '', '?q=' + v );
} else {
window.history.replaceState( {} , '', window.location.pathname );
}
if( selected ) window.location.hash = selected
var exp = new RegExp( filterInput.value, 'gi' );
for( var j in nameCategoryMap ) {
var res = nameCategoryMap[ j ].name.match( exp );
......@@ -383,6 +401,7 @@
var title = 'three.js - documentation - ' + section + ' - ' + name;
var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name) + (!!member ? MEMBER_DELIMITER + encodeUrl(member) : '');
selected = url
window.location.hash = url;
window.document.title = title;
......@@ -416,6 +435,9 @@
' \\/____/\\/_____/'
].join('\n'));
filterInput.value = extractQuery()
updateFilter( )
</script>
<script src="../build/three.min.js"></script> <!-- console sandbox -->
</body>
......
......@@ -240,8 +240,17 @@
<iframe id="viewer" name="viewer" allowfullscreen onmousewheel=""></iframe>
<script src="files.js"></script>
<script>
function extractQuery() {
var p = window.location.search.indexOf( '?q=' )
if( p !== -1 ) {
return window.location.search.substr( 3 );
}
return ''
}
var panel = document.getElementById( 'panel' );
var content = document.getElementById( 'content' );
var viewer = document.getElementById( 'viewer' );
......@@ -371,7 +380,15 @@
function updateFilter() {
var exp = new RegExp( filterInput.value, 'gi' );
var v = filterInput.value;
if( v !== '' ) {
window.history.replaceState( {} , '', '?q=' + v );
} else {
window.history.replaceState( {} , '', window.location.pathname );
}
if( selected ) window.location.hash = selected
var exp = new RegExp( v, 'gi' );
for ( var key in files ) {
......@@ -459,6 +476,9 @@
}
filterInput.value = extractQuery()
updateFilter( )
</script>
</body>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册