diff --git a/_data/simple-icons.json b/_data/simple-icons.json index 3d756a5c..15467db4 100644 --- a/_data/simple-icons.json +++ b/_data/simple-icons.json @@ -602,8 +602,8 @@ }, { "title": "Eventbrite", - "hex": "F6682F", - "source": "https://www.eventbrite.com" + "hex": "F05537", + "source": "https://www.eventbrite.com/signin/" }, { "title": "Event Store", diff --git a/icons/eventbrite.svg b/icons/eventbrite.svg index ace10b77..8141f904 100644 --- a/icons/eventbrite.svg +++ b/icons/eventbrite.svg @@ -1 +1 @@ -Eventbrite icon \ No newline at end of file +Eventbrite icon \ No newline at end of file diff --git a/package.json b/package.json index 87db8c4d..2f169677 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simple-icons", - "version": "1.9.11", + "version": "1.9.12", "description": "SVG icons for popular brands https://simpleicons.org", "homepage": "https://www.simpleicons.org", "keywords": [ diff --git a/site_script.js b/site_script.js index 36546bca..01cf24f6 100644 --- a/site_script.js +++ b/site_script.js @@ -1,16 +1,17 @@ (function(document) { - var $grid = document.querySelector('.grid'), - $icons = $grid.querySelectorAll('.grid-item:not(.grid-item--ad)'), - $search = document.querySelector('.search'), - $searchClose = $search.querySelector('.search__close'), - $searchInput = $search.querySelector('input'), - $sortColor = document.getElementById('sort-color'), - $sortAlphabetically = document.getElementById('sort-alphabetically'), - $sortRelevance = document.getElementById('sort-relevance'); + var $grid = document.querySelector('.grid'), + $icons = $grid.querySelectorAll('.grid-item:not(.grid-item--ad)'), + $search = document.querySelector('.search'), + $searchClose = $search.querySelector('.search__close'), + $searchInput = $search.querySelector('input'), + $orderByColor = document.getElementById('sort-color'), + $orderAlphabetically = document.getElementById('sort-alphabetically'), + $orderByRelevance = document.getElementById('sort-relevance'); var queryParameter = 'q', + orderingPreferenceIdentifier = 'ordering-preference', previousQuery = null, - previousOrder = $sortColor; + previousOrdering = $orderByColor; // Remove the "disabled" attribute from the search input $searchInput.setAttribute('title', 'Search Simple Icons'); @@ -108,47 +109,61 @@ $grid.classList.toggle('search__empty', matchedIcons.length == 0); if (query === '') { - if ($sortRelevance.classList.contains('active')) { - selectSortingOrder(previousOrder); + if ($orderByRelevance.classList.contains('active')) { + selectOrdering(previousOrdering); } - $sortRelevance.setAttribute('display', 'none'); + $orderByRelevance.setAttribute('display', 'none'); previousQuery = null; } else { if (previousQuery === null) { - selectSortingOrder($sortRelevance); + selectOrdering($orderByRelevance); } previousQuery = query; } } - function sort() { - if ($sortColor.classList.contains('active')) { + function orderIcons() { + if ($orderByColor.classList.contains('active')) { $icons.forEach(icon => { icon.style.order = null; }); - } else if ($sortAlphabetically.classList.contains('active')) { + } else if ($orderAlphabetically.classList.contains('active')) { $icons.forEach(icon => { icon.style.order = icon.getAttribute('order'); }); - } else if ($sortRelevance.classList.contains('active')) { + } else if ($orderByRelevance.classList.contains('active')) { $icons.forEach(icon => { icon.style.order = icon.getAttribute('data-relevance'); }); } } - function selectSortingOrder(selected) { + function selectOrdering(selected) { selected.classList.add('active'); - var options = [$sortColor, $sortAlphabetically, $sortRelevance]; + var options = [$orderByColor, $orderAlphabetically, $orderByRelevance]; for (var option of options.filter(option => option !== selected)) { option.classList.remove('active'); } - if (selected !== $sortRelevance) { - previousOrder = selected; + if (selected !== $orderByRelevance) { + previousOrdering = selected; } else { - $sortRelevance.removeAttribute('display'); + $orderByRelevance.removeAttribute('display'); } - sort(); + orderIcons(); + + // Store ordering preference + var preferenceOptions = [$orderByColor, $orderAlphabetically]; + if (localStorage && preferenceOptions.includes(selected)) { + localStorage.setItem(orderingPreferenceIdentifier, selected.id); + } } document.addEventListener('DOMContentLoaded', function() { + // Restore ordering preference of the user. This should be performed before + // applying the search query as it would overwrite "order by relevance" + if (localStorage) { + var storedOrderingId = localStorage.getItem(orderingPreferenceIdentifier); + var ordering = document.getElementById(storedOrderingId); + if (ordering) selectOrdering(ordering); + } + // Load search query if present var query = getUrlParameter(queryParameter); if (query) { @@ -179,13 +194,13 @@ search(''); }, false); - $sortColor.addEventListener('click', function() { - selectSortingOrder($sortColor); + $orderByColor.addEventListener('click', function() { + selectOrdering($orderByColor); }); - $sortAlphabetically.addEventListener('click', function() { - selectSortingOrder($sortAlphabetically); + $orderAlphabetically.addEventListener('click', function() { + selectOrdering($orderAlphabetically); }); - $sortRelevance.addEventListener('click', function() { - selectSortingOrder($sortRelevance); + $orderByRelevance.addEventListener('click', function() { + selectOrdering($orderByRelevance); }); })( document );