Corrections pour backend 0.2
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage_django / templates / recherche.html
CommitLineData
d15017b2
CR
1{% extends "container_base.html" %}
2
3{% block contenu %}
4<script>
5 function urlencode(str) {
6 return escape(str).replace(/\+/g,'%2B').replace(
7 /%20/g, '+').replace(/\*/g, '%2A').replace(
8 /\//g, '%2F').replace(/@/g, '%40');
9 }
10 function makeLink (page) {
11 return "?page=" + page +
12 "&q=" + urlencode ("{{ q }}");
13 }
14
15 $(document).ready(function(){
16 var currentPage = {{ page }};
17 var lastPage = {{ data.last_page }};
18 var more = '{{ data.more_link }}';
19
20 var span = $("#pageLinks");
21 // Premiere page
22 if (currentPage == 0)
23 span.append ('<span class="lien-texte">&lt;&lt;</span>&nbsp;&nbsp;');
24 else
25 span.append ('<a href="' + makeLink(0) +
26 '"><span class="lien-texte">&lt;&lt;</span></a>&nbsp;&nbsp;');
27
28 // Boucle
29 var f = currentPage - 4;
30 var t = 0;
31 if (f < 0) { t = -f; f = 0; }
32 t += currentPage + 4;
33 if (t > lastPage) t = lastPage;
34
35 for (var i = f; i <= t; i++) {
36 var display = i + 1;
37 if (i == currentPage)
38 span.append ("<span>" + display + "</span>&nbsp;&nbsp;");
39 else
40 span.append ('<a href="' + makeLink(i) + '"><span>' +
41 display + '</span></a>&nbsp;&nbsp;');
42 }
43
44 // Derniere page
45 if (currentPage == lastPage)
46 span.append ('<span class="lien-texte">&gt;&gt;</span>');
47 else
48 span.append ('<a href="' + makeLink(lastPage) +
49 '"><span class="lien-texte">&gt;&gt;</span></a>');
50
51 if (more.length > 0)
52 span.append ('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +
53 '<a href="'+more+'"><span class="lien-texte">Plus de résultats</span></a>');
54
55 });
56
57
58 </script>
59
60 <h4>Résultats de recherche pour « {{ q }} » :</h4>
61
62 <div class="zone-texte">
63 {% for r in data.results %}
64 <div class="resultatRecherche">
65 <a class="le-titre" href="{{ r.uri }}">{{ r.title|safe }}</a>
66 <div class="resultatResume">{{ r.content|safe }}</div>
67 <a class="ligne-url" href="{{ r.uri }}">{{ r.uri }}</a>
68 </div>
69 {% endfor %}
70 </div>
71 <div class="resultatPages">
72 <span id="pageLinks">
73 </span>
74 </div>
75
76 {% endblock %}