$("#search_histogram").html("Searching for matching twitter data...")
varargs={
// query is an array of str
"q":the_query,
// the_queries is an array of str
"q":the_queries,
"since":1989,
"until":2013
}
vardocs_years=[];
$("#search_histogram")
.html('<p class="micromessage">Waiting for histogram data</p>')
$.ajax({
type:"GET",
...
...
@@ -91,6 +43,9 @@ function search_proposed_terms_and_draw( the_query ) {
// ES aggs response, for example
// data = {"took":91,"total":121673,"aggs":{"publicationCount":{"buckets":[{"key":1989,"doc_count":880},{"key":1990,"doc_count":1088},...,{"key":2012,"doc_count":9543},{"key":2013,"doc_count":8832}]}},"hits":{"total":121673,"max_score":0,"hits":[]}}
// console.log(">> incoming api data <<")
// console.log(data)
if(data.total==0){
returnfalse;
}
...
...
@@ -102,44 +57,65 @@ function search_proposed_terms_and_draw( the_query ) {
// query : IF in the Map -> GO to ISC-API (search and draw it)
varselectedLabels=[];
for(iinselectedNodeIds){
varthisId=selectedNodeIds[i]
if(TW.Nodes[thisId]!=null){
selectedLabels.push(TW.Nodes[thisId].label)
}
else{
// activate save suggestion button
// (if subchain was in no autocomplete term, it's already on)
$('#savesuggestion').prop('disabled',false);
// save_suggestions
$("#crowdsourcing_answer").html("<p>This topic (<i>\""+query+"\"</i> isn't in the maps. You can click the grey button to propose it as a suggestion.</p>");
// (if subchain was in no autocomplete term, it's already on)
$('#savesuggestion').prop('disabled',false);
// save_suggestions
$("#crowdsourcing_answer").html("<p>The topic <i>\""+e.q+"\"</i> is not in the map.</p> <p>(You can click the grey <span class=\"glyphicon glyphicon-save\"></span> button to propose it as a suggestion.)</p>");
// $("#searchinput").val() = query ;
}
});
$("#savesuggestion").click(function(){
varquery=$("#proposed_terms").val()
varquery=$("#searchinput").val()
if(typeofquery!="string"||!query.length){
query=TW.lastQuery;
}
query=$.trim(query.toLowerCase());
save_suggestions(query);
})
...
...
@@ -193,6 +210,14 @@ function save_suggestions(term) {
"date":(newDate()).toISOString(),
"geo":"ip and geoloc"
}
// sqlite columns in table 'terms'
// 0|source|CHAR(250)|0||0
// 1|suggestion|CHAR(250)|0||0
// 2|time|CHAR(30)|0||0
// 3|space|CHAR(100)|0||0
// 4|new|INTEGER|0||0
// console.log( "SAVE INFO:" + info )
$.ajax({
type:"POST",
...
...
@@ -213,7 +238,7 @@ function save_suggestions(term) {
// reset state after 3 secs
setTimeout(function(){
clean_crowdsourcingform();
clean_crowdsourcingzone();
// if we want to reset the input value too
// $("#proposed_terms").val('') ;
...
...
@@ -229,7 +254,7 @@ function save_suggestions(term) {
}
functionclean_crowdsourcingform(){
functionclean_crowdsourcingzone(){
$("#crowdsourcing_answer").html('');
$("#saveicon").removeClass("glyphicon-saved");
$("#saveicon").addClass("glyphicon-save");
...
...
@@ -237,7 +262,6 @@ function clean_crowdsourcingform() {
}
// non utilisé si termes depuis map
//~ function get_already_suggested_terms() {
//~ $("#sendcrowds").html("...")
//~ $.ajax({
...
...
@@ -253,7 +277,7 @@ function clean_crowdsourcingform() {