index.html 8.5 KB

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