Commit bfdab6f5 authored by PkSM3's avatar PkSM3

[UPDATE] paginator and ajax OK

parent cbb9f8b9
...@@ -503,6 +503,22 @@ def subcorpusJSON(request, project_id, corpus_id, start , end ): ...@@ -503,6 +503,22 @@ def subcorpusJSON(request, project_id, corpus_id, start , end ):
return HttpResponse( serializer.data , content_type='application/json') return HttpResponse( serializer.data , content_type='application/json')
# for pagexample.html
from django.core.paginator import Paginator, InvalidPage, EmptyPage
def get_pagination_page(page=1):
items = range(0, 100)
paginator = Paginator(items, 10)
try:
page = int(page)
except ValueError:
page = 1
try:
items = paginator.page(page)
except (EmptyPage, InvalidPage):
items = paginator.page(paginator.num_pages)
return items
......
...@@ -80,16 +80,9 @@ ...@@ -80,16 +80,9 @@
<div id="collapseOne" class="panel-collapse collapse" role="tabpanel"> <div id="collapseOne" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body"> <div class="panel-body">
<p align="right"> <p align="right">
Page <a href="#">2</a> sur 100
</p> <!--{% include "subcorpus.html" %}-->
</center> <div id="subcorpusdiv"></div>
{% if documents %}
<ul>
{% for doc in documents %}
<li> <b>{{ doc.date }}</b>, <a href="/admin/node/document/{{doc.id}}">{{ doc.title}}</a></li>
{% endfor %}
</ul>
{% endif %}
</div> </div>
</div> </div>
...@@ -161,14 +154,47 @@ function dateToInt(todayTime) { ...@@ -161,14 +154,47 @@ function dateToInt(todayTime) {
} }
function updateDocuments() { // I've clicked "Read Documents":
if(!datesbuffer) return; function updateDocuments(pagenumber,pagenav) {
pagenav = (pagenav)?pagenav:true;
pagenumber = (pagenumber)?pagenumber:1;
pr("in here pagenav:"+pagenav+" - pagenumber:"+pagenumber)
pr($( "#collapseOne" ).height())
// if "Read Documents" collapsible is close, then... show some me pubs!
if ( pagenav || $( "#collapseOne" ).height() < 50) {
// Here u ask for the server some paginated results (pubs)
// if u havent select a timerange from the blue chart, then show me all pubs
if(!datesbuffer) {
console.log("nothing cause dont wanna")
}
// there's some timerange selected in the blue chart, so show me the pubs of that period
else {
var dataini = dateToInt(datesbuffer[0])
var datafin = dateToInt(datesbuffer[1])
//http://localhost:8000/project/37525/corpus/37526/timerange/20040117/20040125?page=1
var base = window.location.href;
var theurl = base+"timerange/"+dataini+"/"+datafin+"?page="+pagenumber;
pr("theurl: "+theurl)
$.ajax({
url: theurl,
success: function(data) {
// console.log(data)
$('#subcorpusdiv').html(data);
}
});
}
}
//else: "Read Documents" collapsible is open!, so do nothing
var dataini = dateToInt(datesbuffer[0])
var datafin = dateToInt(datesbuffer[1])
//http://localhost:8000/project/37525/corpus/37526/timerange/20040117/20040125?page=1
pr("make_ajax_query"+window.location.href+"timerange/"+dataini+"/"+datafin+"?page=1")
} }
......
...@@ -4,23 +4,10 @@ ...@@ -4,23 +4,10 @@
<p>Today: {{date}}</p> <p>Today: {{date}}</p>
{% endif %} {% endif %}
{% if documents %}
<p>Paginator stuff</p>
<ul>
{% for doc in documents %}
{% if doc.date %}
<li> <b>{{ doc.date }}</b>, <a href="/admin/node/document/{{doc.id}}">id:{{ doc.id}} title:{{ doc.name}}</a></li>
{% endif %}
{% endfor %}
</ul>
<div class="pagination"> <div class="pagination">
<span class="step-links"> <span class="step-links">
{% if documents.has_previous %} {% if documents.has_previous %}
<a href="?page={{ documents.previous_page_number }}">previous</a> <a onclick="updateDocuments({{ documents.previous_page_number }},true);">previous</a>
{% endif %} {% endif %}
<span class="current"> <span class="current">
...@@ -28,11 +15,20 @@ ...@@ -28,11 +15,20 @@
</span> </span>
{% if documents.has_next %} {% if documents.has_next %}
<a href="?page={{ documents.next_page_number }}">next</a> <a onclick="updateDocuments({{ documents.next_page_number }},true);">next</a>
{% endif %} {% endif %}
</span> </span>
</div> </div>
{% if documents %}
<p>Paginator stuff</p>
<ul>
{% for doc in documents %}
{% if doc.date %}
<li> <b>{{ doc.date }}</b>, <a href="/admin/node/document/{{doc.id}}">id:{{ doc.id}} title:{{ doc.name}}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %} {% endif %}
\ 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