Browse Source

Examples: Clean up.

Mugen87 4 years ago
parent
commit
b23a10f22f
2 changed files with 42 additions and 42 deletions
  1. 2 2
      examples/files.js
  2. 40 40
      examples/index.html

+ 2 - 2
examples/files.js

@@ -1,4 +1,4 @@
-var files = {
+const files = {
 	"webgl": [
 	"webgl": [
 		"webgl_animation_cloth",
 		"webgl_animation_cloth",
 		"webgl_animation_keyframes",
 		"webgl_animation_keyframes",
@@ -404,7 +404,7 @@ var files = {
 	]
 	]
 };
 };
 
 
-var tags = {
+const tags = {
 	"webgl_animation_cloth": [ "physics", "integration" ],
 	"webgl_animation_cloth": [ "physics", "integration" ],
 	"webgl_clipping": [ "solid" ],
 	"webgl_clipping": [ "solid" ],
 	"webgl_clipping_advanced": [ "solid" ],
 	"webgl_clipping_advanced": [ "solid" ],

+ 40 - 40
examples/index.html

@@ -46,20 +46,21 @@
 
 
 		<script>
 		<script>
 
 
-		var panel = document.getElementById( 'panel' );
-		var content = document.getElementById( 'content' );
-		var viewer = document.getElementById( 'viewer' );
-		var filterInput = document.getElementById( 'filterInput' );
-		var exitSearchButton = document.getElementById( 'exitSearchButton' );
-		var expandButton = document.getElementById( 'expandButton' );
-		var viewSrcButton = document.getElementById( 'button' );
-		var panelScrim = document.getElementById( 'panelScrim' );
+		const panel = document.getElementById( 'panel' );
+		const content = document.getElementById( 'content' );
+		const viewer = document.getElementById( 'viewer' );
+		const filterInput = document.getElementById( 'filterInput' );
+		const exitSearchButton = document.getElementById( 'exitSearchButton' );
+		const expandButton = document.getElementById( 'expandButton' );
+		const viewSrcButton = document.getElementById( 'button' );
+		const panelScrim = document.getElementById( 'panelScrim' );
 
 
-		var previewsToggler = document.getElementById( 'previewsToggler' );
+		const previewsToggler = document.getElementById( 'previewsToggler' );
 
 
-		var links = {};
-		var selected = null;
-		var container = document.createElement( 'div' );
+		const links = {};
+		const container = document.createElement( 'div' );
+
+		let selected = null;
 
 
 		init();
 		init();
 
 
@@ -69,20 +70,20 @@
 
 
 			viewSrcButton.style.display = 'none';
 			viewSrcButton.style.display = 'none';
 
 
-			for ( var key in files ) {
+			for ( const key in files ) {
 
 
-				var section = files[ key ];
+				const section = files[ key ];
 
 
-				var header = document.createElement( 'h2' );
+				const header = document.createElement( 'h2' );
 				header.textContent = key;
 				header.textContent = key;
 				header.setAttribute( 'data-category', key );
 				header.setAttribute( 'data-category', key );
 				container.appendChild( header );
 				container.appendChild( header );
 
 
-				for ( var i = 0; i < section.length; i ++ ) {
+				for ( let i = 0; i < section.length; i ++ ) {
 
 
-					var file = section[ i ];
+					const file = section[ i ];
 
 
-					var link = createLink( file );
+					const link = createLink( file );
 					container.appendChild( link );
 					container.appendChild( link );
 
 
 					links[ file ] = link;
 					links[ file ] = link;
@@ -175,8 +176,7 @@
 
 
 		function createLink( file ) {
 		function createLink( file ) {
 
 
-
-			var template = [
+			const template = [
 				'<div class="card">',
 				'<div class="card">',
 				'	<a href="' + file + '.html" target="viewer">',
 				'	<a href="' + file + '.html" target="viewer">',
 				'		<div class="cover">',
 				'		<div class="cover">',
@@ -187,7 +187,7 @@
 				'</div>'
 				'</div>'
 			].join( "\n" );
 			].join( "\n" );
 
 
-			var link = createElementFromHTML( template );
+			const link = createElementFromHTML( template );
 
 
 			link.querySelector( 'a[target="viewer"]' ).addEventListener( 'click', function ( event ) {
 			link.querySelector( 'a[target="viewer"]' ).addEventListener( 'click', function ( event ) {
 
 
@@ -230,7 +230,7 @@
 
 
 		function updateFilter() {
 		function updateFilter() {
 
 
-			var v = filterInput.value.trim();
+			let v = filterInput.value.trim();
 			v = v.replace( /\s+/gi, ' ' ); // replace multiple whitespaces with a single one
 			v = v.replace( /\s+/gi, ' ' ); // replace multiple whitespaces with a single one
 
 
 			if ( v !== '' ) {
 			if ( v !== '' ) {
@@ -243,13 +243,13 @@
 
 
 			}
 			}
 
 
-			var exp = new RegExp( v, 'gi' );
+			const exp = new RegExp( v, 'gi' );
 
 
-			for ( var key in files ) {
+			for ( const key in files ) {
 
 
-				var section = files[ key ];
+				const section = files[ key ];
 
 
-				for ( var i = 0; i < section.length; i ++ ) {
+				for ( let i = 0; i < section.length; i ++ ) {
 
 
 					filterExample( section[ i ], exp );
 					filterExample( section[ i ], exp );
 
 
@@ -263,17 +263,17 @@
 
 
 		function filterExample( file, exp ) {
 		function filterExample( file, exp ) {
 
 
-			var link = links[ file ];
-			var name = getName( file );
+			const link = links[ file ];
+			const name = getName( file );
 			if ( file in tags ) file += ' ' + tags[ file ].join( ' ' );
 			if ( file in tags ) file += ' ' + tags[ file ].join( ' ' );
-			var res = file.match( exp );
-			var text;
+			const res = file.match( exp );
+			let text;
 
 
 			if ( res && res.length > 0 ) {
 			if ( res && res.length > 0 ) {
 
 
 				link.classList.remove( 'hidden' );
 				link.classList.remove( 'hidden' );
 
 
-				for ( var i = 0; i < res.length; i ++ ) {
+				for ( let i = 0; i < res.length; i ++ ) {
 
 
 					text = name.replace( res[ i ], '<b>' + res[ i ] + '</b>' );
 					text = name.replace( res[ i ], '<b>' + res[ i ] + '</b>' );
 
 
@@ -292,7 +292,7 @@
 
 
 		function getName( file ) {
 		function getName( file ) {
 
 
-			var name = file.split( '_' );
+			const name = file.split( '_' );
 			name.shift();
 			name.shift();
 			return name.join( ' / ' );
 			return name.join( ' / ' );
 
 
@@ -300,15 +300,15 @@
 
 
 		function layoutList() {
 		function layoutList() {
 
 
-			for ( var key in files ) {
+			for ( const key in files ) {
 
 
-				var collapsed = true;
+				let collapsed = true;
 
 
-				var section = files[ key ];
+				const section = files[ key ];
 
 
-				for ( var i = 0; i < section.length; i ++ ) {
+				for ( let i = 0; i < section.length; i ++ ) {
 
 
-					var file = section[ i ];
+					const file = section[ i ];
 
 
 					if ( links[ file ].classList.contains( 'hidden' ) === false ) {
 					if ( links[ file ].classList.contains( 'hidden' ) === false ) {
 
 
@@ -319,7 +319,7 @@
 
 
 				}
 				}
 
 
-				var element = document.querySelector( 'h2[data-category="' + key + '"]' );
+				const element = document.querySelector( 'h2[data-category="' + key + '"]' );
 
 
 				if ( collapsed ) {
 				if ( collapsed ) {
 
 
@@ -337,7 +337,7 @@
 
 
 		function extractQuery() {
 		function extractQuery() {
 
 
-			var p = window.location.search.indexOf( '?q=' );
+			const p = window.location.search.indexOf( '?q=' );
 
 
 			if ( p !== - 1 ) {
 			if ( p !== - 1 ) {
 
 
@@ -352,7 +352,7 @@
 
 
 		function createElementFromHTML( htmlString ) {
 		function createElementFromHTML( htmlString ) {
 
 
-			var div = document.createElement( 'div' );
+			const div = document.createElement( 'div' );
 			div.innerHTML = htmlString.trim();
 			div.innerHTML = htmlString.trim();
 			return div.firstChild;
 			return div.firstChild;