mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-04-14 08:39:33 +03:00
Use custom URL parser for query parameter
As pointed out by @birjolaxew, URLSearchParams isn't supported by IE. Hence, adding a custom URL parser to get the query parameter.
This commit is contained in:
parent
b395b7837a
commit
bc97a6e0ec
13
index.html
13
index.html
@ -584,6 +584,17 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get any parameter from the URL's search section (location.search).
|
||||||
|
// see
|
||||||
|
// - https://davidwalsh.name/query-string-javascript
|
||||||
|
// - https://github.com/WebReflection/url-search-params
|
||||||
|
function getUrlParameter(parameter) {
|
||||||
|
name = parameter.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
|
||||||
|
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
||||||
|
var results = regex.exec(location.search);
|
||||||
|
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||||
|
}
|
||||||
|
|
||||||
function search(value) {
|
function search(value) {
|
||||||
var hiddenCounter = 0,
|
var hiddenCounter = 0,
|
||||||
value = normalizeSearchTerm(value);
|
value = normalizeSearchTerm(value);
|
||||||
@ -606,7 +617,7 @@
|
|||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Load search query if present
|
// Load search query if present
|
||||||
var query = new URLSearchParams(window.location.search).get(queryParameter);
|
var query = getUrlParameter(queryParameter);
|
||||||
if (query !== null) {
|
if (query !== null) {
|
||||||
$search.classList.add('search--active');
|
$search.classList.add('search--active');
|
||||||
$searchInput.value = query;
|
$searchInput.value = query;
|
||||||
|
Loading…
Reference in New Issue
Block a user