in index.js [844:935]
function _applyFragment (fragment) {
if (!fragment || fragment.substr(0, 2) !== '#?') return
fragment = fragment.substring(2) // remove the #?
// use this literal's keys as the source of truth for key-value pairs in the fragment
var actions = { proposal: [], search: null, status: [], version: [] }
// parse the fragment as a query string
Object.keys(actions).forEach(function (action) {
var pattern = new RegExp(action + '=([^=]+)(&|$)')
var values = fragment.match(pattern)
if (values) {
var value = values[1] // 1st capture group from the RegExp
if (action === 'search') {
value = decodeURIComponent(value)
} else {
value = value.split(',')
}
actions[action] = value
}
})
// perform key-specific parsing and checks
if (actions.proposal.length) {
document.querySelector('#search-filter').value = actions.proposal.join(',')
} else if (actions.search) {
document.querySelector('#search-filter').value = actions.search
}
if (actions.version.length) {
var versionSelections = actions.version.map(function (version) {
return document.querySelector('#filter-by-swift-' + _idSafeName(version))
}).filter(function (version) {
return !!version
})
versionSelections.forEach(function (versionSelection) {
versionSelection.checked = true
})
if (versionSelections.length) {
document.querySelector(
'#filter-by-' + states['.implemented'].className
).checked = true
}
}
// track this state specifically for toggling the version panel
var implementedSelected = false
// update the filter selections in the nav
if (actions.status.length) {
var statusSelections = actions.status.map(function (status) {
var stateName = Object.keys(states).filter(function (state) {
return states[state].className === status
})[0]
if (!stateName) return // fragment contains a nonexistent state
var state = states[stateName]
if (stateName === '.implemented') implementedSelected = true
return document.querySelector('#filter-by-' + state.className)
}).filter(function (status) {
return !!status
})
statusSelections.forEach(function (statusSelection) {
statusSelection.checked = true
})
}
// the version panel needs to be activated if any are specified
if (actions.version.length || implementedSelected) {
;['#version-options', '#version-options-label'].forEach(function (selector) {
document.querySelector('.filter-options')
.querySelector(selector).classList
.toggle('hidden')
})
}
// specifying any filter in the fragment should activate the filters in the UI
if (actions.version.length || actions.status.length) {
toggleFilterPanel()
toggleFiltering()
}
filterProposals()
}