Commit e91c3ca8 authored by delanoe's avatar delanoe

[CSS] Icones alignement + bar progression

parent 14ce4cff
...@@ -79,32 +79,37 @@ ...@@ -79,32 +79,37 @@
<div id="project_{{project.id}}" class="row"> <div id="project_{{project.id}}" class="row">
<h3> <h3>
<a <div class="col-md-5 content">
href="/projects/{{ project.id }}"> <a
<span class="glyphicon glyphicon-book" aria-hidden="true"></span> href="/projects/{{ project.id }}">
{{ project.name }} <span class="glyphicon glyphicon-book" aria-hidden="true"></span>
</a> {{ project.name }}
<a href="/projects/{{project.id}}" > </a>
<button type="button" class="btn btn-default" aria-label="Left Align"> </div>
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
</button> <div class="col-md-3 content">
<a href="/projects/{{project.id}}" >
</a> <button type="button" class="btn btn-default" aria-label="Left Align">
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
<button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom" </button>
data-content=" <ul>
<!-- </a>
<li>Rename</li>
--!> <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom"
<li onclick=&quot; data-content=" <ul>
garganrest.nodes.delete({{project.id}}, function(){$('#project_'+{{project.id}}).remove()}); <!--
$(this).parent().parent().remove(); <li>Rename</li>
&quot;><a href=&quot;#&quot;>Delete</a></li> --!>
</ul> <li onclick=&quot;
"> garganrest.nodes.delete({{project.id}}, function(){$('#project_'+{{project.id}}).remove()});
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> $(this).parent().parent().remove();
</button> &quot;><a href=&quot;#&quot;>Delete</a>
</li> </li>
</ul>
">
<span class="glyphicon glyphicon-trash pull-right" aria-hidden="true"></span>
</button>
</div>
{% if common_users %} {% if common_users %}
<!-- <a style="cursor:pointer;"><img class="share_button" data-id="{{ project.id }}" title="Share it!" width="20px" src="{% static "img/share.png" %}"></img></a> --!> <!-- <a style="cursor:pointer;"><img class="share_button" data-id="{{ project.id }}" title="Share it!" width="20px" src="{% static "img/share.png" %}"></img></a> --!>
{% endif %} {% endif %}
......
...@@ -73,545 +73,510 @@ ...@@ -73,545 +73,510 @@
{% if list_corpora %} {% if list_corpora %}
{% for key, corpora in list_corpora.items %} {% for key, corpora in list_corpora.items %}
<h2> <h2>
<span class="glyphicon glyphicon-cd" aria-hidden="true"></span> <div class="row">
{{ key }} <span class="glyphicon glyphicon-cd" aria-hidden="true"></span>
{{ key }}
</h2> </h2>
{% for corpus in corpora %} {% for corpus in corpora %}
<div id="corpus_{{corpus.id}}"> <div id="corpus_{{corpus.id}}">
{% ifequal corpus.processing 1 %} <div class="row">
{{corpus.name}}: <h4>
<img width="20px" src="{% static "js/libs/img2/loading-bar.gif" %}"> <div class="col-md-5 content">
Processing, drink a cup of tea, and refresh the page :) <a href="/projects/{{project.id}}/corpora/{{corpus.id}}">
{% else %} <span class="glyphicon glyphicon-file" aria-hidden="true"></span>
<h4> {{corpus.name}}, {{ corpus.count }} documents {{ corpus.status_message }}
<a href="/projects/{{project.id}}/corpora/{{corpus.id}}"> </a>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span> </div>
{{corpus.name}}, {{ corpus.count }} documents {{ corpus.status_message }} <div class="col-md-2 content">
</a> <a href="/projects/{{project.id}}/corpora/{{corpus.id}}">
<a href="/projects/{{project.id}}/corpora/{{corpus.id}}"> <button type="button" class="btn btn-default" aria-label="Left Align">
<button type="button" class="btn btn-default" aria-label="Left Align"> <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> </button>
</button>
</a>
</a> <button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom"
data-content="
{% endifequal %} <ul>
<button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom" <li
data-content=" onclick=&quot;
<ul> garganrest.nodes.delete({{corpus.id}}, function(){$('#corpus_'+{{corpus.id}}).remove()});
<!-- $(this).parent().parent().remove();
<li>Rename</li> &quot;>
<li>Add new documents</li> <a href=&quot;#&quot;>Delete this</a>
--!> </li>
<li </ul>
onclick=&quot; ">
garganrest.nodes.delete({{corpus.id}}, function(){$('#corpus_'+{{corpus.id}}).remove()}); <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
$(this).parent().parent().remove(); </button>
&quot;> </div>
<a href=&quot;#&quot;>I want to delete this</a>
</li>
</ul>
">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</button>
</h4>
<p>
<div class="progress">
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "parsing" %}
<div class=" progress-bar progress-bar-striped
{% if state.complete %}
progress-bar-success
{% else %}
active
{% endif %}
"
role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 50%">
<span>
Parsing
{% if state.complete %}
Complete
{% else %}
Processing
{% endif %}
</span>
</div>
{% endifequal %}
{% ifequal state.action "ngrams_extraction" %}
<div class="progress-bar progress-bar-striped
{% if state.complete %}
progress-bar-success
{% else %}
active
{% endif %}
"
role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 50%">
<span>
Ngrams extraction
{% if state.complete %}
Complete
{% else %}
Processing
{% endif %}
</span>
</div>
{% endifequal %}
{% endfor %}
</div>
</p>
</div>
{% endfor %}
{% endfor %}
{% endif %}
{% if list_corporax %}
<div class="col-md-4">
<h3>
<a href="/projects/{{project.id}}/corpora/{{corpus.id}}">{{corpus.name}}</a>
</h3>
<h4>
{{ corpus.count }} documents
</h4>
<h5>Activity:</h5>
<div class="chart" data-percent="73">73%</div>
</div>
{% endif %}
{% if whitelists %}
<h2>Lists of Ngrams</h2>
<h3>White Lists</h3>
<ul>
{% for list in whitelists %}
<li>{{list.name }}</li>
{% endfor %}
</ul>
{% endif %}
{% if blacklists %} <div class="col-md-5 content">
<h3>Black Lists</h3> {% for state in corpus.hyperdata.statuses %}
<ul> {% ifequal state.action "ngrams_extraction" %}
{% for list in blacklists %} {% if state.complete %}
<li>{{list.name}}</li> <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
{% else %}
{% if state.error %}
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
{% else %}
<div class="progress">
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "parsing" %}
<div class=" progress-bar progress-bar-striped
{% if state.complete %}
progress-bar-success
{% else %}
active
{% endif %}
"
role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 50%">
<span>
Parsing
{% if state.complete %}
Complete
{% else %}
Processing
{% endif %}
</span>
</div>
{% endifequal %}
{% ifequal state.action "ngrams_extraction" %}
<div class="progress-bar progress-bar-striped
{% if state.complete %}
progress-bar-success
{% else %}
active
{% endif %}
"
role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 50%">
<span>
Ngrams extraction
{% if state.complete %}
Complete
{% else %}
Processing
{% endif %}
</span>
</div>
{% endifequal %}
{% endfor %}
</div>
{% endif %}
{% endif %}
{% endifequal %}
{% endfor %}
</div>
</h4>
</div>
</div>
{% endfor %}
{% endfor %} {% endfor %}
</ul>
{% endif %} {% endif %}
{% if cooclists %}
<h2>Results (graphs)</h2>
<h3>Cooccurrences Lists</h2>
<ul>
{% for list in cooclists %}
<li> {{list.name }}
</ul>
{% endfor %}
{% endif %}
</div>
<!-- Modal --> <!-- Modal -->
<div class="modal fade" id="stack1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal fade" id="stack1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Query to PubMed</h3> <h3>Query to PubMed</h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>One fine body…</p> <p>One fine body…</p>
<input id="daquery" type="text" class="input-lg" data-tabindex="2"> <input id="daquery" type="text" class="input-lg" data-tabindex="2">
<a onclick="getGlobalResults();" class="btn">Scan</a> <a onclick="getGlobalResults();" class="btn">Scan</a>
<div id="results"></div> <div id="results"></div>
</div> </div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button onclick="doTheQuery();" disabled id="id_thebutton" type="button" class="btn btn-primary">Explore a sample!</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal -->
<div class="modal fade" id="addcorpus" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Add a Corpus</h3>
</div>
<div class="modal-body">
<form id="id_form" enctype="multipart/form-data" action="/projects/{{project.id}}/" method="post">
{% csrf_token %}
<table cellpadding="5">
{% for field in form %}
<tr>
<th>{{field.label_tag}}</th>
<td>
{{ field.errors }}
{{ field }}
{% if field.name == 'name' %}
<span onclick="getGlobalResults(this);" id="scanpubmed"></span>
<div id="theresults"></div>
{% endif %}
</td>
</tr>
{% endfor %}
<tr>
<th></th>
<td>
<div id="pubmedcrawl" style="visibility: hidden;">
Do you have a file already? &nbsp;
<input type="radio" id="file_yes" name="file1" onclick="FileOrNotFile(this.value);" class="file1" value="true" checked>Yes </input>
<input type="radio" id="file_no" name="file1" onclick="FileOrNotFile(this.value);" class="file1" value="false">No </input>
</div>
</td>
</tr>
</table>
</form>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <!-- <div id="pubmedcrawl" align="right" style="visibility: hidden;"><a data-toggle="modal" href="#stack1">&#10142; Query directly in PubMed</a></div> -->
<button onclick="doTheQuery();" disabled id="id_thebutton" type="button" class="btn btn-primary">Explore a sample!</button> <button type="button" class="btn btn-default" data-dismiss="modal">
</div> <span class="glyphicon glyphicon-remove" aria-hidden="true" ></span>
</div><!-- /.modal-content --> Close
</div><!-- /.modal-dialog --> </button>
</div><!-- /.modal --> <button onclick='bringDaNoise();' id="submit_thing" disabled class="btn btn-primary" >
<span class="glyphicon glyphicon-ok" aria-hidden="true" ></span>
<!-- Modal --> Process this!
<div class="modal fade" id="addcorpus" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true"> </button><span id="simpleloader"></span>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Add a Corpus</h3>
</div> </div>
<div class="modal-body"> </div>
<form id="id_form" enctype="multipart/form-data" action="/projects/{{project.id}}/" method="post"> </div><!-- /.modal-content -->
{% csrf_token %} </div><!-- /.modal-dialog -->
<table cellpadding="5"> </div><!-- /.modal -->
{% for field in form %} <script type="text/javascript" src="{% static "js/jquery/1.11.2/jquery-ui.js" %}"></script>
<tr> <script type="text/javascript">
<th>{{field.label_tag}}</th> function getCookie(name) {
<td> var cookieValue = null;
{{ field.errors }} if (document.cookie && document.cookie != '') {
{{ field }} var cookies = document.cookie.split(';');
{% if field.name == 'name' %} for (var i = 0; i < cookies.length; i++) {
<span onclick="getGlobalResults(this);" id="scanpubmed"></span> var cookie = jQuery.trim(cookies[i]);
<div id="theresults"></div> // Does this cookie string begin with the name we want?
{% endif %} if (cookie.substring(0, name.length + 1) == (name + '=')) {
</td> cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
</tr> break;
{% endfor %}
<tr>
<th></th>
<td>
<div id="pubmedcrawl" style="visibility: hidden;">
Do you have a file already? &nbsp;
<input type="radio" id="file_yes" name="file1" onclick="FileOrNotFile(this.value);" class="file1" value="true" checked>Yes </input>
<input type="radio" id="file_no" name="file1" onclick="FileOrNotFile(this.value);" class="file1" value="false">No </input>
</div>
</td>
</tr>
</table>
</form>
<div class="modal-footer">
<!-- <div id="pubmedcrawl" align="right" style="visibility: hidden;"><a data-toggle="modal" href="#stack1">&#10142; Query directly in PubMed</a></div> -->
<button type="button" class="btn btn-default" data-dismiss="modal">
<span class="glyphicon glyphicon-remove" aria-hidden="true" ></span>
Close
</button>
<button onclick='bringDaNoise();' id="submit_thing" disabled class="btn btn-primary" >
<span class="glyphicon glyphicon-ok" aria-hidden="true" ></span>
Process this!
</button><span id="simpleloader"></span>
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script type="text/javascript" src="{% static "js/jquery/1.11.2/jquery-ui.js" %}"></script>
<script type="text/javascript">
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
} }
} }
return cookieValue;
} }
return cookieValue;
}
var thequeries = [] ;
// load the template's value for N scan size
var querySize = parseInt({{query_size}}) ;
// TODO if is_admin
function doTheQuery() {
if ( $('#submit_thing').prop('disabled') ) return;
console.log("in doTheQuery:");
var origQuery = $("#id_name").val()
var pubmedifiedQuery = {
query : JSON.stringify(thequeries) ,
string: origQuery ,
N : querySize
} ;
console.log(pubmedifiedQuery)
var projectid = window.location.href.split("projects")[1].replace(/\//g, '')//replace all the slashes
$.ajax({
// contentType: "application/json",
url: window.location.origin+"/scrapers/pubmed/save/"+projectid,
data: pubmedifiedQuery,
type: 'POST',
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
},
success: function(data) {
console.log("in doTheQuery() Ajax.Success:")
console.log(data)
setTimeout(
function() {
location.reload();
}, 3000);
},
error: function(result) {
console.log("in doTheQuery(). Data not found");
}
});
}
var thequeries = [] ; function bringDaNoise() {
var theresults = $("#theresults").html()
// load the template's value for N scan size if( theresults && theresults.search("No results")==-1 ) {
var querySize = parseInt({{query_size}}) ; console.log("we've in dynamic mode")
$("#simpleloader").html('<img width="30px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img>')
// TODO if is_admin $("#submit_thing").prop('onclick',null);
function doTheQuery() {
if ( $('#submit_thing').prop('disabled') ) return;
console.log("in doTheQuery:");
var origQuery = $("#id_name").val()
var pubmedifiedQuery = {
query : JSON.stringify(thequeries) ,
string: origQuery ,
N : querySize
} ;
console.log(pubmedifiedQuery)
var projectid = window.location.href.split("projects")[1].replace(/\//g, '')//replace all the slashes var theType = $("#id_type option:selected").html();
console.log("consoling the type: ")
console.log(theType)
if(theType=="Pubmed (XML format)") doTheQuery();
if(theType=="ISTex") {
var origQuery = $("#id_name").val()
console.log("printing the results:")
console.log(origQuery)
testISTEX(origQuery.replace(" ","+"), querySize)
}
}
else {
console.log("we dont have nothing inside results div")
if ( $("#id_file").is(':visible') ) {
console.log("we're in upload-file mode")
var namefield = $("#id_name").val()!=""
var typefield = $("#id_type").val()!=""
var filefield = $("#id_file").val()!=""
if( namefield && typefield && filefield ) {
$("#simpleloader").html('<img width="30px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img>')
$("#submit_thing").prop('onclick',null);
$( "#id_form" ).submit();
}
}
}
}
function getGlobalResults(value){
console.log("in getGlobalResults()")
// AJAX to django
var pubmedquery = $("#id_name").val()
// var Npubs = $("#id_N").val();
if(pubmedquery=="") return;
var formData = {query:pubmedquery , N:querySize}
$("#theresults").html('<img width="30px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img>')
console.log("disabling "+"#"+value.id)
$("#"+value.id).prop('onclick',null);
var theType = $("#id_type option:selected").html();
if(theType=="Pubmed (XML format)") {
$.ajax({ $.ajax({
// contentType: "application/json", // contentType: "application/json",
url: window.location.origin+"/scrapers/pubmed/save/"+projectid, url: window.location.origin+"/scrapers/pubmed/query",
data: pubmedifiedQuery, data: formData,
type: 'POST', type: 'POST',
beforeSend: function(xhr) { beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken")); xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
}, },
success: function(data) { success: function(data) {
console.log("in doTheQuery() Ajax.Success:") console.log("SUCCESS")
console.log("in getGlobalResults")
console.log(data) console.log(data)
setTimeout( console.log("enabling "+"#"+value.id)
function() { $("#"+value.id).attr('onclick','getGlobalResults(this);');
location.reload(); // $("#submit_thing").prop('disabled' , false)
}, 3000); $("#submit_thing").html("Process a {{ query_size }} sample!")
},
error: function(result) { thequeries = data
console.log("in doTheQuery(). Data not found"); var N=0,k=0;
}
}); for(var i in thequeries) N += thequeries[i].count
} if( N>0) {
$("#theresults").html("<i> <b>"+pubmedquery+"</b>: "+N+" publications in the last 5 years</i><br>")
function bringDaNoise() { $('#submit_thing').prop('disabled', false);
var theresults = $("#theresults").html() } else {
if( theresults && theresults.search("No results")==-1 ) { $("#theresults").html("<i> <b>"+pubmedquery+"</b>: No results!.</i><br>")
console.log("we've in dynamic mode") if(data[0]==false)
$("#simpleloader").html('<img width="30px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img>')
$("#submit_thing").prop('onclick',null);
var theType = $("#id_type option:selected").html();
console.log("consoling the type: ")
console.log(theType)
if(theType=="Pubmed (XML format)") doTheQuery();
if(theType=="ISTex") {
var origQuery = $("#id_name").val()
console.log("printing the results:")
console.log(origQuery)
testISTEX(origQuery.replace(" ","+"), querySize)
}
}
else {
console.log("we dont have nothing inside results div")
if ( $("#id_file").is(':visible') ) {
console.log("we're in upload-file mode")
var namefield = $("#id_name").val()!=""
var typefield = $("#id_type").val()!=""
var filefield = $("#id_file").val()!=""
if( namefield && typefield && filefield ) {
$("#simpleloader").html('<img width="30px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img>')
$("#submit_thing").prop('onclick',null);
$( "#id_form" ).submit();
}
}
}
}
function getGlobalResults(value){
console.log("in getGlobalResults()")
// AJAX to django
var pubmedquery = $("#id_name").val()
// var Npubs = $("#id_N").val();
if(pubmedquery=="") return;
var formData = {query:pubmedquery , N:querySize}
$("#theresults").html('<img width="30px" src="{% static "js/libs/img2/loading-bar.gif" %}"></img>')
console.log("disabling "+"#"+value.id)
$("#"+value.id).prop('onclick',null);
var theType = $("#id_type option:selected").html();
if(theType=="Pubmed (XML format)") {
$.ajax({
// contentType: "application/json",
url: window.location.origin+"/scrapers/pubmed/query",
data: formData,
type: 'POST',
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
},
success: function(data) {
console.log("SUCCESS")
console.log("in getGlobalResults")
console.log(data)
console.log("enabling "+"#"+value.id)
$("#"+value.id).attr('onclick','getGlobalResults(this);');
// $("#submit_thing").prop('disabled' , false)
$("#submit_thing").html("Process a {{ query_size }} sample!")
thequeries = data
var N=0,k=0;
for(var i in thequeries) N += thequeries[i].count
if( N>0) {
$("#theresults").html("<i> <b>"+pubmedquery+"</b>: "+N+" publications in the last 5 years</i><br>")
$('#submit_thing').prop('disabled', false);
} else {
$("#theresults").html("<i> <b>"+pubmedquery+"</b>: No results!.</i><br>")
if(data[0]==false)
$("#theresults").html("Pubmed connection error!</i><br>")
$('#submit_thing').prop('disabled', true);
}
},
error: function(result) {
$("#theresults").html("Pubmed connection error!</i><br>") $("#theresults").html("Pubmed connection error!</i><br>")
$('#submit_thing').prop('disabled', true); $('#submit_thing').prop('disabled', true);
} }
});
}
if(theType=="ISTex") {
console.log(window.location.origin+"scrapers/istex/query")
$.ajax({
// contentType: "application/json",
url: window.location.origin+"/scrapers/istex/query",
data: formData,
type: 'POST',
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
},
success: function(data) {
console.log("in getGlobalResults: Ajax(ISTex)")
console.log("enabling "+"#"+value.id)
$("#"+value.id).attr('onclick','getGlobalResults(this);');
// $("#submit_thing").prop('disabled' , false)
$("#submit_thing").html("Process a {{ query_size }} sample!")
thequeries = data
var N=data.length,k=0;
// for(var i in thequeries) N += thequeries[i].count
if( N>1) {
var total = JSON.parse(data).total
console.log("N: "+total)
$("#theresults").html("<i> <b>"+pubmedquery+"</b>: "+total+" publications.</i><br>")
$('#submit_thing').prop('disabled', false);
} else {
$("#theresults").html("<i> <b>"+data[0]+"</b></i><br>")
$('#submit_thing').prop('disabled', true);
}
},
error: function(result) {
console.log("Data not found");
}
});
}
}
// CSS events for selecting one Radio-Input
function FileOrNotFile( value ) {
var showfile = JSON.parse(value)
var theType = $("#id_type option:selected").html();
// @upload-file events
if (showfile) {
console.log("You've clicked the YES")
$("#id_file").show()
$('label[for=id_file]').show();
$("#id_name").attr("placeholder", "");
$("#scanpubmed").html("")
$("#theresults").html("")
$('#submit_thing').prop('disabled', false);
$( "#id_name" ).on('input',null);
$("#submit_thing").html('<span class="glyphicon glyphicon-ok" aria-hidden="true" ></span> Process this!')
}
// @dynamic-query events
else {
console.log("You've clicked the NO")
$("#id_file").hide()
$('label[for=id_file]').hide();
$("#id_name").attr("placeholder", " [ Enter your query here ] ");
$("#id_name").focus();
$("#scanpubmed").html('<a class="btn btn-primary">Scan</a>')//+'Get: <input id="id_N" size="2" type="text"></input>')
$("#theresults").html("")
$("#submit_thing").prop('disabled' , true)
$( "#id_name" ).on('input',function(e){
console.log($(this).val())
if(theType=="Pubmed (XML format)")
testPUBMED( $(this).val() )
});
}
}
//CSS events for changing the Select element
function CustomForSelect( selected ) {
// show Radio-Inputs and trigger FileOrNotFile>@upload-file events
selected = selected.toLowerCase()
var is_pubmed = (selected.indexOf('pubmed') != -1);
var is_istex = (selected.indexOf('istex') != -1);
if (is_pubmed || is_istex) {
// if(selected=="pubmed") {
console.log("show the button for: " + selected)
$("#pubmedcrawl").css("visibility", "visible");
$("#pubmedcrawl").show();
$("#file_yes").click();
$("#submit_thing").html("Process this!")
}
// hide Radio-Inputs and trigger @upload-file events
else {
console.log("hide the button")
$("#pubmedcrawl").css("visibility", "hidden");
$("#id_file").show()
$('label[for=id_file]').show();
FileOrNotFile( "true" )
}
}
var LastData = []
function NSuggest_CreateData(q, data) {
console.log("in the new NSuggest_CreateData:")
LastData = data;
// console.log(LastData)
console.log("adding class ui-widget")
$("#id_name").removeClass( "ui-widget" ).addClass( "ui-widget" )
$( "#id_name" ).autocomplete({
source: LastData
});
return data;
}
function testPUBMED( query ) { },
LastData = [] error: function(result) {
if(!query || query=="") return; $("#theresults").html("Pubmed connection error!</i><br>")
var pubmedquery = encodeURIComponent(query) $('#submit_thing').prop('disabled', true);
$.ajax({ }
type: 'GET',
url: "http://www.ncbi.nlm.nih.gov/portal/utils/autocomp.fcgi?dict=pm_related_queries_2&q="+pubmedquery,
// data:"db="+db+"&query="+query,
contentType: "application/json",
dataType: 'jsonp'
}); });
return false;
} }
function testISTEX(query,N) { if(theType=="ISTex") {
console.log("in testISTEX:"); console.log(window.location.origin+"scrapers/istex/query")
if(!query || query=="") return;
var origQuery = query
var postQuery = { query : query , N: N }
var projectid = window.location.href.split("projects")[1].replace(/\//g, '')//replace all the slashes
$.ajax({ $.ajax({
// contentType: "application/json", // contentType: "application/json",
url: window.location.origin+"/scrapers/istex/save/"+projectid, url: window.location.origin+"/scrapers/istex/query",
data: postQuery, data: formData,
type: 'POST', type: 'POST',
beforeSend: function(xhr) { beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken")); xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
}, },
success: function(data) { success: function(data) {
console.log("ajax_success: in testISTEX()") console.log("in getGlobalResults: Ajax(ISTex)")
console.log(data) console.log("enabling "+"#"+value.id)
setTimeout( $("#"+value.id).attr('onclick','getGlobalResults(this);');
function() { // $("#submit_thing").prop('disabled' , false)
location.reload(); $("#submit_thing").html("Process a {{ query_size }} sample!")
}, 5000);
}, thequeries = data
error: function(result) { var N=data.length,k=0;
console.log("in testISTEX(). Data not found"); // for(var i in thequeries) N += thequeries[i].count
if( N>1) {
var total = JSON.parse(data).total
console.log("N: "+total)
$("#theresults").html("<i> <b>"+pubmedquery+"</b>: "+total+" publications.</i><br>")
$('#submit_thing').prop('disabled', false);
} else {
$("#theresults").html("<i> <b>"+data[0]+"</b></i><br>")
$('#submit_thing').prop('disabled', true);
} }
});
}
// Morris Donut Chart
Morris.Donut({
element: 'hero-donut',
data: [
{% if donut %}
{% for part in donut %}
{label: '{{ part.source }}', value: {{ part.part }} },
{% endfor %}
{% endif %}
], },
colors: ["@white", "@white"], error: function(result) {
//colors: ["#30a1ec", "#76bdee"], console.log("Data not found");
formatter: function (y) { return y + "%" } }
}); });
}
}
// CSS events for selecting one Radio-Input
function FileOrNotFile( value ) {
var showfile = JSON.parse(value)
var theType = $("#id_type option:selected").html();
// @upload-file events
if (showfile) {
console.log("You've clicked the YES")
$("#id_file").show()
$('label[for=id_file]').show();
$("#id_name").attr("placeholder", "");
$("#scanpubmed").html("")
$("#theresults").html("")
$('#submit_thing').prop('disabled', false);
$( "#id_name" ).on('input',null);
$("#submit_thing").html('<span class="glyphicon glyphicon-ok" aria-hidden="true" ></span> Process this!')
}
// @dynamic-query events
else {
console.log("You've clicked the NO")
$("#id_file").hide()
$('label[for=id_file]').hide();
$("#id_name").attr("placeholder", " [ Enter your query here ] ");
$("#id_name").focus();
$("#scanpubmed").html('<a class="btn btn-primary">Scan</a>')//+'Get: <input id="id_N" size="2" type="text"></input>')
$("#theresults").html("")
$("#submit_thing").prop('disabled' , true)
$( "#id_name" ).on('input',function(e){
console.log($(this).val())
if(theType=="Pubmed (XML format)")
testPUBMED( $(this).val() )
});
}
}
//CSS events for changing the Select element
function CustomForSelect( selected ) {
// show Radio-Inputs and trigger FileOrNotFile>@upload-file events
selected = selected.toLowerCase()
var is_pubmed = (selected.indexOf('pubmed') != -1);
var is_istex = (selected.indexOf('istex') != -1);
if (is_pubmed || is_istex) {
// if(selected=="pubmed") {
console.log("show the button for: " + selected)
$("#pubmedcrawl").css("visibility", "visible");
$("#pubmedcrawl").show();
$("#file_yes").click();
$("#submit_thing").html("Process this!")
}
// hide Radio-Inputs and trigger @upload-file events
else {
console.log("hide the button")
$("#pubmedcrawl").css("visibility", "hidden");
$("#id_file").show()
$('label[for=id_file]').show();
FileOrNotFile( "true" )
}
}
var LastData = []
function NSuggest_CreateData(q, data) {
console.log("in the new NSuggest_CreateData:")
LastData = data;
// console.log(LastData)
console.log("adding class ui-widget")
$("#id_name").removeClass( "ui-widget" ).addClass( "ui-widget" )
$( "#id_name" ).autocomplete({
source: LastData
});
return data;
}
function testPUBMED( query ) {
LastData = []
if(!query || query=="") return;
var pubmedquery = encodeURIComponent(query)
$.ajax({
type: 'GET',
url: "http://www.ncbi.nlm.nih.gov/portal/utils/autocomp.fcgi?dict=pm_related_queries_2&q="+pubmedquery,
// data:"db="+db+"&query="+query,
contentType: "application/json",
dataType: 'jsonp'
});
return false;
}
function testISTEX(query,N) {
console.log("in testISTEX:");
if(!query || query=="") return;
var origQuery = query
var postQuery = { query : query , N: N }
var projectid = window.location.href.split("projects")[1].replace(/\//g, '')//replace all the slashes
$.ajax({
// contentType: "application/json",
url: window.location.origin+"/scrapers/istex/save/"+projectid,
data: postQuery,
type: 'POST',
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
},
success: function(data) {
console.log("ajax_success: in testISTEX()")
console.log(data)
setTimeout(
function() {
location.reload();
}, 5000);
},
error: function(result) {
console.log("in testISTEX(). Data not found");
}
});
}
// Morris Donut Chart
Morris.Donut({
element: 'hero-donut',
data: [
{% if donut %}
{% for part in donut %}
{label: '{{ part.source }}', value: {{ part.part }} },
{% endfor %}
{% endif %}
],
colors: ["@white", "@white"],
//colors: ["#30a1ec", "#76bdee"],
formatter: function (y) { return y + "%" }
});
</script> </script>
{% endblock %} {% endblock %}
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