Explorar o código

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 %!s(int64=9) %!d(string=hai) anos
pai
achega
448423a55b
Modificáronse 1 ficheiros con 8 adicións e 3 borrados
  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 );