Skip to content

Commit

Permalink
Merge pull request #72 from das-s/rename-filtering
Browse files Browse the repository at this point in the history
Rename the filtering menu to exclusion/inclusion
  • Loading branch information
goktug97 authored Aug 1, 2020
2 parents fcfe94d + a223ef0 commit 0c5d430
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
<input id="inputdistance" name="distance" type="number" value="1" min="0" pattern="\d+" />
</div>
<button class="btn btn-primary btn-danger btn-sm" id="toggle-list-type-button">
Blacklist
Exclude
</button>
<button class="btn btn-primary btn-danger btn-sm" id="reload-button">
Reload
Expand Down Expand Up @@ -372,16 +372,16 @@
var nodeDataset = new vis.DataSet();
var edgeDataset = new vis.DataSet();

var whitelistFilters = new Set();
var blacklistFilters = new Set();
var includeFilters = new Set();
var excludeFilters = new Set();
var colors = new Array();
var view = new vis.DataView(nodeDataset, {
filter: function (item) {
//Blacklist has precidence
if (blacklistFilters.size > 0) {
//Exclude has precidence
if (excludeFilters.size > 0) {
if (item.tags) {
let itemTags = new Set(item.tags);
for (let filter of blacklistFilters.values()) {
for (let filter of excludeFilters.values()) {
var parsed_filter = JSON.parse(filter);
if (parsed_filter.parent === "tags"){
if (itemTags.has(parsed_filter.id)){
Expand All @@ -391,10 +391,10 @@
}
}
}
if (whitelistFilters.size > 0) {
if (includeFilters.size > 0) {
if (item.tags) {
let itemTags = new Set(item.tags);
for (let filter of whitelistFilters.values()) {
for (let filter of includeFilters.values()) {
var parsed_filter = JSON.parse(filter);
if (parsed_filter.parent === "tags"){
if (!itemTags.has(parsed_filter.id)) {
Expand Down Expand Up @@ -430,7 +430,7 @@

function onStabilized () {
// Update positions storage
if (blacklistFilters.size + whitelistFilters.size == 0) { // Save only if it is full network
if (excludeFilters.size + includeFilters.size == 0) { // Save only if it is full network
localStorage.positions = JSON.stringify(globalNetwork.getPositions());
}
}
Expand Down Expand Up @@ -489,11 +489,11 @@
$("#toggle-list-type-button").click(function() {
let listTypeState = document.getElementById('toggle-list-type-button').innerText;
let color = "green";
if (listTypeState === "Whitelist"){
listTypeState = "Blacklist";
if (listTypeState === "Include"){
listTypeState = "Exclude";
color = "#c82333";
} else {
listTypeState = "Whitelist";
listTypeState = "Include";
color = "green";
}
document.getElementById('toggle-list-type-button').style.background = color;
Expand Down Expand Up @@ -592,18 +592,18 @@
})
.on('select2:select', function (e) {
let listTypeState = document.getElementById('toggle-list-type-button').innerText;
if (listTypeState == "Whitelist") {
whitelistFilters.add(JSON.stringify({id: e.params.data.id, parent: e.params.data.parent}));
if (listTypeState == "Include") {
includeFilters.add(JSON.stringify({id: e.params.data.id, parent: e.params.data.parent}));
}
if (listTypeState == "Blacklist") {
blacklistFilters.add(JSON.stringify({id: e.params.data.id, parent: e.params.data.parent}));
if (listTypeState == "Exclude") {
excludeFilters.add(JSON.stringify({id: e.params.data.id, parent: e.params.data.parent}));
}
view.refresh()
})
.on('select2:unselect', function (e) {
//delete from both. doesn't matter because tag shouldn't be there any ways.
whitelistFilters.delete(JSON.stringify({id: e.params.data.id, parent: e.params.data.parent}));
blacklistFilters.delete(JSON.stringify({id: e.params.data.id, parent: e.params.data.parent}));
includeFilters.delete(JSON.stringify({id: e.params.data.id, parent: e.params.data.parent}));
excludeFilters.delete(JSON.stringify({id: e.params.data.id, parent: e.params.data.parent}));

//maintain color map
colors[e.params.data.id] = null;
Expand Down

0 comments on commit 0c5d430

Please sign in to comment.