2
0
Эх сурвалжийг харах

Implemented cross-referencing functions for members

Casey Grun 10 жил өмнө
parent
commit
50b3e1d638
2 өөрчлөгдсөн 24 нэмэгдсэн , 7 устгасан
  1. 18 6
      docs/index.html
  2. 6 1
      docs/page.js

+ 18 - 6
docs/index.html

@@ -351,23 +351,35 @@
 
 
 			// Page loading
 			// Page loading
 
 
-			function goTo( section, category, name ) {
+			function goTo( section, category, name, member ) {
+				var parts, location;
+				var MEMBER_DELIMITER = '.'
 
 
 				// Fully resolve links that only provide a name
 				// Fully resolve links that only provide a name
 				if(arguments.length == 1) {
 				if(arguments.length == 1) {
-					var location = nameCategoryMap[section];
+
+					// Resolve links of the form 'Class.member'
+					if(section.indexOf(MEMBER_DELIMITER) !== -1) {
+						parts = section.split(MEMBER_DELIMITER)
+						section = parts[0]; 
+						member = parts[1];
+					}
+
+					location = nameCategoryMap[section];
+					if (!location) return;
 					section = location.section;
 					section = location.section;
 					category = location.category;
 					category = location.category;
 					name = location.name;
 					name = location.name;
-				}
+				} 
 
 
 				var title = 'three.js - documentation - ' + section + ' - ' + name;
 				var title = 'three.js - documentation - ' + section + ' - ' + name;
-				var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name);
+				var url = encodeUrl(section) + DELIMITER + encodeUrl( category ) + DELIMITER + encodeUrl(name) + (!!member ? DELIMITER + encodeUrl(member) : '');
 
 
 				window.location.hash = url;
 				window.location.hash = url;
 				window.document.title = title;
 				window.document.title = title;
 
 
-				viewer.src = pages[ section ][ category ][ name ] + '.html';
+				viewer.src = pages[ section ][ category ][ name ] + '.html' + (!!member ? '#'+member : '');
+
 				panel.classList.add( 'collapsed' );
 				panel.classList.add( 'collapsed' );
 
 
 			}
 			}
@@ -375,7 +387,7 @@
 			function goToHash() {
 			function goToHash() {
 
 
 				var hash = window.location.hash.substring( 1 ).split(DELIMITER);
 				var hash = window.location.hash.substring( 1 ).split(DELIMITER);
-				goTo( decodeUrl(hash[0]), decodeUrl(hash[1]), decodeUrl(hash[2]) );
+				goTo( decodeUrl(hash[0]), decodeUrl(hash[1]), decodeUrl(hash[2]), decodeUrl(hash.length > 3 ? hash[3] : '') );
 
 
 			}
 			}
 
 

+ 6 - 1
docs/page.js

@@ -23,7 +23,12 @@ var onDocumentLoad = function ( event ) {
 	text = text.replace(/\[name\]/gi, name);
 	text = text.replace(/\[name\]/gi, name);
 	text = text.replace(/\[path\]/gi, path);
 	text = text.replace(/\[path\]/gi, path);
 	text = text.replace(/\[page:(\w+)\]/gi, "[page:$1 $1]" ); // [page:name] to [page:name title]
 	text = text.replace(/\[page:(\w+)\]/gi, "[page:$1 $1]" ); // [page:name] to [page:name title]
-	text = text.replace(/\[page:(\w+) ([\w|\.]+)\]/gi, "<a href=\"javascript:window.parent.goTo('$1')\" title=\"$1\">$2</a>" ); // [page:name title]
+	text = text.replace(/\[page:(\w+) ([\w|\.]+)\]/gi, "<a href=\"javascript:window.parent.goTo('$1')\" title=\"$1\" id=\"$2\">$2</a>" ); // [page:name title]
+
+	text = text.replace(/\[member:([\w.]+)\]/gi, "[member:$1 $1]" ); // [member:name] to [member:name title]
+	text = text.replace(/\[member:.([\w]+) ([\w\.]+)\]/gi, "<a href=\"javascript:window.parent.goTo('" + name + ".$1')\" title=\"$1\">$2</a>" );
+	text = text.replace(/\[member:([\w\.]+) ([\w\.]+)\]/gi, "<a href=\"javascript:window.parent.goTo('$1')\" title=\"$1\">$2</a>" );
+
 	text = text.replace(/\[link:([\w|\:|\/|\.|\-|\_]+)\]/gi, "[link:$1 $1]" ); // [link:url] to [link:url title]
 	text = text.replace(/\[link:([\w|\:|\/|\.|\-|\_]+)\]/gi, "[link:$1 $1]" ); // [link:url] to [link:url title]
 	text = text.replace(/\[link:([\w|\:|\/|\.|\-|\_|\(|\)]+) ([\w|\:|\/|\.|\-|\_ ]+)\]/gi, "<a href=\"$1\"  target=\"_blank\">$2</a>" ); // [link:url title]
 	text = text.replace(/\[link:([\w|\:|\/|\.|\-|\_|\(|\)]+) ([\w|\:|\/|\.|\-|\_ ]+)\]/gi, "<a href=\"$1\"  target=\"_blank\">$2</a>" ); // [link:url title]
 	text = text.replace(/\*([\w|\d|\"|\-|\(][\w|\d|\ |\-|\/|\+|\-|\(|\)|\=|\,|\.\"]*[\w|\d|\"|\)]|\w)\*/gi, "<strong>$1</strong>" ); // *
 	text = text.replace(/\*([\w|\d|\"|\-|\(][\w|\d|\ |\-|\/|\+|\-|\(|\)|\=|\,|\.\"]*[\w|\d|\"|\)]|\w)\*/gi, "<strong>$1</strong>" ); // *