瀏覽代碼

view source support (#9225)

Revive  "view-source" support and add a catch and try statement if "view-source" is not available. Note: the relative path on view-source is not working, it has to be a full url for it to work...
verteAzur 9 年之前
父節點
當前提交
448423a55b
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      examples/index.html

+ 8 - 3
examples/index.html

@@ -284,9 +284,14 @@
 		button.id = 'button';
 		button.textContent = 'View source';
 		button.addEventListener( 'click', function ( event ) {
-
-			window.open( 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html' );
-
+			try{
+				var array = location.href.split('/');
+				array.pop();
+				window.open( 'view-source:'+ array.join('/')+ '/' + selected + '.html' );
+			}catch(err){
+				window.open( 'https://github.com/mrdoob/three.js/blob/master/examples/' + selected + '.html' );
+				console.log(err);
+			}
 		}, false );
 		button.style.display = 'none';
 		document.body.appendChild( button );