// === monitor windows resize === // var counterrrr=0; $( window ).resize(function() { counterrrr++; $("#log").html("redimension nro: "+counterrrr); sigmaLimits(); });// === / monitor windows resize === // // === [what to do at start] === // if (mainfile) { listGexfs(); if(!isUndef(getUrlParam.file)){ $.doTimeout(30,function (){ parse(getUrlParam.file); nb_cats = scanCategories(); pr("nb_cats: "+nb_cats); listGexfs(); graphtype=(nb_cats==1)?"mono":"bi"; bringTheNoise(getUrlParam.file,graphtype); $.doTimeout(30,function (){ if(!isUndef(gexfDict[getUrlParam.file])){ $("#currentGraph").html(gexfDict[getUrlParam.file]); } else $("#currentGraph").html(getUrlParam.file); scanDataFolder(); }); }); } else { window.location.href=window.location.origin+window.location.pathname+"?file="+mainfile; } } else { if(isUndef(getUrlParam.nodeidparam)) { pr("do nothing, 'cause don't wanna"); // $('#mainmodal').modal('show'); // $("#my-text-input").tokenInput("try.json"); // pr("doing something 'cause i'm a doer"); mainfile=true; // bringTheNoise("data/pkmn_types.gexf","mono"); // scanCategories(); } else { if(getUrlParam.nodeidparam.indexOf("__")===-1){ //gexfPath = "php/bridgeClientServer_filter.php?query="+getUrlParam.nodeidparam; param=getUrlParam.nodeidparam; // pr(param) bringTheNoise(param,"filtermode"); } else { param=getUrlParam.nodeidparam; pr(param) bringTheNoise(param,"unique_id"); } } }// === [ / what to do at start ] === // //just CSS function sigmaLimits(){ pr("\t*** sigmaLimits()") pw=$('#sigma-example').width(); ph=$('#sigma-example').height(); pr("\t\tprevsigma:("+pw+","+ph+")"); sidebar=$('#leftcolumn').width(); anchototal=$('#fixedtop').width(); altototal=$('#leftcolumn').height(); altofixtop=$('#fixedtop').height() altodeftop=$('#defaultop').height() $('#sigma-example').width(anchototal-sidebar); $('#sigma-example').height(altototal-altofixtop-altodeftop-4); pw=$('#sigma-example').width(); ph=$('#sigma-example').height(); pr("\t\tnowsigma:("+pw+","+ph+")"); } function bringTheNoise(pathfile,type){ $('#modalloader').modal('show'); // === get width and height === // sigmaLimits(); // === sigma canvas resize with previous values === // partialGraph = sigma.init(document.getElementById('sigma-example')) .drawingProperties(sigmaJsDrawingProperties) .graphProperties(sigmaJsGraphProperties) .mouseProperties(sigmaJsMouseProperties); // === resize topbar and tweakbar === // var body=document.getElementsByTagName('body')[0]; body.style.paddingTop="41px"; $("#changetype").click(function(){ pr("") pr(" ############ changeTYPE click"); printStates() changeType(); printStates() pr(" ############ / changeTYPE click"); pr("") }); $("#changelevel").click(function(){ pr("") pr(" ############ changeLEVEL click"); printStates() changeLevel(); printStates() pr(" ############ / changeLEVEL click"); pr("") }); // === un/hide leftpanel === // $("#aUnfold").click(function(e) { //SHOW leftcolumn sidebar = $("#leftcolumn"); fullwidth=$('#fixedtop').width(); e.preventDefault(); // $("#wrapper").toggleClass("active"); if(parseFloat(sidebar.css("right"))<0){ $("#aUnfold").attr("class","rightarrow"); sidebar.animate({ "right" : sidebar.width()+"px" }, { duration: 400, queue: false }); $("#ctlzoom").animate({ "right": (sidebar.width()+10)+"px" }, { duration: 400, queue: false }); // $('#sigma-example').width(fullwidth-sidebar.width()); $('#sigma-example').animate({ "width": fullwidth-sidebar.width()+"px" }, { duration: 400, queue: false }); setTimeout(function() { partialGraph.resize(); partialGraph.refresh(); }, 400); } else { //HIDE leftcolumn $("#aUnfold").attr("class","leftarrow"); sidebar.animate({ "right" : "-" + sidebar.width() + "px" }, { duration: 400, queue: false }); $("#ctlzoom").animate({ "right": "0px" }, { duration: 400, queue: false }); // $('#sigma-example').width(fullwidth); $('#sigma-example').animate({ "width": fullwidth+"px" },{ duration: 400, queue: false }); setTimeout(function() { partialGraph.resize(); partialGraph.refresh(); }, 400); } }); // $("#statsicon").click(function(){ // $('#statsmodal').modal('show'); // }); // === start minimap library... currently off === // startMiniMap(); console.log("parsing..."); // < === EXTRACTING DATA === > if(mainfile) { pr("mainfile: "+mainfile) parse(decodeURIComponent(pathfile)); if(type=="mono") { onepartiteExtract(); $("#left").hide(); } else if(type=="bi") fullExtract(); partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw(2,2,2); theListeners(); } else { if(type=="unique_id") { pr("bring the noise, case: unique_id"); pr(getClientTime()+" : DataExt Ini"); // < === DATA EXTRACTION === > $.ajax({ type: 'GET', url: bridge["forNormalQuery"], data: "unique_id="+pathfile+"&it="+iterationsFA2, contentType: "application/json", dataType: 'jsonp', async: true, success : function(data){ if(!isUndef(getUrlParam.seed))seed=getUrlParam.seed; extractFromJson(data,seed); pr(getClientTime()+" : DataExt Fin"); // < === DATA EXTRACTED!! === > if(fa2enabled==="off") $("#edgesButton").hide(); pushSWClick("social"); pr(partialGraph._core.graph.nodes.length) pr(partialGraph._core.graph.edges.length) nbnodes = partialGraph._core.graph.nodes.length if(nbnodes>=400 && nbnodes<1000) { snbnodes = nbnodes+""; cut1 = snbnodes[0]; cut2 = snbnodes.length; pr("cut1: "+cut1) pr("cut2: "+cut2) iterationsFA2 = Math.round(iterationsFA2/(cut1/cut2)) } if(nbnodes>=1000) iterationsFA2 = 150; pr("iterationsFA2: "+iterationsFA2) var netname = pathfile.replace(/\_/g, ' ').toUpperCase(); $("#network").html(netname); // < === ASYNCHRONOUS FA2.JS === > // var vis_nds = getVisibleNodes(); // pr("before_change... visible nodes:") // for(var i in vis_nds) // pr(vis_nds[i].id+" : "+vis_nds[i].degree) // var vis_ndsIndex = {} // for(var n in vis_nds) { // id = vis_nds[n].id // vis_ndsIndex[id] = vis_nds[n] // vis_ndsIndex[id].degree = 0; // } // var vis_edgs = getVisibleEdges(); // for(var e in vis_edgs) { // e1 = vis_edgs[e] // n1 = e1.source.id // n2 = e1.target.id // vis_ndsIndex[n1]["degree"]++; // vis_ndsIndex[n2]["degree"]++; // } // pr("after_change... visible nodes:") // for(var i in vis_ndsIndex) // pr(vis_ndsIndex[i].id+" : "+vis_ndsIndex[i].degree) pr(getClientTime()+" : Ini FA2"); var ForceAtlas2 = new Worker("FA2.js"); ForceAtlas2.postMessage({ "nodes": partialGraph._core.graph.nodes, "edges": partialGraph._core.graph.edges, "it":iterationsFA2 }); ForceAtlas2.addEventListener('message', function(e) { iterations=e.data.it; nds=e.data.nodes; for(var n in nds){ id=nds[n].id; x=nds[n].x y=nds[n].y partialGraph._core.graph.nodes[n].x=x; partialGraph._core.graph.nodes[n].y=y; partialGraph._core.graph.nodesIndex[id].x=x partialGraph._core.graph.nodesIndex[id].y=y Nodes[id].x=x; Nodes[id].y=y; } pr("\ttotalIterations: "+iterations) pr(getClientTime()+" : Fin FA2"); console.log("Parsing and FA2 complete."); // < === ASYNCHRONOUS FA2.JS DONE!! === > theListeners(); }); }, error: function(){ pr("Page Not found. parseCustom, inside the IF"); } }); } else { if ("filtermode") { // "php/bridgeClientServer_filter.php?query="+getUrlParam.nodeidparam; pr("bring the noise, case: query with multiple filters"); pr(getClientTime()+" : DataExt Ini"); pr(bridge["forFilteredQuery"]+"?query="+getUrlParam.nodeidparam); // < === DATA EXTRACTION === > $.ajax({ type: 'GET', url: bridge["forFilteredQuery"], data: "query="+getUrlParam.nodeidparam, contentType: "application/json", dataType: 'jsonp', async: true, success : function(data){ if(!isUndef(getUrlParam.seed))seed=getUrlParam.seed; extractFromJson(data,seed); pr(getClientTime()+" : DataExt Fin"); // < === DATA EXTRACTED!! === > if(fa2enabled==="off") $("#edgesButton").hide(); pushSWClick("social"); pr(partialGraph._core.graph.nodes.length) pr(partialGraph._core.graph.edges.length) nbnodes = partialGraph._core.graph.nodes.length if(nbnodes>=400 && nbnodes<1000) { snbnodes = nbnodes+""; cut1 = snbnodes[0]; cut2 = snbnodes.length; pr("cut1: "+cut1) pr("cut2: "+cut2) iterationsFA2 = Math.round(iterationsFA2/(cut1/cut2)) } if(nbnodes>=1000) iterationsFA2 = 150; pr("iterationsFA2: "+iterationsFA2) var netname = pathfile.replace(/\_/g, ' ').toUpperCase(); $("#network").html("MultiQuery: lalala"); // < === ASYNCHRONOUS FA2.JS === > pr(getClientTime()+" : Ini FA2"); var ForceAtlas2 = new Worker("FA2.js"); ForceAtlas2.postMessage({ "nodes": partialGraph._core.graph.nodes, "edges": partialGraph._core.graph.edges, "it":iterationsFA2 }); ForceAtlas2.addEventListener('message', function(e) { iterations=e.data.it; nds=e.data.nodes; for(var n in nds){ id=nds[n].id; x=nds[n].x y=nds[n].y partialGraph._core.graph.nodes[n].x=x; partialGraph._core.graph.nodes[n].y=y; partialGraph._core.graph.nodesIndex[id].x=x partialGraph._core.graph.nodesIndex[id].y=y Nodes[id].x=x; Nodes[id].y=y; } pr("\ttotalIterations: "+iterations) pr(getClientTime()+" : Fin FA2"); console.log("Parsing and FA2 complete."); // < === ASYNCHRONOUS FA2.JS DONE!! === > theListeners(); }); }, error: function(){ pr("Page Not found. parseCustom, inside the IF"); } }); } } } } function theListeners(){ pr("in THELISTENERS"); // leftPanel("close"); $("#closeloader").click();//modal.hide doesnt work :c // startForceAtlas2(partialGraph._core.graph);r( cancelSelection(false); $("#tips").html(getTips()); //$('#sigma-example').css('background-color','white'); $("#category-B").hide(); $("#labelchange").hide(); $("#availableView").hide(); showMeSomeLabels(6); initializeMap(); updateMap(); updateDownNodeEvent(false); partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw(2,2,2); $("#saveAs").click(function() { $('#savemodal').modal('show'); }); /******************* /SEARCH ***********************/ $.ui.autocomplete.prototype._renderItem = function(ul, item) { var searchVal = $("#searchinput").val(); var desc = extractContext(item.desc, searchVal); return $('
') .data('item.autocomplete', item) .append("" + item.label + "" ) .appendTo(ul); }; $('input#searchinput').autocomplete({ source: function(request, response) { matches = []; var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); pr(labels); var results = $.grep(labels, function(e) { return matcher.test(e.label); //|| matcher.test(e.desc); }); if (!results.length) { $("#noresults").text("Pas de résultats"); } else { $("#noresults").empty(); } matches = results.slice(0, maxSearchResults); response(matches); }, minLength: minLengthAutoComplete }); $('#searchinput').bind('autocompleteopen', function(event, ui) { $(this).data('is_open',true); }); $('#searchinput').bind('autocompleteclose', function(event, ui) { $(this).data('is_open',false); }); $("#searchinput").focus(function () { if ($(this).val() == strSearchBar) { $(this).val(''); } }); $("#searchinput").blur(function () { if ($(this).val() == '') { $(this).val(strSearchBar); } }); // i've a list of coincidences and i press enter like a boss $("#searchinput").keydown(function (e) { if (e.keyCode == 13 && $("input#searchinput").data('is_open') === true) { // Search has several results and you pressed ENTER if(!is_empty(matches)) { var coincidences = [] for(j=0;j