mirror of
https://github.com/Mibew/simple-icons.git
synced 2024-11-15 18:04:12 +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) {
|
||||
var hiddenCounter = 0,
|
||||
value = normalizeSearchTerm(value);
|
||||
@ -606,7 +617,7 @@
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Load search query if present
|
||||
var query = new URLSearchParams(window.location.search).get(queryParameter);
|
||||
var query = getUrlParameter(queryParameter);
|
||||
if (query !== null) {
|
||||
$search.classList.add('search--active');
|
||||
$searchInput.value = query;
|
||||
|
Loading…
Reference in New Issue
Block a user