浏览代码

Fixed content page links that only provide a name

Joe Doyle 12 年之前
父节点
当前提交
f0366c0e8f
共有 1 个文件被更改,包括 24 次插入1 次删除
  1. 24 1
      docs/index.html

+ 24 - 1
docs/index.html

@@ -138,8 +138,15 @@
 
 			function goTo( section, category, name ) {
 
+        // Fully resolve links that only provide a name
+        if(!category && !name) {
+          var location = getPageFromList(section);
+          section = location.section;
+          category = location.category;
+          name = location.name;
+        }
+        
 				window.document.title = 'three.js - documentation - ' + section + ' - ' + name;
-
 				window.location.hash = section + '/' + category + '/' + name.replace(/\ /g, '-');
 
 				viewer.src = pages[ section ][ category ][ name ] + '.html';
@@ -153,6 +160,22 @@
 
 			}
 
+      function getPageFromList( name ) {
+        for ( var section in pages ) {
+          for ( var category in pages[section] ) {
+            for ( var pageName in pages[section][category] ) {
+              if(pageName === name) {
+                return {
+                         section: section,
+                         category: category,
+                         name: pageName
+                       };
+              }
+            }
+          }        
+        }
+      }
+      
 			window.addEventListener( 'hashchange', goToHash, false );
 
 			if ( window.location.hash.length > 0 ) goToHash();