瀏覽代碼

Examples: Clean up.

Mr.doob 9 年之前
父節點
當前提交
beed901a2c
共有 1 個文件被更改,包括 12 次插入7 次删除
  1. 12 7
      examples/index.html

+ 12 - 7
examples/index.html

@@ -247,7 +247,7 @@
 			var p = window.location.search.indexOf( '?q=' )
 			var p = window.location.search.indexOf( '?q=' )
 			if( p !== -1 ) {
 			if( p !== -1 ) {
 				return window.location.search.substr( 3 );
 				return window.location.search.substr( 3 );
-			} 
+			}
 			return ''
 			return ''
 		}
 		}
 
 
@@ -284,14 +284,19 @@
 		button.id = 'button';
 		button.id = 'button';
 		button.textContent = 'View source';
 		button.textContent = 'View source';
 		button.addEventListener( 'click', function ( event ) {
 		button.addEventListener( 'click', function ( event ) {
-			try{
-				var array = location.href.split('/');
-				array.pop();
-				window.open( 'view-source:'+ array.join('/')+ '/' + selected + '.html' );
-			}catch(err){
+
+			try {
+
+				var url = location.href.split( '/' ).slice( 0, - 1 ).join( '/' );
+				window.open( 'view-source:' + url + '/' + selected + '.html' );
+
+			} catch ( e ) {
+
 				window.open( 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html' );
 				window.open( 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html' );
-				console.log(err);
+				console.log( e );
+
 			}
 			}
+
 		}, false );
 		}, false );
 		button.style.display = 'none';
 		button.style.display = 'none';
 		document.body.appendChild( button );
 		document.body.appendChild( button );