Commit 322bb883 authored by PkSM3's avatar PkSM3

[UPDATE] ajax cascade for ngrams table

parent 83e263f6
...@@ -501,8 +501,6 @@ $("#Save_All").click(function(){ ...@@ -501,8 +501,6 @@ $("#Save_All").click(function(){
}); });
function Main_test( data , initial) { function Main_test( data , initial) {
...@@ -740,14 +738,46 @@ function Main_test( data , initial) { ...@@ -740,14 +738,46 @@ function Main_test( data , initial) {
return "OK" 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") // [ = = = = = = = = = = INIT = = = = = = = = = = ]
$.ajax({ var corpus_id = getIDFromURL( "corpus" )
url: window.location.href+"/ngrams.json", var url1=window.location.origin+"/api/node/"+corpus_id+"/ngrams/group",
success: function(data){ 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 // Building the Score-Selector
var FirstScore = data.scores.initial var FirstScore = ngrams_data.scores.initial
var possible_scores = Object.keys( data.ngrams[0].scores ); 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"; var scores_div = '<br><select style="font-size:25px;" class="span1" id="scores_selector">'+"\n";
scores_div += "\t"+'<option value="'+FirstScore+'">'+FirstScore+'</option>'+"\n" scores_div += "\t"+'<option value="'+FirstScore+'">'+FirstScore+'</option>'+"\n"
for( var i in possible_scores ) { for( var i in possible_scores ) {
...@@ -756,7 +786,7 @@ $.ajax({ ...@@ -756,7 +786,7 @@ $.ajax({
} }
} }
// Initializing the Charts and Table // Initializing the Charts and Table
var result = Main_test( data , FirstScore ) var result = Main_test( ngrams_data , FirstScore )
console.log( result ) console.log( result )
// Listener for onchange Score-Selector // Listener for onchange Score-Selector
...@@ -764,9 +794,8 @@ $.ajax({ ...@@ -764,9 +794,8 @@ $.ajax({
$("#ScoresBox").html(scores_div) $("#ScoresBox").html(scores_div)
$("#scores_selector").on('change', function() { $("#scores_selector").on('change', function() {
console.log( this.value ) console.log( this.value )
var result = Main_test( data , this.value ) var result = Main_test( ngrams_data , this.value )
console.log( result ) console.log( result )
}); });
}
}); });
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment