Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
20aed85e
Commit
20aed85e
authored
May 31, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove .index "decorator" that was too opaque
parent
baa586a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
66 deletions
+56
-66
Tinaweb.js
tinawebJS/Tinaweb.js
+32
-21
main.js
tinawebJS/main.js
+24
-45
No files found.
tinawebJS/Tinaweb.js
View file @
20aed85e
...
...
@@ -4,19 +4,25 @@
function
SelectionEngine
()
{
// creates the union of prevsels and currsels, if addvalue
this
.
SelectorEngine
=
(
function
(
addvalue
,
prevsels
,
currsels
)
{
// console.log("addvalue, prevsels, currsels",addvalue, prevsels, currsels)
this
.
SelectorEngine
=
function
(
args
)
{
console
.
log
(
"addvalue, prevsels, currsels"
,
args
)
if
(
!
args
)
args
=
{}
if
(
!
args
.
addvalue
)
args
.
addvalue
=
false
if
(
!
args
.
prevsels
)
args
.
prevsels
=
{}
// FIXME easier with array like currsels.concat(buffer)
if
(
!
args
.
currsels
)
args
.
currsels
=
[]
var
targeted
=
[]
var
buffer
=
Object
.
keys
(
prevsels
);
var
buffer
=
Object
.
keys
(
args
.
prevsels
);
// currsels = bunch of nodes from a click in the map
if
(
addvalue
)
{
// FOR SIMPLE
ADD WITHOUT COMPLEMENT
targeted
=
currsels
.
concat
(
buffer
.
filter
(
function
(
item
)
{
return
currsels
.
indexOf
(
item
)
<
0
;
if
(
a
rgs
.
a
ddvalue
)
{
// FOR SIMPLE
UNIQUE UNION
targeted
=
args
.
currsels
.
concat
(
buffer
.
filter
(
function
(
item
)
{
return
args
.
currsels
.
indexOf
(
item
)
<
0
;
}));
}
else
targeted
=
currsels
;
}
else
targeted
=
args
.
currsels
;
if
(
targeted
.
length
==
0
)
return
[];
...
...
@@ -47,7 +53,7 @@ function SelectionEngine() {
// targeted = Object.keys(whitelist);
// } else {// inter = 0 ==> click in other portion of the graph (!= current selection)
// // Union!
// if(addvalue) {
// if(a
rgs.a
ddvalue) {
// targeted = currsels.concat(buffer.filter(function (item) {
// return currsels.indexOf(item) < 0;
// }));
...
...
@@ -57,7 +63,7 @@ function SelectionEngine() {
// ---------------------------------------------------------->8---------
return
targeted
;
}
).
index
()
;
};
// uses: SelectorEngine() and MultipleSelection2()
...
...
@@ -145,13 +151,18 @@ function SelectionEngine() {
* updateRelatedNodesPanel();
*/
// ====================
this
.
MultipleSelection2
=
(
function
(
nodes
,
nodesDict
,
edgesDict
)
{
this
.
MultipleSelection2
=
function
(
args
)
{
if
(
!
args
)
args
=
{}
if
(
isUndef
(
args
.
nodes
))
args
.
nodes
=
[]
if
(
isUndef
(
args
.
nodesDict
))
args
.
nodesDict
=
{}
if
(
isUndef
(
args
.
edgesDict
))
args
.
edgesDict
=
{}
if
(
TW
.
conf
.
debug
.
logSelections
)
{
var
tMS2_deb
=
performance
.
now
()
console
.
log
(
"IN SelectionEngine.MultipleSelection2:"
)
console
.
log
(
"nodes"
,
nodes
)
console
.
log
(
"nodes"
,
args
.
nodes
)
}
greyEverything
();
...
...
@@ -174,17 +185,17 @@ function SelectionEngine() {
// console.log (" - - - - - - ")
// Dictionaries of: selection+neighbors
var
nodes_2_colour
=
(
nodesDict
)?
nodesDict
:
{};
var
edges_2_colour
=
(
edgesDict
)?
edgesDict
:
{};
var
nodes_2_colour
=
args
.
nodesDict
var
edges_2_colour
=
args
.
edgesDict
selections
=
{}
// targeted arg 'nodes' can be nid array or single nid
var
ndsids
=
[]
if
(
nodes
)
{
if
(
!
$
.
isArray
(
nodes
))
ndsids
.
push
(
nodes
);
else
ndsids
=
nodes
;
if
(
args
.
nodes
)
{
if
(
!
$
.
isArray
(
args
.
nodes
))
ndsids
.
push
(
args
.
nodes
);
else
ndsids
=
args
.
nodes
;
for
(
var
i
in
ndsids
)
{
var
s
=
ndsids
[
i
];
...
...
@@ -339,7 +350,7 @@ function SelectionEngine() {
}
).
index
()
}
};
// TODO TW.SelInst
...
...
@@ -361,7 +372,7 @@ TinaWebJS = function ( sigmacanvas ) {
else
{
this
.
prepareSigmaCustomIndices
(
sigma
)
if
(
TW
.
conf
.
our
Rendering
)
if
(
TW
.
conf
.
tw
Rendering
)
this
.
prepareSigmaCustomRenderers
(
sigma
)
}
...
...
@@ -1024,7 +1035,7 @@ TinaWebJS = function ( sigmacanvas ) {
$
(
"#zoomPlusButton"
).
click
(
function
()
{
var
newRatio
=
TW
.
cam
.
ratio
*
.
75
if
(
newRatio
>=
TW
.
conf
.
sigmaJsMouseProperties
.
minRatio
)
{
if
(
newRatio
>=
TW
.
conf
.
zoomMin
)
{
// triggers coordinatesUpdated which sets the slider cursor
partialGraph
.
camera
.
goTo
({
ratio
:
newRatio
});
return
false
;
...
...
@@ -1033,7 +1044,7 @@ TinaWebJS = function ( sigmacanvas ) {
$
(
"#zoomMinusButton"
).
click
(
function
()
{
var
newRatio
=
TW
.
cam
.
ratio
*
1.25
if
(
newRatio
<=
TW
.
conf
.
sigmaJsMouseProperties
.
maxRatio
)
{
if
(
newRatio
<=
TW
.
conf
.
zoomMax
)
{
// triggers coordinatesUpdated which sets the slider cursor
partialGraph
.
camera
.
goTo
({
ratio
:
newRatio
});
return
false
;
...
...
tinawebJS/main.js
View file @
20aed85e
'use strict'
;
// Function.prototype.index
// ---
// 'decorator'
// (used here and in Tinaweb.js for MultipleSelection2)
// ---
// transforms calls like foobar({arg1:a, arg2:b})
// into calls like foobar(a, b)
(
function
(
reComments
,
reParams
,
reNames
)
{
Function
.
prototype
.
index
=
function
(
arrParamNames
)
{
var
fnMe
=
this
;
arrParamNames
=
arrParamNames
||
(((
fnMe
+
''
).
replace
(
reComments
,
''
)
.
match
(
reParams
)[
1
]
||
''
)
.
match
(
reNames
)
||
[]);
return
function
(
namedArgs
)
{
var
args
=
[],
i
=
arrParamNames
.
length
;
args
[
i
]
=
namedArgs
;
while
(
i
--
)
{
args
[
i
]
=
namedArgs
[
arrParamNames
[
i
]];
}
return
fnMe
.
apply
(
this
,
args
);
};
};
})(
/
\/\*[\s\S]
*
?\*\/
|
\/\/
.*
?[\r\n]
/g
,
/
\(([\s\S]
*
?)\)
/
,
/
[
$
\w]
+/g
);
// ajax request
// args:
// - type: REST method to use: GET (by def), POST...
// - url: target url
// - data: url params or payload if POST
// - datatype: expected response format: 'json', 'text' (by def)...
var
AjaxSync
=
function
(
args
)
{
if
(
!
args
)
args
=
{}
if
(
isUndef
(
args
.
url
))
console
.
error
(
"AjaxSync call needs url"
)
if
(
isUndef
(
args
.
type
))
args
.
type
=
'GET'
if
(
isUndef
(
args
.
datatype
))
args
.
datatype
=
'text'
else
if
(
args
.
datatype
==
"jsonp"
)
args
.
datatype
=
"json"
var
AjaxSync
=
(
function
(
TYPE
,
URL
,
DATA
,
DT
)
{
var
Result
=
[]
TYPE
=
(
!
TYPE
)?
"GET"
:
TYPE
if
(
DT
&&
(
DT
==
"jsonp"
||
DT
==
"json"
))
DT
=
"json"
else
DT
=
'text'
// ie "if not json then raw xml string"
if
(
TW
.
conf
.
debug
.
logFetchers
)
console
.
log
(
"---AjaxSync---
\n
"
,
TYPE
,
URL
,
DATA
,
DT
,
"
\n
--------------"
)
console
.
log
(
"---AjaxSync---
"
,
args
)
$
.
ajax
({
type
:
TYPE
,
url
:
URL
,
dataType
:
DT
,
// <= the expected response format
type
:
args
.
type
,
url
:
args
.
url
,
dataType
:
args
.
datatype
,
async
:
false
,
// <= synchronous (POSS alternative: cb + waiting display)
// our payload: filters...
data
:
DATA
,
data
:
args
.
data
,
contentType
:
'application/json'
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
var
header
=
jqXHR
.
getResponseHeader
(
"Content-Type"
)
...
...
@@ -61,7 +40,7 @@ var AjaxSync = (function(TYPE, URL, DATA, DT) {
}
else
{
if
(
TW
.
conf
.
debug
.
logFetchers
)
console
.
debug
(
"after AjaxSync("
+
URL
+
") => response header="
+
header
+
"not xml => fallback on json"
);
console
.
debug
(
"after AjaxSync("
+
args
.
url
+
") => response header="
+
header
+
"not xml => fallback on json"
);
format
=
"json"
;
}
Result
=
{
"OK"
:
true
,
"format"
:
format
,
"data"
:
data
};
...
...
@@ -72,7 +51,7 @@ var AjaxSync = (function(TYPE, URL, DATA, DT) {
}
});
return
Result
;
}
).
index
();
}
// === [ what to do at start ] === //
...
...
@@ -232,7 +211,7 @@ function syncRemoteGraphData () {
mapLabel
=
'"'
+
elements
.
join
(
'" , "'
)
+
'"'
;
}
var
bridgeRes
=
AjaxSync
({
URL
:
theurl
,
DATA
:
thedata
,
TYPE
:
'GET'
,
DT
:
'json'
})
var
bridgeRes
=
AjaxSync
({
url
:
theurl
,
data
:
thedata
,
type
:
'GET'
,
datatype
:
'json'
})
// should be a js object with 'nodes' and 'edges' properties
inData
=
bridgeRes
.
data
...
...
@@ -270,7 +249,7 @@ function syncRemoteGraphData () {
var
infofile
=
TW
.
conf
.
sourceMenu
if
(
TW
.
conf
.
debug
.
logFetchers
)
console
.
info
(
`attempting to load filemenu
${
infofile
}
`
)
var
preRES
=
AjaxSync
({
URL
:
infofile
,
DT
:
"json"
});
var
preRES
=
AjaxSync
({
url
:
infofile
,
datatype
:
"json"
});
if
(
preRES
[
'OK'
]
&&
preRES
.
data
)
{
console
.
log
(
'initial AjaxSync result preRES'
,
preRES
)
...
...
@@ -344,7 +323,7 @@ function syncRemoteGraphData () {
console
.
error
(
`No specified input and neither db.json nor TW.conf.sourceFile
${
TW
.
conf
.
sourceFile
}
are present`
)
}
var
finalRes
=
AjaxSync
({
URL
:
the_file
});
var
finalRes
=
AjaxSync
({
url
:
the_file
});
inData
=
finalRes
[
"data"
]
inFormat
=
finalRes
[
"format"
]
...
...
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