浏览代码

Docs: Fix edit button

Mugen87 6 年之前
父节点
当前提交
e710ed7f4d
共有 1 个文件被更改,包括 7 次插入7 次删除
  1. 7 7
      docs/page.js

+ 7 - 7
docs/page.js

@@ -17,7 +17,7 @@ if ( !window.frameElement && window.location.protocol !== 'file:' ) {
 
 
 	}
 	}
 
 
-	var pathSnippet = href.slice( splitIndex, -5 );
+	var pathSnippet = href.slice( splitIndex, - 5 );
 
 
 	window.location.replace( docsBaseURL + '#' + pathSnippet + hash );
 	window.location.replace( docsBaseURL + '#' + pathSnippet + hash );
 
 
@@ -26,7 +26,7 @@ if ( !window.frameElement && window.location.protocol !== 'file:' ) {
 
 
 function onDocumentLoad( event ) {
 function onDocumentLoad( event ) {
 
 
-	var path;
+	var path, localizedPath;
 	var pathname = window.location.pathname;
 	var pathname = window.location.pathname;
 	var section = /\/(manual|api|examples)\//.exec( pathname )[ 1 ].toString().split( '.html' )[ 0 ];
 	var section = /\/(manual|api|examples)\//.exec( pathname )[ 1 ].toString().split( '.html' )[ 0 ];
 	var name = /[\-A-z0-9]+\.html/.exec( pathname ).toString().split( '.html' )[ 0 ];
 	var name = /[\-A-z0-9]+\.html/.exec( pathname ).toString().split( '.html' )[ 0 ];
@@ -34,22 +34,22 @@ function onDocumentLoad( event ) {
 	switch ( section ) {
 	switch ( section ) {
 
 
 		case 'api':
 		case 'api':
-			path = /\/api\/[A-z0-9\/]+/.exec( pathname ).toString().substr( 5 );
+			localizedPath = /\/api\/[A-z0-9\/]+/.exec( pathname ).toString().substr( 5 );
 
 
 			// Remove localized part of the path (e.g. 'en/' or 'es-MX/'):
 			// Remove localized part of the path (e.g. 'en/' or 'es-MX/'):
-			path = path.replace( /^[A-z0-9-]+\//, '' );
+			path = localizedPath.replace( /^[A-z0-9-]+\//, '' );
 
 
 			break;
 			break;
 
 
 		case 'examples':
 		case 'examples':
-			path = /\/examples\/[A-z0-9\/]+/.exec( pathname ).toString().substr( 10 );
+			path = localizedPath = /\/examples\/[A-z0-9\/]+/.exec( pathname ).toString().substr( 10 );
 			break;
 			break;
 
 
 		case 'manual':
 		case 'manual':
 			name = name.replace( /\-/g, ' ' );
 			name = name.replace( /\-/g, ' ' );
 
 
 			path = pathname.replace( /\ /g, '-' );
 			path = pathname.replace( /\ /g, '-' );
-			path = /\/manual\/[-A-z0-9\/]+/.exec( path ).toString().substr( 8 );
+			path = localizedPath = /\/manual\/[-A-z0-9\/]+/.exec( path ).toString().substr( 8 );
 			break;
 			break;
 
 
 	}
 	}
@@ -101,7 +101,7 @@ function onDocumentLoad( event ) {
 
 
 	button.addEventListener( 'click', function ( event ) {
 	button.addEventListener( 'click', function ( event ) {
 
 
-		window.open( 'https://github.com/mrdoob/three.js/blob/dev/docs/' + section + '/' + path + '.html' );
+		window.open( 'https://github.com/mrdoob/three.js/blob/dev/docs/' + section + '/' + localizedPath + '.html' );
 
 
 	}, false );
 	}, false );