index.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>three.js - documentation</title>
  6. <style>
  7. @font-face {
  8. font-family: 'inconsolata';
  9. src: url('files/inconsolata.woff') format('woff');
  10. font-weight: normal;
  11. font-style: normal;
  12. }
  13. *{ box-sizing: border-box;}
  14. html {
  15. height: 100%;
  16. }
  17. body {
  18. background-color: #ffffff;
  19. margin: 0;
  20. padding: 0 0 0 260px;
  21. height: 100%;
  22. color: #555;
  23. font-family: 'inconsolata';
  24. font-size: 15px;
  25. line-height: 18px;
  26. overflow: hidden;
  27. }
  28. a {
  29. color: #2194CE;
  30. text-decoration: none;
  31. }
  32. #panel {
  33. position: fixed;
  34. left: 0px;
  35. width: 260px;
  36. height: 100%;
  37. overflow: auto;
  38. background: #fafafa;
  39. }
  40. #panel h1 {
  41. margin-top: 30px;
  42. margin-bottom: 40px;
  43. margin-left: 20px;
  44. font-size: 25px;
  45. font-weight: normal;
  46. }
  47. #panel h2 {
  48. color: #454545;
  49. font-size: 18px;
  50. font-weight: normal;
  51. margin-top: 20px;
  52. margin-left: 20px;
  53. }
  54. #panel h3 {
  55. color: #666;
  56. font-size: 16px;
  57. font-weight: normal;
  58. margin-top: 20px;
  59. margin-left: 20px;
  60. }
  61. #panel ul {
  62. list-style-type: none;
  63. padding: 0px;
  64. margin-left: 20px;
  65. }
  66. #viewer {
  67. border: 0px;
  68. width: 100%;
  69. height: 100%;
  70. overflow: auto;
  71. }
  72. .filterBlock{
  73. margin: 20px;
  74. position: relative;
  75. }
  76. .filterBlock p {
  77. margin: 0;
  78. }
  79. #filterInput {
  80. width: 100%;
  81. padding: 5px;
  82. font-family: 'inconsolata';
  83. font-size: 15px;
  84. outline: none;
  85. border: 1px solid #dedede;
  86. }
  87. #filterInput:focus{
  88. border: 1px solid #2194CE;
  89. }
  90. #clearFilterButton {
  91. position: absolute;
  92. right: 6px;
  93. top: 50%;
  94. margin-top: -8px;
  95. width: 16px;
  96. height: 16px;
  97. font-size: 14px;
  98. background-color: #b70000;
  99. border-radius: 16px;
  100. color: white;
  101. text-align: center;
  102. line-height: 0;
  103. padding-top: 7px;
  104. opacity: .5;
  105. transition: opacity 150ms ease-out, transform 150ms ease-out;
  106. }
  107. #clearFilterButton:hover{
  108. opacity: 1;
  109. transform: scale( 1.2 );
  110. }
  111. .filtered{
  112. display: none;
  113. }
  114. </style>
  115. </head>
  116. <body>
  117. <div id="panel">
  118. <h1><a href="http://threejs.org">three.js</a> / docs</h1>
  119. <div class="filterBlock" >
  120. <input type="text" id="filterInput" placeholder="Type to filter"/>
  121. <a href="#" id="clearFilterButton" >x</a>
  122. </div>
  123. </div>
  124. <iframe id="viewer"></iframe>
  125. <script src="list.js"></script>
  126. <script>
  127. var panel = document.getElementById( 'panel' );
  128. var viewer = document.getElementById( 'viewer' );
  129. var filterInput = document.getElementById( 'filterInput' );
  130. filterInput.focus();
  131. var DELIMITER = '/';
  132. var nameCategoryMap = {};
  133. var sections = [];
  134. var content = document.createDocumentFragment();
  135. for ( var section in list ) {
  136. var h2 = document.createElement( 'h2' );
  137. h2.textContent = section;
  138. content.appendChild( h2 );
  139. for ( var category in list[ section ] ) {
  140. var div = document.createElement( 'div' );
  141. var h3 = document.createElement( 'h3' );
  142. h3.textContent = category;
  143. div.appendChild( h3 );
  144. var ul = document.createElement( 'ul' );
  145. div.appendChild( ul );
  146. for ( var i = 0; i < list[ section ][ category ].length; i ++ ) {
  147. var page = list[ section ][ category ][ i ];
  148. var li = document.createElement( 'li' );
  149. var a = document.createElement( 'a' );
  150. a.setAttribute( 'href', 'javascript:goTo(\'' + section + '\', \'' + category + '\', \'' + page[ 0 ] + '\')');
  151. a.textContent = page[ 0 ];
  152. li.appendChild( a );
  153. ul.appendChild( li );
  154. nameCategoryMap[page[0]] = {
  155. section: section,
  156. category: category,
  157. name: page[0],
  158. element: li
  159. };
  160. }
  161. content.appendChild( div );
  162. sections.push( ul );
  163. }
  164. }
  165. panel.appendChild( content )
  166. function layoutList() {
  167. sections.forEach( function( el ) {
  168. var collapsed = true;
  169. Array.prototype.slice.apply( el.children ).forEach( function( item ) {
  170. if( !item.classList.contains( 'filtered' ) ) {
  171. collapsed = false;
  172. return;
  173. }
  174. } );
  175. if( collapsed ) {
  176. el.parentElement.classList.add( 'filtered' );
  177. } else {
  178. el.parentElement.classList.remove( 'filtered' );
  179. }
  180. } );
  181. }
  182. filterInput.addEventListener( 'input', function( e ) {
  183. updateFilter();
  184. } );
  185. document.getElementById( 'clearFilterButton' ).addEventListener( 'click', function( e ) {
  186. filterInput.value = '';
  187. updateFilter();
  188. e.preventDefault();
  189. } );
  190. function updateFilter() {
  191. var exp = new RegExp( filterInput.value, 'gi' );
  192. for( var j in nameCategoryMap ) {
  193. var res = nameCategoryMap[ j ].name.match( exp );
  194. if( res && res.length > 0 ) {
  195. nameCategoryMap[ j ].element.classList.remove( 'filtered' );
  196. } else {
  197. nameCategoryMap[ j ].element.classList.add( 'filtered' );
  198. }
  199. }
  200. layoutList();
  201. }
  202. function encodeUrl( path ) {
  203. return path.replace(/\ \/\ /g, '.').replace(/\ /g, '_');
  204. }
  205. function decodeUrl( path ) {
  206. return path.replace(/_/g, ' ').replace(/\./g, ' / ');
  207. }
  208. // Page loading
  209. function goTo( section, category, name ) {
  210. // Fully resolve links that only provide a name
  211. if(arguments.length == 1) {
  212. var location = nameCategoryMap[section];
  213. section = location.section;
  214. category = location.category;
  215. name = location.name;
  216. }
  217. var title = 'three.js - documentation - ' + section + ' - ' + name;
  218. var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name);
  219. window.location.hash = url;
  220. window.document.title = title;
  221. viewer.src = pages[ section ][ category ][ name ] + '.html';
  222. }
  223. function goToHash() {
  224. var hash = window.location.hash.substring( 1 ).split(DELIMITER);
  225. goTo( decodeUrl(hash[0]), decodeUrl(hash[1]), decodeUrl(hash[2]) );
  226. }
  227. window.addEventListener( 'hashchange', goToHash, false );
  228. if ( window.location.hash.length > 0 ) goToHash();
  229. </script>
  230. </body>
  231. </html>