on master help sign in
add in decoding for hash in hallway
commit5e5e0b1fe3deccdd9527b7847b533dfcfcd55217 authorckipp01 <ckipp@pm.me> dateWed 14 Aug 2019, 18:08 (7 years ago) parentf535c4f
1 file changed+7−2
scripts/hallway.js+7−2
scripts/hallway.js+7−2
@@ -11,7 +11,7 @@ function Hallway (sites) {
1111 this._el = document.createElement('div')
1212 this._el.id = 'hallway'
1313 const filterAndPage = window.location.hash.split('^')
14− this.finder = { filter: filterAndPage[0].trim().replace('#', ''), page: filterAndPage[1] || 1 }
14+ this.finder = { filter: stripHash(filterAndPage[0]), page: filterAndPage[1] || 1 }
1515 this.cache = null
1616
1717 this._main = document.createElement('main')
@@ -214,9 +214,14 @@ function escapeHtml (unsafe) {
214214 return unsafe.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;')
215215}
216216
217+function stripHash (hash) {
218+ const decoded = decodeURIComponent(hash)
219+ return decoded.charAt(0) === '#' ? decoded.substring(1) : decoded
220+}
221+
217222function filter (name) {
218223 window.location.hash = name
219224 const filterAndPage = window.location.hash.split('^')
220− hallway.finder = { filter: filterAndPage[0].trim().replace('#', ''), page: filterAndPage[1] || 1 }
225+ hallway.finder = { filter: stripHash(filterAndPage[0]), page: filterAndPage[1] || 1 }
221226 hallway.refresh()
222227}