tune urls
This commit is contained in:
parent
097d64a2ce
commit
f9578af0e4
2 changed files with 13 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
// FIXME: move to utils
|
||||
// From: https://stackoverflow.com/a/175787
|
||||
|
||||
function isNumeric (str) {
|
||||
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
||||
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
|
||||
|
@ -46,13 +47,21 @@ function parseHash() {
|
|||
var options = {}
|
||||
location.hash.slice(1).split('&').forEach(kv => {
|
||||
kv = kv.split('=')
|
||||
options[kv.shift()] = kv.join('=')
|
||||
const k = kv.shift()
|
||||
if (k.length) {
|
||||
options[k] = kv.join('=')
|
||||
}
|
||||
})
|
||||
return options;
|
||||
}
|
||||
|
||||
function updateHash() {
|
||||
location.hash = '#' + Object.keys(options).map(key => { return key + '=' + options[key]; }).join('&')
|
||||
const value = Object.keys(options).filter(key => {
|
||||
return key && options[key];
|
||||
}).map(key => {
|
||||
return key + '=' + options[key];
|
||||
}).join('&')
|
||||
location.hash = value ? '#' + value : ''
|
||||
}
|
||||
|
||||
document.getElementById('sort-select').addEventListener('change', sortChanged)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="actions">
|
||||
<strong>Filter:</strong>
|
||||
<select id="filter-select">
|
||||
<option value="">All Types</option>
|
||||
<option value="" selected>All Types</option>
|
||||
{% for type in types %}
|
||||
<option value="{{ type.value }}">{{ type.title }}</option>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue