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
322bb883
Commit
322bb883
authored
Nov 04, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] ajax cascade for ngrams table
parent
83e263f6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
11 deletions
+40
-11
NGrams_dyna_chart_and_table.js
static/js/NGrams_dyna_chart_and_table.js
+40
-11
No files found.
static/js/NGrams_dyna_chart_and_table.js
View file @
322bb883
...
...
@@ -501,8 +501,6 @@ $("#Save_All").click(function(){
});
function
Main_test
(
data
,
initial
)
{
...
...
@@ -740,14 +738,46 @@ function Main_test( data , initial) {
return
"OK"
}
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
];
}
console
.
log
(
window
.
location
.
href
+
"/ngrams.json"
)
$
.
ajax
({
url
:
window
.
location
.
href
+
"/ngrams.json"
,
success
:
function
(
data
){
// [ = = = = = = = = = = INIT = = = = = = = = = = ]
var
corpus_id
=
getIDFromURL
(
"corpus"
)
var
url1
=
window
.
location
.
origin
+
"/api/node/"
+
corpus_id
+
"/ngrams/group"
,
url2
=
window
.
location
.
href
+
"/ngrams.json"
;
var
ngrams_groups
,
ngrams_data
;
$
.
when
(
$
.
ajax
({
type
:
"GET"
,
url
:
url1
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
ngrams_groups
=
data
},
error
:
function
(
exception
)
{
console
.
log
(
"first ajax, exception!: "
+
exception
.
status
)
}
}),
$
.
ajax
({
type
:
"GET"
,
url
:
url2
,
dataType
:
"json"
,
success
:
function
(
data
,
textStatus
,
jqXHR
)
{
ngrams_data
=
data
},
error
:
function
(
exception
)
{
console
.
log
(
"second ajax, exception!: "
+
exception
.
status
)
}
})
).
then
(
function
()
{
// Building the Score-Selector
var
FirstScore
=
data
.
scores
.
initial
var
possible_scores
=
Object
.
keys
(
data
.
ngrams
[
0
].
scores
);
var
FirstScore
=
ngrams_
data
.
scores
.
initial
var
possible_scores
=
Object
.
keys
(
ngrams_
data
.
ngrams
[
0
].
scores
);
var
scores_div
=
'<br><select style="font-size:25px;" class="span1" id="scores_selector">'
+
"
\n
"
;
scores_div
+=
"
\
t"
+
'<option value="'
+
FirstScore
+
'">'
+
FirstScore
+
'</option>'
+
"
\n
"
for
(
var
i
in
possible_scores
)
{
...
...
@@ -756,7 +786,7 @@ $.ajax({
}
}
// Initializing the Charts and Table
var
result
=
Main_test
(
data
,
FirstScore
)
var
result
=
Main_test
(
ngrams_
data
,
FirstScore
)
console
.
log
(
result
)
// Listener for onchange Score-Selector
...
...
@@ -764,9 +794,8 @@ $.ajax({
$
(
"#ScoresBox"
).
html
(
scores_div
)
$
(
"#scores_selector"
).
on
(
'change'
,
function
()
{
console
.
log
(
this
.
value
)
var
result
=
Main_test
(
data
,
this
.
value
)
var
result
=
Main_test
(
ngrams_
data
,
this
.
value
)
console
.
log
(
result
)
});
}
});
\ No newline at end of file
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