index.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. html {
  14. height: 100%;
  15. }
  16. body {
  17. background-color: #ffffff;
  18. margin: 0;
  19. padding: 0 0 0 260px;
  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. border: 0px;
  67. width: 100%;
  68. height: 100%;
  69. overflow: auto;
  70. }
  71. </style>
  72. </head>
  73. <body>
  74. <div id="panel"></div>
  75. <iframe id="viewer"></iframe>
  76. <script src="list.js"></script>
  77. <script>
  78. var panel = document.getElementById( 'panel' );
  79. var viewer = document.getElementById( 'viewer' );
  80. var html = '<h1><a href="http://threejs.org">three.js</a> / docs</h1>';
  81. var DELIMITER = '/';
  82. var nameCategoryMap = {};
  83. for ( var section in list ) {
  84. html += '<h2>' + section + '</h2>';
  85. html += '<ul>';
  86. for ( var category in list[ section ] ) {
  87. html += '<h3>' + category + '</h3>';
  88. html += '<ul>';
  89. for ( var i = 0; i < list[ section ][ category ].length; i ++ ) {
  90. var page = list[ section ][ category ][ i ];
  91. html += '<li><a href="javascript:goTo(\'' + section + '\', \'' + category + '\', \'' + page[ 0 ] + '\')">' + page[ 0 ] + '</a></li>';
  92. nameCategoryMap[page[0]] = {
  93. section: section,
  94. category: category,
  95. name: page[0]
  96. };
  97. }
  98. html += '</ul>';
  99. }
  100. html += '</ul>';
  101. }
  102. panel.innerHTML += html;
  103. function encodeUrl( path ) {
  104. return path.replace(/\ \/\ /g, '.').replace(/\ /g, '_');
  105. }
  106. function decodeUrl( path ) {
  107. return path.replace(/_/g, ' ').replace(/\./g, ' / ');
  108. }
  109. // Page loading
  110. function goTo( section, category, name ) {
  111. // Fully resolve links that only provide a name
  112. if(arguments.length == 1) {
  113. var location = nameCategoryMap[section];
  114. section = location.section;
  115. category = location.category;
  116. name = location.name;
  117. }
  118. var title = 'three.js - documentation - ' + section + ' - ' + name;
  119. var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name);
  120. window.location.hash = url;
  121. window.document.title = title;
  122. viewer.src = pages[ section ][ category ][ name ] + '.html';
  123. }
  124. function goToHash() {
  125. var hash = window.location.hash.substring( 1 ).split(DELIMITER);
  126. goTo( decodeUrl(hash[0]), decodeUrl(hash[1]), decodeUrl(hash[2]) );
  127. }
  128. window.addEventListener( 'hashchange', goToHash, false );
  129. if ( window.location.hash.length > 0 ) goToHash();
  130. </script>
  131. </body>
  132. </html>