Commit 741d94b8 authored by Romain Loth's avatar Romain Loth

debugFlags: settings to control verbosity in console logs

parent cf28677a
......@@ -90,11 +90,11 @@ var desirableScholarSize=6; //Remember that all scholars have the same size!
*Three states:
* - true: fa2 auto-running at start
* - false: fa2 stopped at start, button exists
* - "off": button doesn't exist, fa2 stopped forever
* - "off": button doesn't exist, fa2 stopped forever // £TODO restore case
**/ var fa2enabled=false;//"off";
var stopcriteria = false;
var fa2milliseconds=7000; // for initial auto-run if fa2enabled and any
// subsequent auto-runs if graph modified
var fa2milliseconds=10000; // for initial auto-run if fa2enabled and any
// subsequent auto-runs if graph modified
// deprecated ?
var seed=999999999;//defaultseed
......@@ -130,8 +130,16 @@ TW.customLegendsBins = {
'growth_rate': 12
}
TW.debugFlags = {
initialShowAll: false,
initialShowAll: false, // show all nodes on bipartite case init (docs + terms)
// show verbose console logs...
logFetchers: false, // ...about ajax/fetching of graph data
logParsers: false, // ...about parsing said data
logFacets: false, // ...about parsing node attribute:value facets
logSettings: false, // ...about settings at Tina and Sigma init time
logSelections: false
}
// triggers overriding sigma.canvas renderers: nodes.def, labels.def, edges.def
......
......@@ -147,10 +147,12 @@ function SelectionEngine() {
// ====================
this.MultipleSelection2 = (function(nodes,nodesDict,edgesDict) {
var tMS2_deb = performance.now()
if (TW.debugFlags.selections) {
var tMS2_deb = performance.now()
console.log("IN SelectionEngine.MultipleSelection2:")
console.log("nodes", nodes)
}
greyEverything();
......@@ -313,9 +315,11 @@ function SelectionEngine() {
return b-a
});
console.debug('selections', selections)
console.debug('oppos', oppos)
console.debug('same', same)
if (TW.debugFlags.selections) {
console.debug('selections', selections)
console.debug('oppos', oppos)
console.debug('same', same)
}
overNodes=true;
......@@ -323,8 +327,10 @@ function SelectionEngine() {
updateRelatedNodesPanel( selections , same, oppos );
var tMS2_fin = performance.now()
console.log("end MultipleSelection2, own time:", tMS2_fin-tMS2_deb)
if (TW.debugFlags.selections) {
var tMS2_fin = performance.now()
console.log("end MultipleSelection2, own time:", tMS2_fin-tMS2_deb)
}
}).index()
};
......@@ -337,7 +343,8 @@ TinaWebJS = function ( sigmacanvas ) {
this.init = function () {
console.warn("TW settings", TW)
if (TW.debugFlags.logSettings) console.info("TW settings", TW)
let initErrMsg = null
if (typeof sigma == 'undefined') {
......@@ -460,7 +467,7 @@ TinaWebJS = function ( sigmacanvas ) {
// - additionnaly supports 'active/forcelabel' node property (magnify x 3)
sigmaModule.canvas.hovers.def = tempo.twRender.canvas.hovers.largerall
console.log('tw renderers registered in sigma module')
if (TW.debugFlags.logSettings) console.log('tw renderers registered in sigma module')
}
this.SearchListeners = function () {
......
......@@ -186,6 +186,7 @@ if (getUrlParam.type) {
thename = '"'+elements.join('" , "')+'"';
}
// £TODO restore thename
console.warn (thename, ":name not used anymore since refacto 10/05 could put on same level as inData as inMapname or smth")
console.log( "url", theurl , "data", thedata , "name", thename );
var bridgeRes = AjaxSync({ URL: theurl, DATA:thedata, TYPE:'GET', DT:'json' })
......@@ -302,13 +303,16 @@ if (! inFormat || ! inData) {
alert("error on initial data load")
}
else {
console.log("parsing the data")
if (TW.debugFlags.logParsers) console.log("parsing the data")
let start = new ParseCustom( inFormat , inData );
let catsInfos = start.scanFile(); //user should choose the order of categories
TW.categories = catsInfos.categories
console.log("Categories: ")
console.log(TW.categories)
if (TW.debugFlags.logParsers){
console.log(`Source scan found ${TW.categories.length} node categories: ${TW.categories}`)
}
// reverse lookup: category name => category indice
TW.catDict = catsInfos.lookup_dict
......@@ -323,7 +327,8 @@ else {
// XML parsing from ParseCustom
var dicts = start.makeDicts(TW.categories); // > parse json or gexf, dictfy
console.warn("parsing result:", dicts)
if (TW.debugFlags.logParsers) console.info("parsing result:", dicts)
TW.Nodes = dicts.nodes;
TW.Edges = dicts.edges;
......@@ -344,12 +349,15 @@ else {
// £TODO also test with comex2 for bipart case
// TW.nodes1 = dicts.n1;//not used
console.info(`== new graph ${TW.nodeIds.length} nodes, ${TW.edgeIds.length} edges ==`)
// a posteriori categories diagnostic
// ----------------------------------
// by default TW.categories now match user-suggested catSoc/Sem if present
// so we just need to handle mismatches here (when user-suggested cats were absent)
if (TW.categories.length == 2) {
console.log("== 'bipartite' case ==")
console.info("== 'bipartite' case ==")
if (TW.catSoc != TW.categories[0]) {
console.warn(`Observed social category "${TW.categories[0]}" overwrites user-suggested TW.catSoc ("${TW.catSoc}")`)
TW.catSoc = TW.categories[0]
......@@ -360,7 +368,7 @@ else {
}
}
else if (TW.categories.length == 1) {
console.log("== monopartite case ==")
console.info("== monopartite case ==")
// FIXME it would be more coherent with all tina usecases (like gargantext or tweetoscope) for the default category to by catSem instead of Soc
if (TW.catSoc != TW.categories[0]) {
console.warn(`Observed unique category "${TW.categories[0]}" overwrites user-suggested TW.catSoc ("${TW.catSoc}")`)
......@@ -465,7 +473,8 @@ else {
sigmaJsMouseProperties
)
console.info("sigma settings", customSettings)
if (TW.debugFlags.logSettings) console.info("sigma settings", customSettings)
// ==================================================================
......@@ -509,7 +518,7 @@ else {
// by default category0 is the initial type
$(".category1").hide();
// [ / Poblating the Sigma-Graph ]
......@@ -544,11 +553,11 @@ else {
var present = TW.partialGraph.states.slice(-1)[0]; // Last
var past = TW.partialGraph.states.slice(-2)[0] // avant Last
console.log("previous level: "+past.level)
console.log("new level: "+present.level)
console.log(" % % % % % % % % % % ")
console.log("")
// console.log("previous level: "+past.level)
// console.log("new level: "+present.level)
//
// console.log(" % % % % % % % % % % ")
// console.log("")
var bistate= this.type.map(Number).reduce(function(a, b){return a+b;})
LevelButtonDisable(false);
......@@ -568,7 +577,7 @@ else {
// }
console.log("printing the typestring:", typestring)
// console.log("printing the typestring:", typestring)
if (TW.filterSliders
......@@ -642,6 +651,8 @@ else {
outboundAttractionDistribution: false
}
if (TW.debugFlags.logSettings) console.info("FA2 settings", TW.FA2Params)
// init FA2 for any future forceAtlas2 calls
TW.partialGraph.configForceAtlas2(TW.FA2Params)
......
......@@ -3,7 +3,7 @@
// settings: {norender: Bool}
function cancelSelection (fromTagCloud, settings) {
console.log("\t***in cancelSelection");
if (TW.debugFlags.selections) { console.log("\t***in cancelSelection"); }
if (!settings) settings = {}
highlightSelectedNodes(false); //Unselect the selected ones :D
......@@ -114,7 +114,8 @@ function getCurrentTypeString() {
function highlightSelectedNodes(flag){
console.log("\t***methods.js:highlightSelectedNodes(flag)"+flag+" selEmpty:"+is_empty(selections))
if (TW.debugFlags.logSelections)
console.log("\t***methods.js:highlightSelectedNodes(flag)"+flag+" selEmpty:"+is_empty(selections))
if(!is_empty(selections)){
for(var i in selections) {
TW.partialGraph.graph.nodes(i).active = flag
......@@ -132,6 +133,10 @@ function alertCheckBox(eventCheck){
}
}
// THIS IS THE ORIGINAL FIRST VERSION OF changeType()
// It's not used since before I arrived, but useful as a logical resume
//
// States:
// A : Macro-Social
// B : Macro-Semantic
......
......@@ -165,7 +165,7 @@ function gexfCheckAttributesMap (someXMLContent) {
// Level-00
function scanGexf(gexfContent) {
console.debug("ParseCustom : scanGexf ======= ")
var categoriesDict={};
// adding gexfCheckAttributesMap call
......@@ -237,7 +237,9 @@ function sortNodeTypes(observedTypesDict) {
// if we have only one category, it gets the same code 0 as Document
// but in practice it's more often terms. anyways doesn't affect much
catDict[observedTypes[0]] = 0;
console.log("-----cat unique =>0")
if (TW.debugFlags.logParsers)
console.log(`cat unique (${observedTypes[0]}) =>0`)
}
if(nTypes>1) {
var newcats = []
......@@ -263,7 +265,8 @@ function sortNodeTypes(observedTypesDict) {
// for {1,2}partite graphs
function dictfyGexf( gexf , categories ){
console.log("ParseCustom gexf 2nd loop, main data extraction, with categories", categories)
if (TW.debugFlags.logParsers)
console.log("ParseCustom gexf 2nd loop, main data extraction, with categories", categories)
// var catDict = {'terms':"0"}
......@@ -457,8 +460,10 @@ function dictfyGexf( gexf , categories ){
// ------------- /debug: for local stats ----------------
var classvalues_deb = performance.now()
// console.log('dictfyGexf: begin TW.Clusters')
if (TW.debugFlags.logFacets) {
console.log('dictfyGexf: begin TW.Clusters')
var classvalues_deb = performance.now()
}
var gotClusters = false
for (var nodecat in tmpVals) {
......@@ -566,7 +571,7 @@ function dictfyGexf( gexf , categories ){
legendRefTicks.push(tmpVals[cat][at].vals[nthVal])
}
console.debug("intervals for", at, legendRefTicks)
if (TW.debugFlags.logFacets) console.debug("intervals for", at, legendRefTicks)
var nTicks = legendRefTicks.length
var sortedDistinctVals = Object.keys(tmpVals[cat][at].map).sort(function(a,b){return Number(a)-Number(b)})
......@@ -634,8 +639,11 @@ function dictfyGexf( gexf , categories ){
}
}
var classvalues_fin = performance.now()
console.log('dictfyGexf: end TW.Clusters, own time:', classvalues_fin-classvalues_deb)
if (TW.debugFlags.logFacets) {
var classvalues_fin = performance.now()
console.log('end TW.Clusters, own time:', classvalues_fin-classvalues_deb)
}
//New scale for node size: now, between 2 and 5 instead [1,70]
for(var nid in nodes){
......@@ -652,7 +660,10 @@ function dictfyGexf( gexf , categories ){
for(i=0; i<edgesNodes.length; i++) {
var edgesNode = edgesNodes[i];
var edgeNodes = edgesNode.getElementsByTagName('edge');
console.log("edgeNodes.length", edgeNodes.length)
if (TW.debugFlags.logParsers)
console.log("edgeNodes.length", edgeNodes.length)
for(j=0; j<edgeNodes.length; j++) {
var edgeNode = edgeNodes[j];
var source = parseInt( edgeNode.getAttribute('source') );
......@@ -877,7 +888,9 @@ function scanJSON( data ) {
// Level-00
// for {1,2}partite graphs
function dictfyJSON( data , categories ) {
console.debug(`dictfyJSON, categories:${categories}, data:`, data)
if (TW.debugFlags.logParsers)
console.log("ParseCustom json 2nd loop, main data extraction, with categories", categories)
var catDict = {}
var catCount = {}
for(var i in categories) catDict[categories[i]] = i;
......@@ -888,10 +901,11 @@ function dictfyJSON( data , categories ) {
nodes2={}, bipartiteD2N={}, bipartiteN2D={}
}
for(var i in data.nodes) {
let n = data.nodes[i];
for(var nid in data.nodes) {
let n = data.nodes[nid];
let node = {}
node.id = (n.id) ? n.id : i ; // use the key if no id
node.id = (n.id) ? n.id : nid ; // use the key if no id
node.label = (n.label)? n.label : ("node_"+node.id) ;
node.size = (n.size)? n.size : 3 ;
node.type = (n.type)? n.type : "Document" ;
......@@ -914,7 +928,6 @@ function dictfyJSON( data , categories ) {
if (!catCount[node.type]) catCount[node.type] = 0
catCount[node.type]++;
nodes[node.id] = node;
}
......
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