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
8 years ago
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove .index "decorator" that was too opaque
parent
baa586a0
Changes
2
Hide 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 @@
...
@@ -4,19 +4,25 @@
function
SelectionEngine
()
{
function
SelectionEngine
()
{
// creates the union of prevsels and currsels, if addvalue
// creates the union of prevsels and currsels, if addvalue
this
.
SelectorEngine
=
(
function
(
addvalue
,
prevsels
,
currsels
)
{
this
.
SelectorEngine
=
function
(
args
)
{
// console.log("addvalue, prevsels, currsels",addvalue, prevsels, currsels)
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
targeted
=
[]
var
buffer
=
Object
.
keys
(
prevsels
);
var
buffer
=
Object
.
keys
(
args
.
prevsels
);
// currsels = bunch of nodes from a click in the map
// currsels = bunch of nodes from a click in the map
if
(
addvalue
)
{
if
(
a
rgs
.
a
ddvalue
)
{
// FOR SIMPLE
ADD WITHOUT COMPLEMENT
// FOR SIMPLE
UNIQUE UNION
targeted
=
currsels
.
concat
(
buffer
.
filter
(
function
(
item
)
{
targeted
=
args
.
currsels
.
concat
(
buffer
.
filter
(
function
(
item
)
{
return
currsels
.
indexOf
(
item
)
<
0
;
return
args
.
currsels
.
indexOf
(
item
)
<
0
;
}));
}));
}
else
targeted
=
currsels
;
}
else
targeted
=
args
.
currsels
;
if
(
targeted
.
length
==
0
)
return
[];
if
(
targeted
.
length
==
0
)
return
[];
...
@@ -47,7 +53,7 @@ function SelectionEngine() {
...
@@ -47,7 +53,7 @@ function SelectionEngine() {
// targeted = Object.keys(whitelist);
// targeted = Object.keys(whitelist);
// } else {// inter = 0 ==> click in other portion of the graph (!= current selection)
// } else {// inter = 0 ==> click in other portion of the graph (!= current selection)
// // Union!
// // Union!
// if(addvalue) {
// if(a
rgs.a
ddvalue) {
// targeted = currsels.concat(buffer.filter(function (item) {
// targeted = currsels.concat(buffer.filter(function (item) {
// return currsels.indexOf(item) < 0;
// return currsels.indexOf(item) < 0;
// }));
// }));
...
@@ -57,7 +63,7 @@ function SelectionEngine() {
...
@@ -57,7 +63,7 @@ function SelectionEngine() {
// ---------------------------------------------------------->8---------
// ---------------------------------------------------------->8---------
return
targeted
;
return
targeted
;
}
).
index
()
;
};
// uses: SelectorEngine() and MultipleSelection2()
// uses: SelectorEngine() and MultipleSelection2()
...
@@ -145,13 +151,18 @@ function SelectionEngine() {
...
@@ -145,13 +151,18 @@ function SelectionEngine() {
* updateRelatedNodesPanel();
* 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
)
{
if
(
TW
.
conf
.
debug
.
logSelections
)
{
var
tMS2_deb
=
performance
.
now
()
var
tMS2_deb
=
performance
.
now
()
console
.
log
(
"IN SelectionEngine.MultipleSelection2:"
)
console
.
log
(
"IN SelectionEngine.MultipleSelection2:"
)
console
.
log
(
"nodes"
,
nodes
)
console
.
log
(
"nodes"
,
args
.
nodes
)
}
}
greyEverything
();
greyEverything
();
...
@@ -174,17 +185,17 @@ function SelectionEngine() {
...
@@ -174,17 +185,17 @@ function SelectionEngine() {
// console.log (" - - - - - - ")
// console.log (" - - - - - - ")
// Dictionaries of: selection+neighbors
// Dictionaries of: selection+neighbors
var
nodes_2_colour
=
(
nodesDict
)?
nodesDict
:
{};
var
nodes_2_colour
=
args
.
nodesDict
var
edges_2_colour
=
(
edgesDict
)?
edgesDict
:
{};
var
edges_2_colour
=
args
.
edgesDict
selections
=
{}
selections
=
{}
// targeted arg 'nodes' can be nid array or single nid
// targeted arg 'nodes' can be nid array or single nid
var
ndsids
=
[]
var
ndsids
=
[]
if
(
nodes
)
{
if
(
args
.
nodes
)
{
if
(
!
$
.
isArray
(
nodes
))
ndsids
.
push
(
nodes
);
if
(
!
$
.
isArray
(
args
.
nodes
))
ndsids
.
push
(
args
.
nodes
);
else
ndsids
=
nodes
;
else
ndsids
=
args
.
nodes
;
for
(
var
i
in
ndsids
)
{
for
(
var
i
in
ndsids
)
{
var
s
=
ndsids
[
i
];
var
s
=
ndsids
[
i
];
...
@@ -339,7 +350,7 @@ function SelectionEngine() {
...
@@ -339,7 +350,7 @@ function SelectionEngine() {
}
).
index
()
}
};
};
// TODO TW.SelInst
// TODO TW.SelInst
...
@@ -361,7 +372,7 @@ TinaWebJS = function ( sigmacanvas ) {
...
@@ -361,7 +372,7 @@ TinaWebJS = function ( sigmacanvas ) {
else
{
else
{
this
.
prepareSigmaCustomIndices
(
sigma
)
this
.
prepareSigmaCustomIndices
(
sigma
)
if
(
TW
.
conf
.
our
Rendering
)
if
(
TW
.
conf
.
tw
Rendering
)
this
.
prepareSigmaCustomRenderers
(
sigma
)
this
.
prepareSigmaCustomRenderers
(
sigma
)
}
}
...
@@ -1024,7 +1035,7 @@ TinaWebJS = function ( sigmacanvas ) {
...
@@ -1024,7 +1035,7 @@ TinaWebJS = function ( sigmacanvas ) {
$
(
"#zoomPlusButton"
).
click
(
function
()
{
$
(
"#zoomPlusButton"
).
click
(
function
()
{
var
newRatio
=
TW
.
cam
.
ratio
*
.
75
var
newRatio
=
TW
.
cam
.
ratio
*
.
75
if
(
newRatio
>=
TW
.
conf
.
sigmaJsMouseProperties
.
minRatio
)
{
if
(
newRatio
>=
TW
.
conf
.
zoomMin
)
{
// triggers coordinatesUpdated which sets the slider cursor
// triggers coordinatesUpdated which sets the slider cursor
partialGraph
.
camera
.
goTo
({
ratio
:
newRatio
});
partialGraph
.
camera
.
goTo
({
ratio
:
newRatio
});
return
false
;
return
false
;
...
@@ -1033,7 +1044,7 @@ TinaWebJS = function ( sigmacanvas ) {
...
@@ -1033,7 +1044,7 @@ TinaWebJS = function ( sigmacanvas ) {
$
(
"#zoomMinusButton"
).
click
(
function
()
{
$
(
"#zoomMinusButton"
).
click
(
function
()
{
var
newRatio
=
TW
.
cam
.
ratio
*
1.25
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
// triggers coordinatesUpdated which sets the slider cursor
partialGraph
.
camera
.
goTo
({
ratio
:
newRatio
});
partialGraph
.
camera
.
goTo
({
ratio
:
newRatio
});
return
false
;
return
false
;
...
...
This diff is collapsed.
Click to expand it.
tinawebJS/main.js
View file @
20aed85e
'use strict'
;
'use strict'
;
// Function.prototype.index
// ajax request
// ---
// args:
// 'decorator'
// - type: REST method to use: GET (by def), POST...
// (used here and in Tinaweb.js for MultipleSelection2)
// - url: target url
// ---
// - data: url params or payload if POST
// transforms calls like foobar({arg1:a, arg2:b})
// - datatype: expected response format: 'json', 'text' (by def)...
// into calls like foobar(a, b)
var
AjaxSync
=
function
(
args
)
{
(
function
(
reComments
,
reParams
,
reNames
)
{
if
(
!
args
)
args
=
{}
Function
.
prototype
.
index
=
function
(
arrParamNames
)
{
if
(
isUndef
(
args
.
url
))
console
.
error
(
"AjaxSync call needs url"
)
var
fnMe
=
this
;
if
(
isUndef
(
args
.
type
))
args
.
type
=
'GET'
arrParamNames
=
arrParamNames
if
(
isUndef
(
args
.
datatype
))
args
.
datatype
=
'text'
||
(((
fnMe
+
''
).
replace
(
reComments
,
''
)
else
if
(
args
.
datatype
==
"jsonp"
)
args
.
datatype
=
"json"
.
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
);
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"
var
Result
=
[]
if
(
TW
.
conf
.
debug
.
logFetchers
)
if
(
TW
.
conf
.
debug
.
logFetchers
)
console
.
log
(
"---AjaxSync---
\n
"
,
TYPE
,
URL
,
DATA
,
DT
,
"
\n
--------------"
)
console
.
log
(
"---AjaxSync---
"
,
args
)
$
.
ajax
({
$
.
ajax
({
type
:
TYPE
,
type
:
args
.
type
,
url
:
URL
,
url
:
args
.
url
,
dataType
:
DT
,
// <= the expected response format
dataType
:
args
.
datatype
,
async
:
false
,
// <= synchronous (POSS alternative: cb + waiting display)
async
:
false
,
// <= synchronous (POSS alternative: cb + waiting display)
// our payload: filters...
// our payload: filters...
data
:
DATA
,
data
:
args
.
data
,
contentType
:
'application/json'
,
contentType
:
'application/json'
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
var
header
=
jqXHR
.
getResponseHeader
(
"Content-Type"
)
var
header
=
jqXHR
.
getResponseHeader
(
"Content-Type"
)
...
@@ -61,7 +40,7 @@ var AjaxSync = (function(TYPE, URL, DATA, DT) {
...
@@ -61,7 +40,7 @@ var AjaxSync = (function(TYPE, URL, DATA, DT) {
}
}
else
{
else
{
if
(
TW
.
conf
.
debug
.
logFetchers
)
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"
;
format
=
"json"
;
}
}
Result
=
{
"OK"
:
true
,
"format"
:
format
,
"data"
:
data
};
Result
=
{
"OK"
:
true
,
"format"
:
format
,
"data"
:
data
};
...
@@ -72,7 +51,7 @@ var AjaxSync = (function(TYPE, URL, DATA, DT) {
...
@@ -72,7 +51,7 @@ var AjaxSync = (function(TYPE, URL, DATA, DT) {
}
}
});
});
return
Result
;
return
Result
;
}
).
index
();
}
// === [ what to do at start ] === //
// === [ what to do at start ] === //
...
@@ -232,7 +211,7 @@ function syncRemoteGraphData () {
...
@@ -232,7 +211,7 @@ function syncRemoteGraphData () {
mapLabel
=
'"'
+
elements
.
join
(
'" , "'
)
+
'"'
;
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
// should be a js object with 'nodes' and 'edges' properties
inData
=
bridgeRes
.
data
inData
=
bridgeRes
.
data
...
@@ -270,7 +249,7 @@ function syncRemoteGraphData () {
...
@@ -270,7 +249,7 @@ function syncRemoteGraphData () {
var
infofile
=
TW
.
conf
.
sourceMenu
var
infofile
=
TW
.
conf
.
sourceMenu
if
(
TW
.
conf
.
debug
.
logFetchers
)
console
.
info
(
`attempting to load filemenu
${
infofile
}
`
)
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
)
{
if
(
preRES
[
'OK'
]
&&
preRES
.
data
)
{
console
.
log
(
'initial AjaxSync result preRES'
,
preRES
)
console
.
log
(
'initial AjaxSync result preRES'
,
preRES
)
...
@@ -344,7 +323,7 @@ function syncRemoteGraphData () {
...
@@ -344,7 +323,7 @@ function syncRemoteGraphData () {
console
.
error
(
`No specified input and neither db.json nor TW.conf.sourceFile
${
TW
.
conf
.
sourceFile
}
are present`
)
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"
]
inData
=
finalRes
[
"data"
]
inFormat
=
finalRes
[
"format"
]
inFormat
=
finalRes
[
"format"
]
...
...
This diff is collapsed.
Click to expand it.
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