浏览代码

Docs: Turned conditional into a switch.

Mr.doob 8 年之前
父节点
当前提交
f549b95bc2
共有 1 个文件被更改,包括 12 次插入11 次删除
  1. 12 11
      docs/page.js

+ 12 - 11
docs/page.js

@@ -5,21 +5,22 @@ var onDocumentLoad = function ( event ) {
 	var section = /\/(manual|api|examples)\//.exec( pathname )[ 1 ].toString().split( '.html' )[ 0 ];
 	var name = /[\-A-z0-9]+\.html/.exec( pathname ).toString().split( '.html' )[ 0 ];
 
+	switch ( section ) {
 
-	if ( section == 'manual' ) {
+		case 'api':
+			path = /\/api\/[A-z0-9\/]+/.exec( pathname ).toString().substr( 5 );
+			break;
 
-		name = name.replace( /\-/g, ' ' );
+		case 'examples':
+			path = /\/examples\/[A-z0-9\/]+/.exec( pathname ).toString().substr( 10 );
+			break;
 
-		path = pathname.replace( /\ /g, '-' );
-		path = /\/manual\/[-A-z0-9\/]+/.exec( path ).toString().substr( 8 );
+		case 'manual':
+			name = name.replace( /\-/g, ' ' );
 
-	} else if ( section == 'api' ) {
-
-		path = /\/api\/[A-z0-9\/]+/.exec( pathname ).toString().substr( 5 );
-
-	} else {
-
-		path = /\/examples\/[A-z0-9\/]+/.exec( pathname ).toString().substr( 10 );
+			path = pathname.replace( /\ /g, '-' );
+			path = /\/manual\/[-A-z0-9\/]+/.exec( path ).toString().substr( 8 );
+			break;
 
 	}