浏览代码

docs: Factor out page pathname

Greg Guthe 12 年之前
父节点
当前提交
c4536881fc
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5 4
      docs/page.js

+ 5 - 4
docs/page.js

@@ -1,19 +1,20 @@
 var onDocumentLoad = function ( event ) {
 var onDocumentLoad = function ( event ) {
 
 
 	var path;
 	var path;
-	var section = /\/(manual|api)\//.exec( window.location.pathname )[ 1 ].toString().split( '.html' )[ 0 ];
-	var name = /[\-A-z0-9]+\.html/.exec( window.location.pathname ).toString().split( '.html' )[ 0 ];
+	var pathname = window.location.pathname;
+	var section = /\/(manual|api)\//.exec( pathname )[ 1 ].toString().split( '.html' )[ 0 ];
+	var name = /[\-A-z0-9]+\.html/.exec( pathname ).toString().split( '.html' )[ 0 ];
 
 
 	if ( section == 'manual' ) {
 	if ( section == 'manual' ) {
 
 
 		name = name.replace(/\-/g, ' ');
 		name = name.replace(/\-/g, ' ');
 
 
-		path = window.location.pathname.replace( /\ /g, '-' );
+		path = pathname.replace( /\ /g, '-' );
 		path = /\/manual\/[-a-z0-9\/]+/.exec( path ).toString().substr( 8 );
 		path = /\/manual\/[-a-z0-9\/]+/.exec( path ).toString().substr( 8 );
 
 
 	} else {
 	} else {
 
 
-		path = /\/api\/[A-z0-9\/]+/.exec( window.location.pathname ).toString().substr( 5 );
+		path = /\/api\/[A-z0-9\/]+/.exec( pathname ).toString().substr( 5 );
 
 
 	}
 	}