Commit 3bfb7073 authored by Romain Loth's avatar Romain Loth

removing old static/lib/graphExplorer dir (it will be replaced by new external branch)

parent 1925c104
/*
* Customize as you want ;)
*/
function newPopup(url) {
popupWindow = window.open(url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no')
}
function getIDFromURL( item ) {
var pageurl = window.location.href.split("/")
var cid;
for(var i in pageurl) {
if(pageurl[i]==item) {
cid=parseInt(i);
break;
}
}
return pageurl[cid+1];
}
function modify_ngrams( classname ) {
console.clear()
var corpus_id = getIDFromURL( "corpora" ) // not used
var list_id = $("#maplist_id").val()
var selected_ngrams = $.extend({}, selections)
if(classname=="delete") {
CRUD(list_id, Object.keys(selected_ngrams), "DELETE", function(success) {
cancelSelection(false)
for(var i in selected_ngrams) {
partialGraph.dropNode( i )
delete Nodes[i]
delete partialGraph._core.graph.nodesIndex[i]
}
partialGraph.refresh()
$("#lensButton").click()
}) ;
}
// if(classname=="group") {
// CRUD( corpus_id , "/group" , [] , selected_ngrams , "PUT" , function(result) {
// console.log(" GROUP "+result)
// CRUD( corpus_id , "/keep" , [] , selected_ngrams , "PUT" , function(result) {
// });
// });
// }
}
function CRUD( list_id , ngram_ids , http_method , callback) {
// ngramlists/change?node_id=42&ngram_ids=1,2
var the_url = window.location.origin+"/api/ngramlists/change?list="+list_id+"&ngrams="+ngram_ids.join(",");
// debug
// console.log("starting CRUD AJAX => URL: " + the_url + " (" + http_method + ")")
if(ngram_ids.length>0) {
$.ajax({
method: http_method,
url: the_url,
// data: args, // currently all data explicitly in the url (like a GET)
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
},
success: function(data){
console.log("-- CRUD ----------")
console.log(http_method + " ok!!")
console.log(JSON.stringify(data))
console.log("------------------")
callback(true);
},
error: function(result) {
console.log("-- CRUD ----------")
console.log("Data not found in #Save_All");
console.log(result)
console.log("------------------")
callback(false);
}
});
} else callback(false);
}
// = = = = = = = = = = = [ Clusters Plugin ] = = = = = = = = = = = //
// Execution: ChangeGraphAppearanceByAtt( true )
// It scans the existing node-attributes and t keeps only those which are Numeric.
// then, add the button in the html with the sigmaUtils.clustersBy(x) listener.
//TODO: move to ClustersPlugin.js or smntng
function ChangeGraphAppearanceByAtt( manualflag ) {
if ( !isUndef(manualflag) && !colorByAtt ) colorByAtt = manualflag;
if(!colorByAtt) return;
// Seeing all the possible attributes!
var AttsDict = {}
var Atts_2_Exclude = {}
var v_nodes = getVisibleNodes();
for (var i in v_nodes) {
if(!v_nodes[i].hidden) {
var id = v_nodes[i].id;
for(var a in Nodes[id].attributes) {
var someatt = Nodes[id].attributes[a]
// Identifying the attribute datatype: exclude strings and objects
if ( ( typeof(someatt)=="string" && isNaN(Number(someatt)) ) || typeof(someatt)=="object" ) {
if (!Atts_2_Exclude[a]) Atts_2_Exclude[a]=0;
Atts_2_Exclude[a]++;
}
}
var possible_atts = [];
if (!isUndef(Nodes[id].attributes))
possible_atts = Object.keys(Nodes[id].attributes)
if(!isUndef(v_nodes[i].degree))
possible_atts.push("degree")
possible_atts.push("clust_louvain")
for(var a in possible_atts){
if ( !AttsDict[ possible_atts[a] ] )
AttsDict[ possible_atts[a] ] = 0
AttsDict[ possible_atts[a] ] ++;
}
}
}
for(var i in Atts_2_Exclude)
delete AttsDict[i];
var AttsDict_sorted = ArraySortByValue(AttsDict, function(a,b){
return b-a
});
console.log( AttsDict_sorted )
var div_info = "";
if( $( ".colorgraph_div" ).length>0 )
div_info += '<ul id="colorGraph" class="nav navbar-nav navbar-right">'
div_info += ' <li class="dropdown">'
div_info += '<a href="#" class="dropdown-toggle" data-toggle="dropdown">'
div_info += ' <img title="Set Colors" src="/static/img/colors.png" width="20px"><b class="caret"></b></img>'
div_info += '</a>'
div_info += ' <ul class="dropdown-menu">'
for (var i in AttsDict_sorted) {
var att_s = AttsDict_sorted[i].key;
var att_c = AttsDict_sorted[i].value;
var the_method = "clustersBy"
if(att_s.indexOf("clust")>-1) the_method = "colorsBy"
div_info += '<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "color")\'>By '+att_s+'('+att_c+')'+'</a></li>'
pr('<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "color")\'>By '+att_s+'('+att_c+')'+'</a></li>')
}
div_info += ' </ul>'
div_info += ' </li>'
console.log('$( ".colorgraph_div" ).length')
console.log($( ".colorgraph_div" ).length)
if( $( ".colorgraph_div" ).length>0 ) {
div_info += '</ul>'
$( div_info ).insertAfter(".colorgraph_div");
$( ".colorgraph_div" ).remove();
} else {
$("#colorGraph").html(div_info)
}
div_info = "";
if( $( ".sizegraph_div" ).length>0 )
div_info += '<ul id="sizeGraph" class="nav navbar-nav navbar-right">'
div_info += ' <li class="dropdown">'
div_info += '<a href="#" class="dropdown-toggle" data-toggle="dropdown">'
div_info += ' <img title="Set Sizes" src="/static/img/NodeSize.png" width="20px"><b class="caret"></b></img>'
div_info += '</a>'
div_info += ' <ul class="dropdown-menu">'
for(var i in AttsDict) {
if( i.indexOf("clust")>-1 )
delete AttsDict[i]
}
var AttsDict_sorted = ArraySortByValue(AttsDict, function(a,b){
return b-a
});
console.clear()
console.log( AttsDict_sorted )
for (var i in AttsDict_sorted) {
var att_s = AttsDict_sorted[i].key;
var att_c = AttsDict_sorted[i].value;
var the_method = "clustersBy"
if(att_s.indexOf("clust")>-1) the_method = "colorsBy"
div_info += '<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "size")\'>By '+att_s+'('+att_c+')'+'</a></li>'
pr('<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "size")\'>By '+att_s+'('+att_c+')'+'</a></li>')
}
div_info += '<li><a href="#" onclick=\''+"clustersBy"+'("default" , "size")\'>By '+"default"+'('+AttsDict_sorted[0].value+')'+'</a></li>'
console.log('<li><a href="#" onclick=\''+"clustersBy"+'("default" , "size")\'>By '+"default"+'('+AttsDict_sorted[0].value+')'+'</a></li>' )
div_info += ' </ul>'
div_info += ' </li>'
console.log('$( ".sizegraph_div" ).length')
console.log($( ".sizegraph_div" ).length)
if( $( ".sizegraph_div" ).length>0 ) {
div_info += '</ul>'
$( div_info ).insertAfter(".sizegraph_div");
$( ".sizegraph_div" ).remove();
} else {
$("#sizeGraph").html(div_info)
}
}
// It scans the current visible nodes|edges. It considers n-id and e(s,t,w)
// then, it runs external library jLouvain()
//TODO: move to ClustersPlugin.js or smntng
function RunLouvain() {
var node_realdata = []
var nodesV = getVisibleNodes()
for(var n in nodesV)
node_realdata.push( nodesV[n].id )
var edge_realdata = []
var edgesV = getVisibleEdges()
for(var e in edgesV) {
var st = edgesV[e].id.split(";")
var info = {
"source":st[0],
"target":st[1],
"weight":edgesV[e].weight
}
edge_realdata.push(info)
}
var community = jLouvain().nodes(node_realdata).edges(edge_realdata);
var results = community();
for(var i in results)
Nodes[i].attributes["clust_louvain"]=results[i]
}
// Highlight nodes belonging to cluster_i when you click in thecluster_i of the legend
//TODO: move to ClustersPlugin.js or smntng
function HoverCluster( ClusterCode ) {
console.log( ClusterCode )
var raw = ClusterCode.split("||")
var Type=raw[0], Cluster=raw[1], clstID=Number(raw[2]);
var present = partialGraph.states.slice(-1)[0]; // Last
var type_t0 = present.type;
var str_type_t0 = type_t0.map(Number).join("|")
console.log( "\t"+str_type_t0)
greyEverything();
var nodes_2_colour = {};
var edges_2_colour = {};
var nodesV = getVisibleNodes()
for(var i in nodesV) {
var n = nodesV[i]
n.forceLabel = false;
var node = Nodes[n.id]
if ( node.type==Type && !isUndef(node.attributes[Cluster]) && node.attributes[Cluster]==clstID ) {
// pr( n.id + " | " + Cluster + " : " + node.attributes[Cluster] )
nodes_2_colour[n.id] = n.degree;
}
}
for(var s in nodes_2_colour) {
if(Relations[str_type_t0] && Relations[str_type_t0][s] ) {
neigh = Relations[str_type_t0][s]
if(neigh) {
for(var j in neigh) {
t = neigh[j]
if( !isUndef(nodes_2_colour[t]) ) {
edges_2_colour[s+";"+t]=true;
edges_2_colour[t+";"+s]=true;
}
}
}
}
}
for(var i in nodes_2_colour) {
n = partialGraph._core.graph.nodesIndex[i]
if(n) {
n.color = n.attr['true_color'];
n.attr['grey'] = 0;
}
}
for(var i in edges_2_colour) {
an_edge = partialGraph._core.graph.edgesIndex[i]
if(!isUndef(an_edge) && !an_edge.hidden){
// pr(an_edge)
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
}
var nodes_2_label = ArraySortByValue(nodes_2_colour, function(a,b){
return b-a
});
for(var n in nodes_2_label) {
if(n==4)
break
var ID = nodes_2_label[n].key
partialGraph._core.graph.nodesIndex[ID].forceLabel = true;
}
overNodes=true;
partialGraph.draw()
}
// From the cluster information of JSON|GEXF i build the Clusters Legend div.
// daclass = "clust_default" | "clust_louvain" | "clust_x" ...
//TODO: move to ClustersPlugin.js or smntng
function set_ClustersLegend ( daclass ) {
//partialGraph.states.slice(-1)[0].LouvainFait = true
if( daclass=="clust_default" && Clusters.length==0)
return false;
$("#legend_for_clusters").removeClass( "my-legend" )
$("#legend_for_clusters").html("")
var ClustNB_CurrentColor = {}
var nodesV = getVisibleNodes()
for(var i in nodesV) {
n = nodesV[i]
color = n.color
type = Nodes[n.id].type
clstNB = Nodes[n.id].attributes[daclass]
ClustNB_CurrentColor[type+"||"+daclass+"||"+clstNB] = color
}
LegendDiv = ""
LegendDiv += ' <div class="legend-title">Map Legend</div>'
LegendDiv += ' <div class="legend-scale">'
LegendDiv += ' <ul class="legend-labels">'
if (daclass=="clust_louvain")
daclass = "louvain"
OrderedClustDicts = Object.keys(ClustNB_CurrentColor).sort()
if( daclass.indexOf("clust")>-1 ) {
for(var i in OrderedClustDicts) {
var IDx = OrderedClustDicts[i]
var raw = IDx.split("||")
var Type = raw[0]
var ClustType = raw[1]
var ClustID = raw[2]
var Color = ClustNB_CurrentColor[IDx]
pr ( Color+" : "+ Clusters[Type][ClustType][ClustID] )
var ColorDiv = '<span style="background:'+Color+';"></span>'
LegendDiv += '<li onclick=\'HoverCluster("'+IDx+'")\'>'+ColorDiv+ Clusters[Type][ClustType][ClustID]+"</li>"+"\n"
}
} else {
for(var i in OrderedClustDicts) {
var IDx = OrderedClustDicts[i]
var Color = ClustNB_CurrentColor[IDx]
// pr ( Color+" : "+ Clusters[Type][ClustType][ClustID] )
var ColorDiv = '<span style="background:'+Color+';"></span>'
LegendDiv += '<li onclick=\'HoverCluster("'+IDx+'")\'>'+ColorDiv+ IDx+"</li>"+"\n"
}
}
LegendDiv += ' </ul>'
LegendDiv += ' </div>'
$("#legend_for_clusters").addClass( "my-legend" );
$("#legend_for_clusters").html( LegendDiv )
}
// = = = = = = = = = = = [ / Clusters Plugin ] = = = = = = = = = = = //
// PHP-mode when you've a cortext db.
function getTopPapers_OriginalVersion(type){
if(getAdditionalInfo){
jsonparams=JSON.stringify(getSelections());
bi=(Object.keys(categories).length==2)?1:0;
var APINAME = "API_CNRS/"
//jsonparams = jsonparams.replaceAll("&","__and__");
jsonparams = jsonparams.split('&').join('__and__');
//dbsPaths.push(getGlobalDBs());
thisgexf=JSON.stringify(decodeURIComponent(getUrlParam.file));
image='<img style="display:block; margin: 0px auto;" src="'+APINAME+'img/ajax-loader.gif"></img>';
$("#tab-container-top").show();
$("#topPapers").show();
$("#topPapers").html(image);
$.ajax({
type: 'GET',
url: APINAME+'info_div.php',
data: "type="+type+"&bi="+bi+"&query="+jsonparams+"&gexf="+thisgexf+"&index="+field[getUrlParam.file],
//contentType: "application/json",
//dataType: 'json',
success : function(data){
pr(APINAME+'info_div.php?'+"type="+type+"&bi="+bi+"&query="+jsonparams+"&gexf="+thisgexf+"&index="+field[getUrlParam.file]);
$("#topPapers").html(data);
},
error: function(){
pr('Page Not found: getTopPapers');
}
});
}
}
// PHP-mode when you've a cortext db.
function getTopProposals(type , jsonparams , thisgexf) {
type = "semantic";
if(swclickActual=="social") {
nodesA = []
nodesB = []
socneigh = []
for(var i in selections) {
if(Nodes[i].type==catSoc) nodesA.push(i);
if(Nodes[i].type==catSem) nodesB.push(i);
}
if(nodesA.length>0 && nodesB.length==0) socneigh = getArrSubkeys(opos,"key");
if(nodesA.length>0 && nodesB.length>0) socneigh = getNeighs(nodesA,bipartiteD2N);
kSels = {}
for(var i in nodesB) {
kSels[nodesB[i]] = 1;
}
for(var i in socneigh) {
kSels[socneigh[i]] = 1;
}
concepts = []
for(var i in kSels) {
concepts.push(Nodes[i].label)
}
jsonparams=JSON.stringify(concepts);
jsonparams = jsonparams.split('&').join('__and__');
}
image='<img style="display:block; margin: 0px auto;" src="'+"API_pasteur/"+'img/ajax-loader.gif"></img>';
$("#topProposals").show();
$("#topProposals").html(image);
$.ajax({
type: 'GET',
url: "API_pasteur/"+'info_div2.php',
data: "type="+"semantic"+"&query="+jsonparams+"&gexf="+thisgexf,
//contentType: "application/json",
//dataType: 'json',
success : function(data){
pr("API_pasteur/"+'info_div2.php?'+"type="+"semantic"+"&query="+jsonparams+"&gexf="+thisgexf);
$("#topProposals").html(data);
},
error: function(){
pr('Page Not found: getTopProposals');
}
});
}
// Just for Garg
function genericGetTopPapers(theids , corpus_id , thediv) {
if(getAdditionalInfo) {
$("#"+thediv).show();
$.ajax({
type: 'GET',
url: window.location.origin+'/api/nodes/'+corpus_id+'/having?score=tfidf&ngram_ids='+theids.join(","),
//contentType: "application/json",
//dataType: 'json',
success : function(data){
pr(window.location.origin+'/api/nodes/'+corpus_id+'/having?score=tfidf&ngram_ids='+theids.join(",") )
var arraydata = $.parseJSON(data)
var output = "<ul style='padding: 0px; margin: 13px;'>"
for(var i in arraydata) {
var pub = arraydata[i]
var gquery = "https://searx.laquadrature.net/?categories=general&q="+pub["title"].replace(" "+"+")
var getpubAPI = window.location.origin+"/nodeinfo/"+pub["id"]
var ifjournal="",ifauthors="",ifkeywords="",ifdate="",iftitle="";
if(pub["journal"]) ifjournal = "<br>Published in <a>"+pub["journal"]+"</a>";
if(pub["authors"]) {
ifauthors = "By "+pub["authors"]+"";
if(pub["authors"] == "not found") {
if(pub["source"])
ifauthors = "By "+pub["source"]+"";
else ifauthors = ""
} else ifauthors = ""
}
if(pub["fields"]) ifkeywords = "<br>Fields: "+pub["fields"];
if(pub["publication_date"]) ifdate = "<br>In "+pub["publication_date"].split(" ")[0];
var jsstuff = "if(wnws_buffer!=null) {wnws_buffer.close();} "
var jsparams = 'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no'
jsstuff += "wnws_buffer = window.open('"+getpubAPI+"', 'popUpWindow' , '"+jsparams+"')";
output += "<li><a onclick=\""+jsstuff+"\" target=_blank>"+pub["title"]+"</a>. "+ifauthors+". "+ifjournal+". "+ifkeywords+". "+ifdate+"\n";
output += '<a href="'+gquery+'" target=_blank><img title="Query the anonymous web" src="'+window.location.origin+'/static/img/searx.png"></img></a>'
output +="</li>\n";
// for(var j in pub) {
// if(j!="abstract")
// output += "<li><b>"+j+"</b>: "+pub[j]+"</li>\n";
// }
output += "<br>"
}
output += "</ul>"
$("#"+thediv).html(output);
$("#"+thediv).show();
// $('#tab-container-top').easytabs({updateHash:false});
},
error: function(){
pr('Page Not found: getTopPapers()');
}
});
}
}
// Just for Garg: woops, override
function getTopPapers(type){
if(getAdditionalInfo){
$("#topPapers").show();
var img = '<center><img src="'+window.location.origin+'/static/img/ajax-loader.gif" width="30%"></img></center>';
$("#topPapers").html(img);
var pageurl = window.location.href.split("/")
var cid;
for(var i in pageurl) {
if(pageurl[i]=="corpora") {
cid=parseInt(i);
break;
}
}
var corpus_id = pageurl[cid+1];
pr("corpus_id: "+ corpus_id);
var theids = []
for(var i in selections) {
if(!Nodes[i].iscluster) {
theids.push(parseInt(Nodes[i].id))
}
}
pr("the IDs of the selectioons")
pr(theids)
$.ajax({
type: 'GET',
url: window.location.origin+'/api/nodes/'+corpus_id+'/having?score=tfidf&ngram_ids='+theids.join(","),
//contentType: "application/json",
//dataType: 'json',
success : function(data){
// pr(window.location.origin+'/api/tfidf/'+corpus_id+'/'+theids.join("a") )
// var arraydata = $.parseJSON(data)
var output = "<ul style='padding: 0px; margin: 13px;'>"
for(var i in data) {
var pub = data[i]
if(pub["title"]) {
var gquery = "https://searx.laquadrature.net/?categories=general&q="+pub["title"].replace(" "+"+")
// ex url_elems = ["http:", "", "localhost:8000", "projects", "1", "corpora", "2690", "explorer?field1=ngrams&field2=ngrams&distance=conditional&bridgeness=5"]
var url_elems = window.location.href.split("/")
var url_mainIDs = {}
for(var i=0; i<url_elems.length; i++) {
if(url_elems[i]!="" && !isNaN(Number(url_elems[i]))) {
url_mainIDs[url_elems[i-1]] = Number(url_elems[i]);
}
}
// ex url_mainIDs = {projects: 1, corpora: 2690}
// link to matching document
var getpubAPI = window.location.origin+'/projects/'+url_mainIDs["projects"]+'/corpora/'+ url_mainIDs["corpora"] + '/documents/'+pub["id"]
var ifjournal="",ifauthors="",ifkeywords="",ifdate="",iftitle="";
if(pub["journal"]) ifjournal = "<br>Published in <a>"+pub["journal"]+"</a>";
if(pub["authors"]) {
ifauthors = "By "+pub["authors"]+"";
if(pub["authors"] == "not found") {
if(pub["source"])
ifauthors = "By "+pub["source"]+"";
else ifauthors = ""
} else ifauthors = ""
}
if(pub["fields"]) ifkeywords = "<br>Fields: "+pub["fields"];
if(pub["publication_date"]) ifdate = "<br>In "+pub["publication_date"].split(" ")[0];
var jsstuff = "if(wnws_buffer!=null) {wnws_buffer.close();} "
var jsparams = 'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no'
jsstuff += "wnws_buffer = window.open('"+getpubAPI+"', 'popUpWindow' , '"+jsparams+"')";
output += "<li><a onclick=\""+jsstuff+"\" target=_blank>"+pub["title"]+"</a>. "+ifauthors+". "+ifjournal+". "+ifkeywords+". "+ifdate+"\n";
output += '<a href="'+gquery+'" target=_blank><img title="Query to Google" src="'+window.location.origin+'/static/img/searx.png"></img></a>'
output +="</li>\n";
// for(var j in pub) {
// if(j!="abstract")
// output += "<li><b>"+j+"</b>: "+pub[j]+"</li>\n";
// }
output += "<br>"
}
}
output += "</ul>"
$("#tab-container-top").show();
// $('#tab-container-top').easytabs({updateHash:false});
$("#topPapers").html(output);
},
error: function(){
pr('Page Not found: getTopPapers()');
}
});
// for(var i in corpusesList) {
// var c_id = i;
// var text = corpusesList[i]["name"]
// console.log(theid+" : "+text)
// genericGetTopPapers(theids , c_id , ("top_"+text) )
// }
}
}
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
// Just for Garg
function printCorpuses() {
console.clear()
console.log( "!!!!!!!! Corpus chosen, going to make the diff !!!!!!!! " )
pr(corpusesList)
var selected = $('input[name=optradio]:checked')[0].id.split("_")
var sel_p = selected[0], sel_c=selected[1]
var pageurl = window.location.href.split("/")
var cid;
for(var i in pageurl) {
if(pageurl[i]=="corpora") {
cid=parseInt(i);
break;
}
}
var current_corpus = pageurl[cid+1];
pr("corpus id, selected: "+sel_c)
pr("current corpus: "+current_corpus)
var the_ids = []
the_ids.push( current_corpus )
the_ids.push( sel_c )
$("#closecorpuses").click();
var thenodes = []
for(var i in partialGraph._core.graph.nodes) {
thenodes.push(partialGraph._core.graph.nodes[i].id)
}
console.log( thenodes )
$.ajax({
type: 'GET',
url: window.location.origin+'/explorer/intersection/'+the_ids.join("a"),
data: "nodeids="+JSON.stringify(thenodes),
type: 'POST',
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
},
success : function(data){
console.log( "!!!!!!!! in printCorpuses() AJAX!!!!!!!! " )
for(var i in Nodes) {
if(data[i])
Nodes[i].attributes["inter"] = data[i]
else
Nodes[i].attributes["inter"] = 0
}
cancelSelection(false)
ChangeGraphAppearanceByAtt(true)
console.log("Getting the clusters")
clustersBy("inter" , "color")
clustersBy("inter" , "size")
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
console.log(err.Message);
}
});
// $("#tab-container-top").html("");
// var string = ""
// string += "<ul class='etabs'>"+"\n";
// string += "\t"+"<li id='tabmed' class='tab active'><a href='#tabs3'>Main Pubs</a></li>"+"\n";
// for(var i in corpusesList) {
// var text = corpusesList[i]["name"]
// var c = corpusesList[i]["id"]
// string += "\t"+"<li id='tab_"+text+"' class='tab'><a href='#tabs"+c+"'>"+text+" Pubs</a></li>"+"\n";
// }
// string += "</ul>"+"\n";
// string += "<div class='panel-container'>"+"\n";
// string += "\t"+'<div id="tabs3">'+"\n";
// string += "\t\t"+'<div id="topPapers"></div>'+"\n";
// string += "\t"+'</div>'+"\n";
// for(var i in corpusesList) {
// var text = corpusesList[i]["name"]
// var c = corpusesList[i]["id"]
// string += "\t"+'<div id="tabs'+c+'">'+"\n";
// string += "\t\t"+'<div id="top_'+text+'"></div>'+"\n";
// string += "\t"+'</div>'+"\n";
// }
// string += "</div>"+"\n";
// $("#tab-container-top").html(string);
// console.log(string)
// console.log(" - - -- -- - ")
// console.log(corpusesList)
// var theids = []
// var pageurl = window.location.href.split("/")
// var cid;
// for(var i in pageurl) {
// if(pageurl[i]=="corpus") {
// cid=parseInt(i);
// break;
// }
// }
// var corpus_id = pageurl[cid+1];
// theids.push( corpus_id )
// for(var corpora in corpusesList) {
// console.log("other corpus_id:")
// console.log( corpora )
// theids.push( corpora )
// break
// }
// console.log("the two corpuses:")
// console.log( theids )
}
// Just for Garg
function GetUserPortfolio() {
//http://localhost:8000/api/corpusintersection/1a50317a50145
var pageurl = window.location.href.split("/")
var pid;
for(var i in pageurl) {
if(pageurl[i]=="project") {
pid=parseInt(i);
break;
}
}
var project_id = pageurl[pid+1];
var cid;
for(var i in pageurl) {
if(pageurl[i]=="corpus") {
cid=parseInt(i);
break;
}
}
var corpus_id = pageurl[cid+1];
if( Object.keys( corpusesList ).length > 0 )
return true;
var query_url = window.location.origin+'/api/nodes?types[]=PROJECT&types[]=CORPUS&pagination_limit=100'
// var query_url = window.location.origin+'/api/nodes?types[]=PROJECT&types[]=CORPUS&pagination_limit=100&fields[]=hyperdata'
$.ajax({
type: 'GET',
dataType : 'JSON',
url: query_url,
success : function(data) {
var html_ = ""
var portfolio = {}
html_ += '<div class="panel-group" id="accordion">'+"\n"
html_ += ' <form id="corpuses_form" role="form">'+"\n"
for (var record in data["records"]) {
console.log( " ici le record " + record )
if ( data["records"][record]["typename"] === 'PROJECT' ) {
var project_id = data["records"][record]["id"]
var project_name = data["records"][record]["name"]
portfolio[project_id] = project_name
html_ += ' <div class="panel panel-default">'+"\n"
html_ += ' <div class="panel-heading">'+"\n"
html_ += ' <h4 class="panel-title">'+"\n"
html_ += ' <a data-toggle="collapse" data-parent="#accordion" href="#collapse_' + project_id+'">'
html_ += ' <span class="glyphicon glyphicon-book" aria-hidden="true"></span> ' + project_name
html_ += ' </a>'+"\n"
html_ += ' </h4>'+"\n"
html_ += ' </div>'+"\n"
html_ += ' <div id="collapse_'+project_id+'" class="panel-collapse collapse">'+"\n"
html_ += ' <div class="panel-body" style="input[type=radio] {display: none;}">'+"\n"
html_ += ' <ul>'+"\n"
for (var record2 in data["records"]) {
if ( data["records"][record2]["typename"] == 'CORPUS' ) {
var corpus_parent_id = data["records"][record2]["parent_id"]
if (corpus_parent_id !== null) {
if ( corpus_parent_id == project_id) {
var corpus_id = data["records"][record2]["id"]
var corpus_name = data["records"][record2]["name"]
portfolio[corpus_id] = corpus_name
html_ += ' <div class="row">'+"\n"
html_ += ' <div class="radio">'+"\n"
html_ += ' <label><input type="radio" id="'+project_id+"_"+corpus_id+'" name="optradio">'+"\n"
html_ += ' <a target="_blank" href="/projects/'+project_id+'/corpora/'+corpus_id+'/">'
html_ += ' <span class="glyphicon glyphicon-file" aria-hidden="true"></span> ' + corpus_name +'</a>'+"\n"
html_ += ' </label>'+"\n"
html_ += ' </div>'+"\n"
html_ += ' </div>'+"\n"
}
}
}
}
html_ += ' </ul>'+"\n"
html_ += ' </div>'+"\n"
html_ += ' </div>'+"\n"
html_ += ' </div>'+"\n"
}
}
html_ += ' </form>'+"\n"
html_ += '</div>'+"\n"
$("#user_portfolio").html( html_ )
$('#corpuses_form input:radio').change(function() {
$("#add_corpus_tab").prop("disabled",false)
var selected = $('input[name=optradio]:checked')[0].id.split("_")
var sel_p_id = selected[0], sel_c_id =selected[1]
var html_selection = ""
html_selection += '<center>You are comparing :<br><span class="glyphicon glyphicon-hand-down" aria-hidden="true"></span></center>'+"\n"
html_selection += '<center>'
html_selection += '( current graph ) '
html_selection += '<span class="glyphicon glyphicon-resize-horizontal" aria-hidden="true"></span>'
html_selection += ' (' + portfolio[sel_p_id] + ' / ' + portfolio[sel_c_id] + ')'
// html_selection += ' (' + portfolio[sel_p_id] + '/' + sel_c_id + portfolio[sel_c_id] + ')'
html_selection += '</center><br>'+"\n"
$("#selected_corpus").html( html_selection )
});
},
error: function(){
pr('Page Not found: TestFunction()');
}
});
}
function camaraButton(){
$("#PhotoGraph").click(function (){
//canvas=partialGraph._core.domElements.nodes;
var nodesCtx = partialGraph._core.domElements.nodes;
/*
var edgesCtx = document.getElementById("sigma_edges_1").getContext('2d');
var edgesImg = edgesCtx.getImageData(0, 0, document.getElementById("sigma_edges_1").width, document.getElementById("sigma_edges_1").height)
nodesCtx.putImageData(edgesImg,0,0);
//ctx.drawImage(partialGraph._core.domElements.edges,0,0)
//var oCanvas = ctx;
*/
//div = document.getElementById("sigma_nodes_1").getContext('2d');
//ctx = div.getContext("2d");
//oCanvas.drawImage(partialGraph._core.domElements.edges,0,0);
Canvas2Image.saveAsPNG(nodesCtx);
/*
Canvas2Image.saveAsJPEG(oCanvas); // will prompt the user to save the image as JPEG.
// Only supported by Firefox.
Canvas2Image.saveAsBMP(oCanvas); // will prompt the user to save the image as BMP.
// returns an <img> element containing the converted PNG image
var oImgPNG = Canvas2Image.saveAsPNG(oCanvas, true);
// returns an <img> element containing the converted JPEG image (Only supported by Firefox)
var oImgJPEG = Canvas2Image.saveAsJPEG(oCanvas, true);
// returns an <img> element containing the converted BMP image
var oImgBMP = Canvas2Image.saveAsBMP(oCanvas, true);
// all the functions also takes width and height arguments.
// These can be used to scale the resulting image:
// saves a PNG image scaled to 100x100
Canvas2Image.saveAsPNG(oCanvas, false, 100, 100);
*/
});
}
function getTips(){
param='';
text =
"<br>"+
"Basic Interactions:"+
"<ul>"+
"<li>Click on a node to select/unselect and get its information. In case of multiple selection, the button unselect clears all selections.</li>"+
"<li>The switch button switch allows to change the view type.</li>"+
"</ul>"+
"<br>"+
"Graph manipulation:"+
"<ul>"+
"<li>Link and node sizes indicate their strength.</li>"+
"<li>To fold/unfold the graph (keep only strong links or weak links), use the 'edges filter' sliders.</li>"+
"<li>To select a more of less specific area of the graph, use the 'nodes filter' slider.</li>"+
"</ul>"+
"<br>"+
"Micro/Macro view:"+
"<ul>"+
"<li>To explore the neighborhood of a selection, either double click on the selected nodes, either click on the macro/meso level button. Zoom out in meso view return to macro view.</li>"+
"<li>Click on the 'all nodes' tab below to view the full clickable list of nodes.</li>"+
"</ul>";
$("#tab-container").hide();
$("#tab-container-top").hide();
return text;
}
/*
* Customize as you want ;)
*/
// ============ < DEVELOPER OPTIONS > ============
var geomap=false;
var colorByAtt = false;
var twittertimeline = false;
var minimap=false;
var getAdditionalInfo=true;//for topPapers div
var mainfile = ["db.json"];
// // var mainfile = "api.json";
// var mainfile = [
// "data/2-Terms-Authors-300nodes.gexf",
// "data/0-terms-terms-MainNodes.gexf",
// "data/maziyar2.json",
// "data/3-Terms-Countries-300nodes.gexf",
// // "data/noclimatechange_mnodes.gexf",
// "data/20150518t1052_phylograph.json",
// // "data/phylograph_6.json",
// // "data/maziyar.json",
// // "data/20141128_GPs_03_bi.gexf",
// // "data/example.json",
// // "data/Elisa__Omodei.gexf",
// ];
// getUrlParam.file = window.location.origin+"/"+$("#graphid").html(); // garg exclusive
// var corpusesList = {} // garg exclusive -> corpus comparison
// getUrlParam.file = "data/testgraph.json";
if( isUndef(getUrlParam.field1) && isUndef(getUrlParam.field2) ) {
if($("#graphid").length>0) {
getUrlParam.file = window.location.origin+"/"+$("#graphid").html(); // just Garg
}
} else {
var current_url = window.location.origin+window.location.pathname+window.location.search
getUrlParam.file = current_url.replace(/project(.*?)corpus/g, "api/corpus").replace("explorer?","graph?")
}
// if($("#graphid").length>0) // just Garg
// getUrlParam.file = window.location.origin+"/"+$("#graphid").html(); // just Garg
var corpusesList = {}
var Clusters = [];
var dataFolderTree = {};
var gexfDict={};
var egonode = {}
var iwantograph = "";
var bridge={};
var external="";
//external="http://tina.iscpif.fr/explorerjs/";//Just if you want to use the server-apps from tina.server
bridge["forFilteredQuery"] = external+"php/bridgeClientServer_filter.php";
bridge["forNormalQuery"] = external+"php/bridgeClientServer.php";
var gexfDict={};
// gexfDict["data/terrorism/terrorism_mono.gexf"] = "[2001-2014] TERRORISM (1-partite graph)";
// gexfDict["data/terrorism/terrorism_bi.gexf"] = "[2001-2014] TERRORISM (2-partite graph)";
var field = {}
// field["data/20141128_GPs_03_bi.gexf"] = "ISItermsfirstindexing";
// field["data/20141215_GPs_04.gexf"] = "ISItermsfirstindexing";
// field["data/medq2/20141128_MED_02_bi.gexf"] = "ISItermsBigWL";
// field["data/medq2/20141128_MED_03_bi.gexf"] = "ISItermsBigWL";
// field["data/medq2/20141208_MED_Author_name-ISItermsjulien_index.gexf"] = "ISItermsjulien_index";
// field["data/medq1/20141208_MED_01_bi.gexf"] = "ISItermsfirstindex";
// field["data/terrorism/terrorism_mono.gexf"] = "ISItermsListV1";
// field["data/terrorism/terrorism_bi.gexf"] = "ISItermsListV1";
var ParseCustom = function () {};
var SigmaUtils = function () {};
var TinaWebJS = function () {};
var Relations = {}
var SystemStates = {}
SystemStates.level = true;
SystemStates.type = [ true ] //[ true , false ]; //social activated!
SystemStates.selections = [];
SystemStates.opposites = [];
ircNick="";
ircCHN="";
var catSoc = "Document";
var catSem = "NGram";
var sizeMult = [];
sizeMult[catSoc] = 0.0;
sizeMult[catSem] = 0.0;
var inactiveColor = '#666';
var startingNodeId = "1";
var minLengthAutoComplete = 1;
var maxSearchResults = 10;
var strSearchBar = "Search";
var cursor_size_min= 0;
var cursor_size= 10;
var cursor_size_max= 100;
var desirableTagCloudFont_MIN=12;
var desirableTagCloudFont_MAX=20;
var desirableNodeSizeMIN=1;
var desirableNodeSizeMAX=12;
var desirableScholarSize=6; //Remember that all scholars have the same size!
/*
*Three states:
* - true: fa2 running at start
* - false: fa2 stopped at start, button exists
* - "off": button doesn't exist, fa2 stopped forever
**/ var fa2enabled=false;//"off";
var stopcriteria = false;
var iterationsFA2=1000;
var seed=999999999;//defaultseed
var semanticConverged=false;
var fa2seconds = 4;
var showLabelsIfZoom=1.0;
var greyColor = "#9b9e9e";
// ============ < SIGMA.JS PROPERTIES > ============
var sigmaJsDrawingProperties = {
defaultLabelColor: 'black',
defaultLabelSize: 10,//in fact I'm using it as minLabelSize'
defaultLabelBGColor: '#fff',
defaultLabelHoverColor: '#000',
labelThreshold: 4,
labelSize: "proportional",
defaultEdgeType: 'curve',
borderSize: 2.5,//Something other than 0
nodeBorderColor: "default",//exactly like this
defaultNodeBorderColor: "black"//,//Any color of your choice
//defaultBorderView: "always"
};
var sigmaJsGraphProperties = {
minEdgeSize: 2,
maxEdgeSize: 4,
};
var sigmaJsMouseProperties = {
minRatio:0.1,
maxRatio: 50
};
// ============ < / SIGMA.JS PROPERTIES > ============
// ============ < / DEVELOPER OPTIONS > ============
// ============ < VARIABLES.JS > ============
//"http://webchat.freenode.net/?nick=Ademe&channels=#anoe"
var ircUrl="http://webchat.freenode.net/?nick="+ircNick+"&channels="+ircCHN;
var twjs="tinawebJS/";
var categories = {};
var categoriesIndex = [];
var wnws_buffer = null;
var gexf;
//var zoom=0;
var checkBox=false;
var overNodes=false;
var shift_key=false;
var NOW="A";
var PAST="--";
var swclickActual="";
var swclickPrev="";
var swMacro=true;
var socsemFlag=false;
var constantNGramFilter;
var lastFilter = []
lastFilter["#slidercat0nodesweight"] = {"orig":"-" , "last":"-"}
lastFilter["#slidercat1nodesweight"] = {"orig":"-" , "last":"-"}
lastFilter["#slidercat0edgesweight"] = {"orig":"-" , "last":"-"}
lastFilter["#slidercat1edgesweight"] = {"orig":"-" , "last":"-"}
var Filters = {}
var overviewWidth = 200;
var overviewHeight = 175;
var overviewScale = 0.25;
var overviewHover=false;
var moveDelay = 80, zoomDelay = 2;
//var Vecindad;
var partialGraph;
var otherGraph;
var Nodes = [];
var Edges = [];
var nodeslength=0;
var labels = [];
var numberOfDocs=0;
var numberOfNGrams=0;
var selections = [];
var deselections={};
var opossites = {};
var opos=[];
var oposMAX;
var matches = [];
var nodes1 = {};
var nodes2 = {};
var bipartiteD2N = {};
var bipartiteN2D = {};
var flag=0;
var firstime=0;
var leftright=true;
var edgesTF=false;
//This variables will be updated in sigma.parseCustom.js
var minNodeSize=1.00;
var maxNodeSize=5.00;
var minEdgeWeight=5.0;
var maxEdgeWeight=0.0;
//---------------------------------------------------
var bipartite=false;
var gexfDictReverse={}
for (var i in gexfDict){
gexfDictReverse[gexfDict[i]]=i;
}
var colorList = ["#000000", "#FFFF00", "#1CE6FF", "#FF34FF", "#FF4A46", "#008941", "#006FA6", "#A30059", "#FFDBE5", "#7A4900", "#0000A6", "#63FFAC", "#B79762", "#004D43", "#8FB0FF", "#997D87", "#5A0007", "#809693", "#FEFFE6", "#1B4400", "#4FC601", "#3B5DFF", "#4A3B53", "#FF2F80", "#61615A", "#BA0900", "#6B7900", "#00C2A0", "#FFAA92", "#FF90C9", "#B903AA", "#D16100", "#DDEFFF", "#000035", "#7B4F4B", "#A1C299", "#300018", "#0AA6D8", "#013349", "#00846F", "#372101", "#FFB500", "#C2FFED", "#A079BF", "#CC0744", "#C0B9B2", "#C2FF99", "#001E09", "#00489C", "#6F0062", "#0CBD66", "#EEC3FF", "#456D75", "#B77B68", "#7A87A1", "#788D66", "#885578", "#FAD09F", "#FF8A9A", "#D157A0", "#BEC459", "#456648", "#0086ED", "#886F4C","#34362D", "#B4A8BD", "#00A6AA", "#452C2C", "#636375", "#A3C8C9", "#FF913F", "#938A81", "#575329", "#00FECF", "#B05B6F", "#8CD0FF", "#3B9700", "#04F757", "#C8A1A1", "#1E6E00", "#7900D7", "#A77500", "#6367A9", "#A05837", "#6B002C", "#772600", "#D790FF", "#9B9700", "#549E79", "#FFF69F", "#201625", "#72418F", "#BC23FF", "#99ADC0", "#3A2465", "#922329", "#5B4534", "#FDE8DC", "#404E55", "#0089A3", "#CB7E98", "#A4E804", "#324E72", "#6A3A4C", "#83AB58", "#001C1E", "#D1F7CE", "#004B28", "#C8D0F6", "#A3A489", "#806C66", "#222800", "#BF5650", "#E83000", "#66796D", "#DA007C", "#FF1A59", "#8ADBB4", "#1E0200", "#5B4E51", "#C895C5", "#320033", "#FF6832", "#66E1D3", "#CFCDAC", "#D0AC94", "#7ED379", "#012C58"];
var RVUniformC = function(seed){
this.a=16807;
this.b=0;
this.m=2147483647;
this.u;
this.seed=seed;
this.x = this.seed;
// this.generar = function(n){
// uniforme = [];
// x = 0.0;
// x = this.seed;
// for(i = 1; i < n ; i++){
// x = ((x*this.a)+this.b)%this.m;
// uniforme[i] = x/this.m;
// }
// return uniforme;
// };
this.getRandom = function(){
x = ((this.x*this.a)+this.b)%this.m;
this.x = x;
this.u = this.x/this.m;
return this.u;
};
}
//unifCont = new RVUniformC(100000000)
This source diff could not be displayed because it is too large. You can view the blob instead.
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