Skip to content

Commit

Permalink
Add "#none" command to the url
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneCharignon committed Sep 22, 2018
1 parent cedcab3 commit 6f62d8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 8 additions & 3 deletions public/paysagerenderer/visibility_management.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions spec/public/paysagerenderer/visibility_management_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 6f62d8f

Please sign in to comment.