From 695c1c52f91f6619e4eaec10d1b8690a5fb904e5 Mon Sep 17 00:00:00 2001 From: octopoulo Date: Wed, 8 Sep 2021 16:25:48 +0200 Subject: [PATCH 1/4] Docs and examples switching retains filter --- docs/index.html | 30 ++++++++++++++++++++++++++++++ examples/index.html | 31 ++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index 663d865ce0022e..0123de1882dbbf 100644 --- a/docs/index.html +++ b/docs/index.html @@ -53,6 +53,7 @@

three.js

const exitSearchButton = document.getElementById( 'exitSearchButton' ); const panelScrim = document.getElementById( 'panelScrim' ); const filterInput = document.getElementById( 'filterInput' ); + const sectionLink = document.querySelector('#sections > a'); let iframe = document.querySelector( 'iframe' ); const pageProperties = {}; @@ -185,6 +186,10 @@

three.js

updateFilter(); + } else { + + updateLink(''); + } } @@ -387,6 +392,31 @@

three.js

displayFilteredPanel(); + updateLink(v); + + } + + function updateLink(search) { + + // update examples link + + if ( ! sectionLink.href2 ) { + + sectionLink.href2 = sectionLink.href; + + } + + if (search) { + + let link = sectionLink.href.split(/[?#]/)[0]; + sectionLink.href = `${link}?q=${search}`; + + } else { + + sectionLink.href = sectionLink.href2; + + } + } function displayFilteredPanel() { diff --git a/examples/index.html b/examples/index.html index efef034ad47706..13819fec793920 100644 --- a/examples/index.html +++ b/examples/index.html @@ -53,7 +53,7 @@

three.js

const expandButton = document.getElementById( 'expandButton' ); const viewSrcButton = document.getElementById( 'button' ); const panelScrim = document.getElementById( 'panelScrim' ); - + const sectionLink = document.querySelector('#sections > a'); const previewsToggler = document.getElementById( 'previewsToggler' ); const links = {}; @@ -120,6 +120,10 @@

three.js

updateFilter( files, tags ); + } else { + + updateLink(''); + } // Events @@ -267,6 +271,31 @@

three.js

layoutList( files ); + updateLink( v ); + + } + + function updateLink(search) { + + // update examples link + + if ( ! sectionLink.href2 ) { + + sectionLink.href2 = sectionLink.href; + + } + + if (search) { + + let link = sectionLink.href.split(/[?#]/)[0]; + sectionLink.href = `${link}?q=${search}`; + + } else { + + sectionLink.href = sectionLink.href2; + + } + } function filterExample( file, exp, tags ) { From 22da42ffd7a36609ee5d5af9bac8597cd0e00dc7 Mon Sep 17 00:00:00 2001 From: octopoulo Date: Wed, 8 Sep 2021 17:08:40 +0200 Subject: [PATCH 2/4] Using the same code formatting --- docs/index.html | 10 +++++----- examples/index.html | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/index.html b/docs/index.html index 0123de1882dbbf..3d8ca192ec7c36 100644 --- a/docs/index.html +++ b/docs/index.html @@ -53,7 +53,7 @@

three.js

const exitSearchButton = document.getElementById( 'exitSearchButton' ); const panelScrim = document.getElementById( 'panelScrim' ); const filterInput = document.getElementById( 'filterInput' ); - const sectionLink = document.querySelector('#sections > a'); + const sectionLink = document.querySelector( '#sections > a' ); let iframe = document.querySelector( 'iframe' ); const pageProperties = {}; @@ -188,7 +188,7 @@

three.js

} else { - updateLink(''); + updateLink( '' ); } @@ -396,7 +396,7 @@

three.js

} - function updateLink(search) { + function updateLink( search ) { // update examples link @@ -406,9 +406,9 @@

three.js

} - if (search) { + if ( search ) { - let link = sectionLink.href.split(/[?#]/)[0]; + let link = sectionLink.href.split( /[?#]/ )[ 0 ]; sectionLink.href = `${link}?q=${search}`; } else { diff --git a/examples/index.html b/examples/index.html index 13819fec793920..1edb56f2a832b9 100644 --- a/examples/index.html +++ b/examples/index.html @@ -53,7 +53,7 @@

three.js

const expandButton = document.getElementById( 'expandButton' ); const viewSrcButton = document.getElementById( 'button' ); const panelScrim = document.getElementById( 'panelScrim' ); - const sectionLink = document.querySelector('#sections > a'); + const sectionLink = document.querySelector( '#sections > a' ); const previewsToggler = document.getElementById( 'previewsToggler' ); const links = {}; @@ -122,7 +122,7 @@

three.js

} else { - updateLink(''); + updateLink( '' ); } @@ -275,7 +275,7 @@

three.js

} - function updateLink(search) { + function updateLink( search ) { // update examples link @@ -285,9 +285,9 @@

three.js

} - if (search) { + if ( search ) { - let link = sectionLink.href.split(/[?#]/)[0]; + let link = sectionLink.href.split( /[?#]/ )[ 0 ]; sectionLink.href = `${link}?q=${search}`; } else { From 7a4bca7011fb4bad9a2f9124de1956705b224c88 Mon Sep 17 00:00:00 2001 From: octopoulo Date: Wed, 8 Sep 2021 17:12:46 +0200 Subject: [PATCH 3/4] Last code formatting fix --- docs/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index 3d8ca192ec7c36..591e5e9a3ce153 100644 --- a/docs/index.html +++ b/docs/index.html @@ -392,7 +392,7 @@

three.js

displayFilteredPanel(); - updateLink(v); + updateLink( v ); } From cf1fe6f22f17017c19b3be0b5da26d570f16e021 Mon Sep 17 00:00:00 2001 From: octopoulo Date: Thu, 9 Sep 2021 13:02:29 +0200 Subject: [PATCH 4/4] Simplified code --- docs/index.html | 12 ++++-------- examples/index.html | 14 +++++--------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/docs/index.html b/docs/index.html index 591e5e9a3ce153..be0e2dbdd40ba5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -53,9 +53,11 @@

three.js

const exitSearchButton = document.getElementById( 'exitSearchButton' ); const panelScrim = document.getElementById( 'panelScrim' ); const filterInput = document.getElementById( 'filterInput' ); - const sectionLink = document.querySelector( '#sections > a' ); let iframe = document.querySelector( 'iframe' ); + const sectionLink = document.querySelector( '#sections > a' ); + const sectionDefaultHref = sectionLink.href; + const pageProperties = {}; const titles = {}; const categoryElements = []; @@ -400,12 +402,6 @@

three.js

// update examples link - if ( ! sectionLink.href2 ) { - - sectionLink.href2 = sectionLink.href; - - } - if ( search ) { let link = sectionLink.href.split( /[?#]/ )[ 0 ]; @@ -413,7 +409,7 @@

three.js

} else { - sectionLink.href = sectionLink.href2; + sectionLink.href = sectionDefaultHref; } diff --git a/examples/index.html b/examples/index.html index 1edb56f2a832b9..64ad421c73b1c5 100644 --- a/examples/index.html +++ b/examples/index.html @@ -53,9 +53,11 @@

three.js

const expandButton = document.getElementById( 'expandButton' ); const viewSrcButton = document.getElementById( 'button' ); const panelScrim = document.getElementById( 'panelScrim' ); - const sectionLink = document.querySelector( '#sections > a' ); const previewsToggler = document.getElementById( 'previewsToggler' ); + const sectionLink = document.querySelector( '#sections > a' ); + const sectionDefaultHref = sectionLink.href; + const links = {}; const validRedirects = new Map(); const container = document.createElement( 'div' ); @@ -277,13 +279,7 @@

three.js

function updateLink( search ) { - // update examples link - - if ( ! sectionLink.href2 ) { - - sectionLink.href2 = sectionLink.href; - - } + // update docs link if ( search ) { @@ -292,7 +288,7 @@

three.js

} else { - sectionLink.href = sectionLink.href2; + sectionLink.href = sectionDefaultHref; }