index.html 8.1 KB

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