diff --git a/public/paysagerenderer/visibility_management.js b/public/paysagerenderer/visibility_management.js index 2f5ea8f..9fa6ba2 100644 --- a/public/paysagerenderer/visibility_management.js +++ b/public/paysagerenderer/visibility_management.js @@ -1,11 +1,16 @@ /* eslint no-eval: "off" */ var Paysage = window.Paysage || {}; +const ONLY_COMMAND = '#only='; + Paysage.readIdsFromUrlHash = function (urlHash) { - if (urlHash.length <= 1) { - return undefined; + if (urlHash.startsWith(ONLY_COMMAND)) { + return urlHash.substring(ONLY_COMMAND.length).split(','); + } + if (urlHash === "#none") { + return []; } - return urlHash.substring(1).split(','); + return undefined; }; Paysage.showCodeObjects = function (allIds, idsToShow, show, hide) { diff --git a/spec/public/paysagerenderer/visibility_management_spec.js b/spec/public/paysagerenderer/visibility_management_spec.js index 951b7a9..59572c7 100644 --- a/spec/public/paysagerenderer/visibility_management_spec.js +++ b/spec/public/paysagerenderer/visibility_management_spec.js @@ -4,8 +4,9 @@ describe('The Paysage renderer visibility management', function () { it('can parse Url hash for code objects ids to display', function () { expect(Paysage.readIdsFromUrlHash('')).toEqual(undefined); expect(Paysage.readIdsFromUrlHash('#')).toEqual(undefined); - expect(Paysage.readIdsFromUrlHash('#toto')).toEqual(['toto']); - expect(Paysage.readIdsFromUrlHash('#toto,titi')).toEqual(['toto', 'titi']); + expect(Paysage.readIdsFromUrlHash('#only=toto')).toEqual(['toto']); + expect(Paysage.readIdsFromUrlHash('#only=toto,titi')).toEqual(['toto', 'titi']); + expect(Paysage.readIdsFromUrlHash('#none')).toEqual([]); }); describe('has code object filtering', function () {