index.html 8.4 KB

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