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
b067717e
Commit
b067717e
authored
May 02, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs view: duplicates by title
parent
6d095f1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
84 deletions
+40
-84
Docs_dyna_chart_and_table.js
static/js/gargantext/Docs_dyna_chart_and_table.js
+31
-56
titles.html
templates/pages/corpora/titles.html
+9
-28
No files found.
static/js/gargantext/Docs_dyna_chart_and_table.js
View file @
b067717e
...
...
@@ -157,6 +157,7 @@ var MyTable;
var
RecDict
=
{};
var
AjaxRecords
=
[]
var
Garbage
=
{}
var
countByTitles
=
{}
// useful for title duplicates
function
getRecord
(
rec_id
)
{
return
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
originalRecords
[
rec_id
];
...
...
@@ -263,7 +264,7 @@ function ulWriter(rowIndex, record, columns, cellWriter) {
}
function
Main_test
(
Data
,
SearchFilter
)
{
function
Main_test
(
Data
)
{
var
DistributionDict
=
{}
for
(
var
i
in
DistributionDict
)
...
...
@@ -441,7 +442,7 @@ function Main_test( Data , SearchFilter ) {
},
inputs
:
{
// our own search which differentiates title vs abstract queries
queries
:
$
(
'#doubleSearch'
)
queries
:
$
(
'#doubleSearch
, #dupFilter
'
)
},
writers
:
{
_rowWriter
:
ulWriter
...
...
@@ -457,23 +458,20 @@ function Main_test( Data , SearchFilter ) {
$
(
".dynatable-record-count"
).
insertAfter
(
".imadiv"
)
$
(
".dynatable-pagination-links"
).
insertAfter
(
".imadiv"
)
// make filter checkboxes appear in the right place (ie after search box)
$
(
"#filter_search"
).
html
(
$
(
"#filter_search"
).
html
().
replace
(
'selected="selected"'
)
);
$
(
"#"
+
SearchFilter
).
attr
(
"selected"
,
"selected"
)
var
the_content
=
$
(
"#filter_search"
).
html
();
$
(
""
+
the_content
).
insertAfter
(
"#doubleSearch"
)
// binds a custom filter to our 'doubleSearch' via dynatable.queries.functions
// binds a custom filter to our 'doubleSearch' via dynatable.queries.functions
MyTable
.
data
(
'dynatable'
).
queries
.
functions
[
'doubleSearch'
]
=
function
(
record
,
searchString
)
{
// global context
doAbstractsSearch
=
$
(
"#searchAB"
).
is
(
':checked'
)
// NB searchString == $("#doubleSearch").val()
// by default we always decide to search in the title
matchInTexts
=
[
record
.
title
]
// if box is checked we'll also search in the abstracts
if
(
$
(
"#searchAB"
).
is
(
':checked'
)
)
{
if
(
doAbstractsSearch
)
{
if
(
typeof
record
.
hyperdata
.
abstract
!==
'undefined'
)
{
matchInTexts
.
push
(
record
.
hyperdata
.
abstract
)
}
...
...
@@ -492,6 +490,18 @@ function Main_test( Data , SearchFilter ) {
}
return
contains
;
}
MyTable
.
data
(
'dynatable'
).
process
();
// also append another bound filter for duplicates
MyTable
.
data
(
'dynatable'
).
queries
.
functions
[
'dupFilter'
]
=
function
(
record
,
selected
)
{
return
(
selected
==
'filter_all'
)
||
(
countByTitles
[
record
.
title
]
>
1
)
}
// and set this filter's initial status to 'filter_all'
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'dupFilter'
]
=
'filter_all'
MyTable
.
data
(
'dynatable'
).
process
();
MyTable
.
data
(
'dynatable'
).
process
...
...
@@ -510,50 +520,6 @@ function Main_test( Data , SearchFilter ) {
return
"OK"
}
function
SearchFilters
(
elem
)
{
var
MODE
=
elem
.
value
;
if
(
MODE
==
"filter_all"
)
{
var
result
=
Main_test
(
AjaxRecords
,
MODE
)
console
.
log
(
result
)
}
if
(
MODE
==
"filter_dupl-titles"
)
{
var
getDupl_API
=
"/api/nodes/"
+
corpus_id
+
"/children/duplicates?keys=title&limit=9999"
$
.
ajax
({
url
:
getDupl_API
,
success
:
function
(
data
)
{
bisarray
=
data
.
data
for
(
var
i
in
bisarray
)
{
titlebis
=
bisarray
[
i
].
values
BIS_dict
[
titlebis
[
0
]]
=
true
;
}
var
Duplicates
=
[]
for
(
var
r
in
AjaxRecords
)
{
if
(
BIS_dict
[
AjaxRecords
[
r
].
title
]
)
Duplicates
.
push
(
AjaxRecords
[
r
]
)
}
var
result
=
Main_test
(
Duplicates
,
MODE
)
console
.
log
(
result
)
MyTable
.
data
(
'dynatable'
).
sorts
.
clear
();
MyTable
.
data
(
'dynatable'
).
sorts
.
add
(
'title'
,
1
)
// 1=ASCENDING,
MyTable
.
data
(
'dynatable'
).
process
();
}
});
}
}
$
(
"#corpusdisplayer"
).
hide
()
// FIRST portion of code to be EXECUTED:
// (3) Get records and hyperdata for paginator
...
...
@@ -572,11 +538,20 @@ $.ajax({
record
.
date
=
get_node_date
(
record
);
record
.
del
=
false
;
});
// initialize CountByTitle census
for
(
var
i
in
data
.
records
)
{
ourTitle
=
data
.
records
[
i
][
'title'
]
;
if
(
countByTitles
.
hasOwnProperty
(
ourTitle
))
{
countByTitles
[
ourTitle
]
++
;
}
else
{
countByTitles
[
ourTitle
]
=
1
;
}
}
AjaxRecords
=
data
.
records
;
// backup-ing in global variable!
var
result
=
Main_test
(
data
.
records
,
"filter_all"
)
var
result
=
Main_test
(
data
.
records
)
$
(
"#corpusdisplayer"
).
show
()
$
(
"#content_loader"
).
remove
()
...
...
templates/pages/corpora/titles.html
View file @
b067717e
...
...
@@ -66,6 +66,15 @@
<div
class=
"pull-left"
style=
"margin-top:1.85em; font-size: 16px;"
>
Search:
<input
type=
"search"
id=
"doubleSearch"
/>
<span
style=
"font-size:70%;"
>
<!-- Used by the #doubleSearch associated function -->
<input
title=
"Search in Titles"
id=
"searchTI"
name=
"searchTI"
type=
"checkbox"
checked
onclick=
"return false"
>
TI
<input
title=
"Search in Abstracts"
id=
"searchAB"
name=
"searchAB"
type=
"checkbox"
>
AB
</span>
<select
id=
"dupFilter"
name=
"dupFilter"
>
<option
value=
"filter_all"
>
All
</option>
<option
value=
"filter_dupl"
>
Duplicates by Title
</option>
</select>
</div>
...
...
@@ -83,32 +92,6 @@
</div>
</div>
<div
id=
"filter_search"
style=
"visibility:hidden"
>
<span
style=
"font-size:70%;"
>
<!-- Used by the #doubleSearch associated function -->
<input
title=
"Search in Titles"
id=
"searchTI"
name=
"searchTI"
type=
"checkbox"
checked
onclick=
"return false"
>
TI
<input
title=
"Search in Abstracts"
id=
"searchAB"
name=
"searchAB"
type=
"checkbox"
>
AB
</span>
<select
id=
"example-single-optgroups"
onchange=
"SearchFilters(this);"
>
<!-- <optgroup label=""> -->
<option
id=
"filter_all"
value=
"filter_all"
>
All
</option>
<!-- <option id="filter_title" value="filter_title">Title</option> -->
<!-- <option id="filter_date" value="filter_date">Date</option> -->
<!-- </optgroup> -->
<!-- <optgroup label="Duplicates"> -->
<!-- <option value="filter_doi">By DOI</option> -->
<!-- TODO
<option id="filter_dupl-titles" value="filter_dupl-titles">Duplicates by Title</option> -->
<!-- </optgroup> -->
</select>
</div>
</div>
<script
type=
"text/javascript"
src=
"{% static "
js
/
jquery
/
jquery
.
min
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
bootstrap
/
bootstrap
.
min
.
js
"
%}"
></script>
<!-- here goes import script js/bootstrap/bootstrap-multiselect.js, mais ca marche pas-->
...
...
@@ -117,6 +100,4 @@
<!-- custom-lib for dynatable.js and dc.js -->
<script
type=
"text/javascript"
src=
"{% static "
js
/
gargantext
/
Docs_dyna_chart_and_table
.
js
"
%}"
></script>
{% endblock %}
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