Commit d8d77bf7 authored by Romain Loth's avatar Romain Loth

rm unnecessary number casting and other minor fixes

parent aebf89e8
......@@ -44,7 +44,7 @@ var TW = {}
// *and* subdirectory to import if true
// see also ProcessDivsFlags()
TW.DivsFlags["histogramModule"] = false ;
TW.DivsFlags["histogramDailyVariantModule"] = true ;
TW.DivsFlags["histogramDailyVariantModule"] = false ;
// TODO more generic module integrating the variants cf. experiments/histogramModule_STUB_GENERIQUE
TW.DivsFlags["crowdsourcingModule"] = true ;
......@@ -107,11 +107,12 @@ TW.filterSliders = false
TW.histogramStartThreshold = 10 ;
TW.defaultNodeColor = "rgb(40,40,40)"
TW.edgeDefaultOpacity = 0.5 // opacity when true_color
TW.edgeGreyColor = "rgba(150, 150, 150, 0.2)";
TW.nodesGreyBorderColor = "rgba(100, 100, 100, 0.5)";
TW.selectedColor = "node" // "node" for a background like the node's color,
// "default" for note-like yellow
// "default" for note-like yellow
TW.overSampling = true // costly hi-def rendering (true => pixelRatio x 2)
......
......@@ -8,26 +8,19 @@ function SelectionEngine() {
// console.log("addvalue, prevsels, currsels",addvalue, prevsels, currsels)
var targeted = []
var buffer = Object.keys(prevsels).map(Number).sort(this.sortNumber);
var buffer = Object.keys(prevsels);
// currsels = bunch of nodes from a click in the map
currsels = currsels.map(Number).sort(this.sortNumber);
if(addvalue) {
// FOR SIMPLE ADD WITHOUT COMPLEMENT
targeted = currsels.concat(buffer.filter(function (item) {
return currsels.indexOf(item) < 0;
}));
} else targeted = currsels;
targeted = targeted.map(Number)
// debug
// console.log("targeted::", targeted)
// NB new sigma: my REFA deprecated clicktype=="double"
if(targeted.length==0) return [];
targeted = targeted.sort();
// ------------ FOR SETWISE COMPLEMENT ---------------------->8---------
// if(buffer.length>0) {
// if(JSON.stringify(buffer)==JSON.stringify(targeted)) {
// // this is just effective for Add[ ] ...
......@@ -51,16 +44,17 @@ function SelectionEngine() {
// whitelist[n] = true;
// }
// }
// targeted = Object.keys(whitelist).map(Number);
// targeted = Object.keys(whitelist);
// } else {// inter = 0 ==> click in other portion of the graph (!= current selection)
// // Union!
// if(addvalue) {
// targeted = targeted.concat(buffer.filter(function (item) {
// return targeted.indexOf(item) < 0;
// targeted = currsels.concat(buffer.filter(function (item) {
// return currsels.indexOf(item) < 0;
// }));
// }
// }
// }
// ---------------------------------------------------------->8---------
return targeted;
}).index();
......@@ -125,6 +119,8 @@ function SelectionEngine() {
//Util
this.intersect_safe = function(a, b) {
a.sort()
b.sort()
var ai=0, bi=0;
var result = new Array();
......@@ -181,10 +177,13 @@ function SelectionEngine() {
selections = {}
// targeted arg 'nodes' can be nid array or single nid
var ndsids=[]
if(nodes) {
if(! $.isArray(nodes)) ndsids.push(nodes);
else ndsids=nodes;
for(var i in ndsids) {
var s = ndsids[i];
......@@ -261,7 +260,7 @@ function SelectionEngine() {
// show the button to remove selection
$("#unselectbutton").show() ;
var the_new_sels = Object.keys(selections).map(Number)
var the_new_sels = Object.keys(selections)
TW.partialGraph.states.slice(-1)[0].selections = the_new_sels;
TW.partialGraph.states.slice(-1)[0].setState( { sels: the_new_sels} )
......@@ -279,11 +278,12 @@ function SelectionEngine() {
});
// console.log("Event [gotNodeSet] sent from Tinaweb MultipleSelection2")
// TODO REFA this used for bipartite case but needs testing with correct typestring case
// £TODO REFA this used for bipartite case but needs testing with correct typestring case
//
if(TW.Relations["1|1"]) {
for(var s in the_new_sels) {
var bipaNeighs = TW.Relations["1|1"][the_new_sels[s]];
for(var n in neighs) {
for(var n in bipaNeighs) {
if (typeof oppositeSideNeighbors[bipaNeighs[n]] == "undefined")
oppositeSideNeighbors[bipaNeighs[n]] = 0;
oppositeSideNeighbors[bipaNeighs[n]]++;
......@@ -308,9 +308,9 @@ function SelectionEngine() {
return b-a
});
// console.debug('oppos', oppos)
// console.debug('same', same)
//
console.debug('selections', selections)
console.debug('oppos', oppos)
console.debug('same', same)
overNodes=true;
......
......@@ -687,7 +687,7 @@ function prepareNodesRenderingProperties(nodesDict) {
}
}
// hex color ex "#eee or #AA00AA"
else if (/^#[A-Fa-f0-1]{3,6}$/.test(n.color)) {
else if (/^#[A-Fa-f0-9]{3,6}$/.test(n.color)) {
rgba = hex2rgba(n.color)
rgbStr = rgba.splice(0, 3).join(',');
}
......@@ -695,12 +695,23 @@ function prepareNodesRenderingProperties(nodesDict) {
invalidFormat = true
}
}
else {
invalidFormat = true
}
if (!invalidFormat) {
n.color = `rgb(${rgbStr})`
}
else {
n.color = TW.defaultNodeColor
rgbStr = TW.defaultNodeColor.split(',').splice(0, 3).join(',');
}
n.customAttrs = {
grey: false,
highlight: false,
true_color : n.color,
defgrey_color : "rgba("+rgbStr+",.4)"
defgrey_color : "rgba("+rgbStr+",.5)"
}
// POSS n.type: distinguish rendtype and twtype
......
......@@ -899,7 +899,8 @@ function dictfyJSON( data , categories ) {
node.y = (n.y)? n.y : Math.random();
node.color = (n.color)? n.color : "#FFFFFF" ;
if(n.shape) node.shape = n.shape;
if(n.attributes) node.attributes = n.attributes;
if(n.attributes) node.attributes = n.attributes
else node.attributes = {}
node.type = (n.type)? n.type : categories[0] ;
// node.shape = "square";
......
......@@ -553,8 +553,8 @@ SigmaUtils = function () {
// (TODO REFA make them inside TW.- ns)
// not often necessary + costly in mem because is a clone
// => preferably use TW.partialGraph.graph.nodes(some_node_id) as accessor
// getnodes => preferably use TW.partialGraph.graph.nodes(some_node_id) as accessor
// (not often necessary + costly in mem because is a clone)
function getnodes(){
// new sigma.js
return TW.partialGraph.graph.nodes();
......@@ -610,10 +610,9 @@ function find(lquery){
}
function exactfind(label) {
nds=getnodes();
if (typeof lquery == 'string' && lquery.length > 0) {
for(var i in nds){
n=nds[i];
for(var i in TW.nodeIds){
n=TW.partialGraph.graph.nodes(TW.nodeIds[i]);
if(!n.hidden){
if (n.label==label) {
return n;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment