Commit 59e64601 authored by sim's avatar sim

[FIX] Unkludge the kludgy kludge

parent 791c196e
...@@ -73,7 +73,8 @@ from rest_framework.views import APIView ...@@ -73,7 +73,8 @@ from rest_framework.views import APIView
from gargantext.util.json import json_encoder from gargantext.util.json import json_encoder
def JsonHttpResponse(data, status=200): def JsonHttpResponse(data, status=200):
return HttpResponse( return HttpResponse(
content = json_encoder.encode(data), content = data.encode('utf-8') if isinstance(data, str) else \
json_encoder.encode(data),
content_type = 'application/json; charset=utf-8', content_type = 'application/json; charset=utf-8',
status = status status = status
) )
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<center id="corpus" class="help"> <center id="corpus" class="help">
<a data-toggle="modal" href="#addcorpus" > <a data-toggle="modal" href="#addcorpus" >
<button <button
type="button" type="button"
...@@ -532,7 +532,7 @@ ...@@ -532,7 +532,7 @@
$("#submit_thing").html("Process a {{ query_size }} sample!") $("#submit_thing").html("Process a {{ query_size }} sample!")
thequeries = data thequeries = data
var N=0,k=0; var N=0;
for(var i in thequeries) N += thequeries[i].count for(var i in thequeries) N += thequeries[i].count
if( N>0) { if( N>0) {
...@@ -571,12 +571,11 @@ ...@@ -571,12 +571,11 @@
$("#submit_thing").html("Process a {{ query_size }} sample!") $("#submit_thing").html("Process a {{ query_size }} sample!")
thequeries = data thequeries = data
var N=data.length,k=0; var N = data.total;
// for(var i in thequeries) N += thequeries[i].count
if( N>1) { if (N > 0) {
var total = JSON.parse(data).total console.log("N: "+N)
console.log("N: "+total) $("#theresults").html("<i> <b>"+pubmedquery+"</b>: "+N+" publications.</i><br>")
$("#theresults").html("<i> <b>"+pubmedquery+"</b>: "+total+" publications.</i><br>")
$('#submit_thing').prop('disabled', false); $('#submit_thing').prop('disabled', false);
} else { } else {
$("#theresults").html("<i> <b>"+data[0]+"</b></i><br>") $("#theresults").html("<i> <b>"+data[0]+"</b></i><br>")
...@@ -661,7 +660,7 @@ ...@@ -661,7 +660,7 @@
console.log(data) console.log(data)
console.log("SUCCESS") console.log("SUCCESS")
console.log("enabling "+"#"+value.id) console.log("enabling "+"#"+value.id)
// $("#"+value.id).attr('onclick','getGlobalResults(this);'); // $("#"+value.id).attr('onclick','getGlobalResults(this);');
$("#submit_thing").prop('disabled' , false) $("#submit_thing").prop('disabled' , false)
//$("#submit_thing").html("Process a {{ query_size }} sample!") //$("#submit_thing").html("Process a {{ query_size }} sample!")
...@@ -721,7 +720,7 @@ ...@@ -721,7 +720,7 @@
console.log(data) console.log(data)
console.log("SUCCESS") console.log("SUCCESS")
console.log("enabling "+"#"+value.id) console.log("enabling "+"#"+value.id)
// $("#"+value.id).attr('onclick','getGlobalResults(this);'); // $("#"+value.id).attr('onclick','getGlobalResults(this);');
$("#submit_thing").prop('disabled' , false) $("#submit_thing").prop('disabled' , false)
//$("#submit_thing").html("Process a {{ query_size }} sample!") //$("#submit_thing").html("Process a {{ query_size }} sample!")
...@@ -781,7 +780,7 @@ ...@@ -781,7 +780,7 @@
console.log(data) console.log(data)
console.log("SUCCESS") console.log("SUCCESS")
console.log("enabling "+"#"+value.id) console.log("enabling "+"#"+value.id)
// $("#"+value.id).attr('onclick','getGlobalResults(this);'); // $("#"+value.id).attr('onclick','getGlobalResults(this);');
$("#submit_thing").prop('disabled' , false) $("#submit_thing").prop('disabled' , false)
//$("#submit_thing").html("Process a {{ query_size }} sample!") //$("#submit_thing").html("Process a {{ query_size }} sample!")
...@@ -876,12 +875,12 @@ ...@@ -876,12 +875,12 @@
console.log("selected:", selectedId); console.log("selected:", selectedId);
// by typeID: 3 = PUBMED, 8 = ISTEX, 9 = CERN // by typeID: 3 = PUBMED, 8 = ISTEX, 9 = CERN
if ( selectedId == "3" if ( selectedId == "3"
|| selectedId == "8" || selectedId == "8"
|| selectedId == "9" || selectedId == "9"
|| selectedId == "10" || selectedId == "10"
|| selectedId == "11" || selectedId == "11"
|| selectedId == "12" || selectedId == "12"
) { ) {
console.log("show the button for: " + selectedId) console.log("show the button for: " + selectedId)
$("#div-fileornot").css("visibility", "visible"); $("#div-fileornot").css("visibility", "visible");
...@@ -1019,16 +1018,16 @@ ...@@ -1019,16 +1018,16 @@
function saveMultivac(query, N){ function saveMultivac(query, N){
console.log("In Multivac") console.log("In Multivac")
if(!query || query=="") return; if(!query || query=="") return;
console.log(query) console.log(query)
//var origQuery = query //var origQuery = query
var data = { "query" : query , "N": N }; var data = { "query" : query , "N": N };
// Replace all the slashes // Replace all the slashes
var projectid = window.location.href.split("projects")[1].replace(/\//g, '') var projectid = window.location.href.split("projects")[1].replace(/\//g, '')
console.log(data) console.log(data)
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
...@@ -1066,16 +1065,16 @@ ...@@ -1066,16 +1065,16 @@
function save(query, N, urlGarg){ function save(query, N, urlGarg){
console.log("In Gargantext") console.log("In Gargantext")
if(!query || query=="") return; if(!query || query=="") return;
console.log(query) console.log(query)
//var origQuery = query //var origQuery = query
var data = { "query" : query , "N": N }; var data = { "query" : query , "N": N };
// Replace all the slashes // Replace all the slashes
var projectid = window.location.href.split("projects")[1].replace(/\//g, '') var projectid = window.location.href.split("projects")[1].replace(/\//g, '')
console.log(data) console.log(data)
$.ajax({ $.ajax({
dataType: 'json', dataType: 'json',
......
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