From beed901a2c04e4a14555b7c9957a2b4f8a379aac Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sun, 26 Jun 2016 10:14:25 -0700 Subject: [PATCH] Examples: Clean up. --- examples/index.html | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/index.html b/examples/index.html index 7228f88c31..79e7ed5537 100644 --- a/examples/index.html +++ b/examples/index.html @@ -247,7 +247,7 @@ var p = window.location.search.indexOf( '?q=' ) if( p !== -1 ) { return window.location.search.substr( 3 ); - } + } return '' } @@ -284,14 +284,19 @@ button.id = 'button'; button.textContent = 'View source'; 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' ); - console.log(err); + console.log( e ); + } + }, false ); button.style.display = 'none'; document.body.appendChild( button ); -- GitLab