Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
58758408
Commit
58758408
authored
Nov 18, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mise a jour
parent
02225ace
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
209 additions
and
15 deletions
+209
-15
extras_explorerjs.js
extras_explorerjs.js
+155
-3
main.js
tinawebJS/main.js
+9
-1
methods.js
tinawebJS/methods.js
+8
-1
sigma.parseCustom.js
tinawebJS/sigma.parseCustom.js
+1
-1
sigmaUtils.js
tinawebJS/sigmaUtils.js
+36
-9
No files found.
extras_explorerjs.js
View file @
58758408
...
...
@@ -7,6 +7,108 @@ function newPopup(url) {
}
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
)
{
var
selected_ngrams
=
Object
.
keys
(
selections
).
map
(
Number
)
console
.
clear
()
console
.
log
(
selected_ngrams
)
var
corpus_id
=
getIDFromURL
(
"corpus"
)
// not used
var
list_id
=
$
(
"#list_id"
).
val
()
var
nodes
=
[]
var
http_method
=
"DELETE"
//"GET"
var
args
=
selected_ngrams
//[]
if
(
classname
==
"delete"
)
{
var
the_url
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams"
+
"/keep"
+
"/"
+
nodes
.
join
(
"+"
);
the_url
=
the_url
.
replace
(
/
\/
$/
,
""
);
//remove trailing slash
$
.
ajax
({
method
:
http_method
,
url
:
the_url
,
data
:
args
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
){
console
.
log
(
"GET"
+
" ok!!"
)
console
.
log
(
nodes
)
console
.
log
(
data
)
console
.
log
(
"Success"
);
},
error
:
function
(
result
)
{
console
.
log
(
result
)
console
.
log
(
"Fail"
);
}
});
// CRUD_( corpus_id , "/keep" , [] , selected_ngrams , "DELETE" , function(result) {
// console.log(" Delete from Map-list: "+result)
// // CRUD( list_id , "" , selected_ngrams , [] , "DELETE", function(result) {
// // console.log(" Add to Stop-list "+result)
// // for(var i in selected_ngrams) {
// // partialGraph.dropNode( selected_ngrams[i] )
// // delete Nodes[selected_ngrams[i]]
// // }
// // partialGraph.refresh()
// // partialGraph.draw()
// // });
// // cancelSelection(false)
// // for(var i in selected_ngrams) {
// // partialGraph.dropNode( selected_ngrams[i] )
// // delete Nodes[selected_ngrams[i]]
// // }
// // partialGraph.refresh()
// // partialGraph.draw()
// });
}
// if(classname=="group") {
// CRUD( corpus_id , "/group" , [] , selected_ngrams , "PUT" , function(result) {
// console.log(" UN ELEFANTE "+result)
// CRUD( corpus_id , "/keep" , [] , selected_ngrams , "PUT" , function(result) {
// });
// });
// }
}
function
CRUD_
(
parent_id
,
action
,
nodes
,
args
,
http_method
,
callback
)
{
var
the_url
=
window
.
location
.
origin
+
"/api/node/"
+
parent_id
+
"/ngrams"
+
action
+
"/"
+
nodes
.
join
(
"+"
);
the_url
=
the_url
.
replace
(
/
\/
$/
,
""
);
//remove trailing slash
console
.
log
(
the_url
)
console
.
log
(
args
)
if
(
nodes
.
length
>
0
||
Object
.
keys
(
args
).
length
>
0
)
{
$
.
ajax
({
method
:
http_method
,
url
:
the_url
,
data
:
args
,
beforeSend
:
function
(
xhr
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
success
:
function
(
data
){
console
.
log
(
http_method
+
" ok!!"
)
console
.
log
(
nodes
)
console
.
log
(
data
)
callback
(
"Success"
);
},
error
:
function
(
result
)
{
console
.
log
(
result
)
callback
(
"Fail"
);
}
});
}
else
callback
(
false
);
}
// = = = = = = = = = = = [ Clusters Plugin ] = = = = = = = = = = = //
// Execution: ChangeGraphAppearanceByAtt( true )
...
...
@@ -61,7 +163,6 @@ function newPopup(url) {
return
b
-
a
});
// console.log( "I AM IN ChangeGraphAppearanceByAtt( true )" )
// console.log( AttsDict_sorted )
...
...
@@ -81,14 +182,15 @@ function newPopup(url) {
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
+
'")
\'
>By '
+
att_s
+
'('
+
att_c
+
')'
+
'</a></li>'
pr
(
'<li><a href="#" onclick=
\'
'
+
the_method
+
'("'
+
att_s
+
'")
\'
>By '
+
att_s
+
'('
+
att_c
+
')'
+
'</a></li>'
)
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"
);
...
...
@@ -96,6 +198,56 @@ function newPopup(url) {
}
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/js/libs/img2/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)
...
...
tinawebJS/main.js
View file @
58758408
...
...
@@ -313,7 +313,7 @@ function MainFunction( RES ) {
partialGraph
.
zoomTo
(
partialGraph
.
_core
.
width
/
2
,
partialGraph
.
_core
.
height
/
2
,
0.8
).
draw
();
// fa2enabled=true; partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw();
// fa2enabled=true;
//
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw();
// $.doTimeout(1,function(){
// fa2enabled=true; partialGraph.startForceAtlas2();
// $.doTimeout(10,function(){
...
...
@@ -336,6 +336,14 @@ function MainFunction( RES ) {
set_ClustersLegend
(
"clust_default"
)
$
(
"footer"
).
remove
()
console
.
log
(
"FIN"
)
fa2enabled
=
true
;
partialGraph
.
startForceAtlas2
();
setTimeout
(
function
()
{
console
.
log
(
"LALALALALALLA"
)
partialGraph
.
stopForceAtlas2
();
},
fa2seconds
*
1000
);
}
...
...
tinawebJS/methods.js
View file @
58758408
...
...
@@ -31,6 +31,7 @@ function cancelSelection (fromTagCloud) {
if
(
fromTagCloud
==
false
){
$
(
"#names"
).
html
(
""
);
$
(
"#ngrams_actions"
).
html
(
""
)
$
(
"#topPapers"
).
html
(
""
);
$
(
"#topPapers"
).
hide
();
$
(
"#opossiteNodes"
).
html
(
""
);
$
(
"#tab-container"
).
hide
();
$
(
"#information"
).
html
(
""
);
...
...
@@ -458,7 +459,6 @@ function htmlfied_nodesatts(elems){
return
socnodes
.
concat
(
semnodes
)
}
//missing: getTopPapers for both node types
//considering complete graphs case! <= maybe i should mv it
function
updateLeftPanel_fix
(
sels
,
oppos
)
{
...
...
@@ -473,6 +473,12 @@ function updateLeftPanel_fix( sels , oppos ) {
namesDIV
+=
getNodeLabels
(
sels
).
join
(
' <b>/</b> '
)
//aqui limitar
namesDIV
+=
'</h4></div>'
;
var
ngram_actions
=
''
// ngram_actions += '<center>'
// ngram_actions += '<span><button class="delete" onclick="modify_ngrams(this.className)">Delete</button></span>'
// ngram_actions += '<span><button class="group" onclick="modify_ngrams(this.className)">Group</button></span>'
// ngram_actions += '</center>'
if
(
oppos
.
length
>
0
)
{
alterNodesDIV
+=
'<div id="opossitesBox">'
;
//tagcloud
alterNodesDIV
+=
htmlfied_alternodes
(
oppos
).
join
(
"
\n
"
)
...
...
@@ -497,6 +503,7 @@ function updateLeftPanel_fix( sels , oppos ) {
// pushing my commit
// because i need more lines, idk
$
(
"#names"
).
html
(
namesDIV
).
readmore
({
maxHeight
:
100
});
$
(
"#ngrams_actions"
).
html
(
ngram_actions
)
$
(
"#tab-container"
).
show
();
$
(
"#opossiteNodes"
).
html
(
alterNodesDIV
).
readmore
({
maxHeight
:
200
});
$
(
"#sameNodes"
).
html
(
sameNodesDIV
).
readmore
({
maxHeight
:
200
});
...
...
tinawebJS/sigma.parseCustom.js
View file @
58758408
...
...
@@ -689,7 +689,7 @@ function dictfyJSON( data , categories ) {
if
(
!
edges
[
target
+
";"
+
source
])
{
if
(
nodes
[
source
].
color
&&
nodes
[
target
].
color
)
{
edges
[
target
+
";"
+
source
]
=
edge
;
edges
[
source
+
";"
+
target
]
=
edge
;
}
}
...
...
tinawebJS/sigmaUtils.js
View file @
58758408
...
...
@@ -279,10 +279,34 @@ function getAcronyms() {
}
function
clustersBy
(
daclass
)
{
function
clustersBy
(
daclass
,
att2change
)
{
cancelSelection
(
false
);
var
v_nodes
=
getVisibleNodes
();
if
(
daclass
==
"default"
)
{
if
(
att2change
==
"size"
)
{
var
NodeID_Val
=
{}
var
real_min
=
1000000
;
var
real_max
=
-
1
;
var
themult
=
Math
.
pow
(
10
,
min_pow
);
for
(
var
i
in
v_nodes
)
{
var
the_node
=
Nodes
[
v_nodes
[
i
].
id
]
var
attval
=
(
the_node
.
size
)?
Math
.
log
(
the_node
.
size
+
1
)
:
3
;
var
attnumber
=
Number
(
attval
);
partialGraph
.
_core
.
graph
.
nodesIndex
[
v_nodes
[
i
].
id
].
size
=
attval
;
partialGraph
.
_core
.
graph
.
nodesIndex
[
v_nodes
[
i
].
id
].
label
=
the_node
.
label
;
}
partialGraph
.
refresh
();
partialGraph
.
draw
();
return
true
;
}
}
var
min_pow
=
0
;
for
(
var
i
in
v_nodes
)
{
var
the_node
=
Nodes
[
v_nodes
[
i
].
id
]
...
...
@@ -331,15 +355,18 @@ function clustersBy(daclass) {
var
Max_size
=
6
;
for
(
var
i
in
NodeID_Val
)
{
var
newval_color
=
Math
.
round
(
(
Min_color
+
(
NodeID_Val
[
i
][
"round"
]
-
real_min
)
*
((
Max_color
-
Min_color
)
/
(
real_max
-
real_min
))
)
);
var
hex_color
=
rgbToHex
(
255
,
(
255
-
newval_color
)
,
0
)
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
color
=
hex_color
if
(
att2change
==
"color"
)
{
var
newval_color
=
Math
.
round
(
(
Min_color
+
(
NodeID_Val
[
i
][
"round"
]
-
real_min
)
*
((
Max_color
-
Min_color
)
/
(
real_max
-
real_min
))
)
);
var
hex_color
=
rgbToHex
(
255
,
(
255
-
newval_color
)
,
0
)
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
][
att2change
]
=
hex_color
}
var
newval_size
=
Math
.
round
(
(
Min_size
+
(
NodeID_Val
[
i
][
"round"
]
-
real_min
)
*
((
Max_size
-
Min_size
)
/
(
real_max
-
real_min
))
)
);
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
size
=
newval_size
;
// pr("real:"+ NodeID_Val[i]["real"] + " | newvalue: "+newval_size)
if
(
att2change
==
"size"
)
{
var
newval_size
=
Math
.
round
(
(
Min_size
+
(
NodeID_Val
[
i
][
"round"
]
-
real_min
)
*
((
Max_size
-
Min_size
)
/
(
real_max
-
real_min
))
)
);
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
][
att2change
]
=
newval_size
;
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
label
=
"("
+
NodeID_Val
[
i
][
"real"
].
toFixed
(
min_pow
)
+
") "
+
Nodes
[
i
].
label
}
partialGraph
.
_core
.
graph
.
nodesIndex
[
i
].
label
=
"("
+
NodeID_Val
[
i
][
"real"
].
toFixed
(
min_pow
)
+
") "
+
Nodes
[
i
].
label
}
// [ / Scaling node colours(0-255) and sizes(3-5) ]
...
...
@@ -372,7 +399,7 @@ function clustersBy(daclass) {
}
function
colorsBy
(
daclass
)
{
function
colorsBy
(
daclass
,
att2change
)
{
pr
(
""
)
pr
(
" = = = = = = = = = = = = = = = = = "
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment