modifié : SRC/public/js/ListeOeuvre.js

This commit is contained in:
sidya82 2015-03-03 11:48:16 +01:00
parent 77544b7ed4
commit 61f4439942

View File

@ -62,48 +62,33 @@ $('#enregistrer').click(function() {
// Afficher résultat de recherche d'oeuvre // Afficher résultat de recherche d'oeuvre
$('#search_button, #previous, #next').click(function(event) { $('#search_button, #previous, #next').click(function(event) {
event.preventDefault(); event.preventDefault();
if(this.id == $('#next').attr('id') && $("#next").parent().hasClass('disabled') || this.id == $('#previous').attr('id') && $("#previous").parent().hasClass('disabled')) if(this.id == $('#next').attr('id') && $("#next").parent().hasClass('disabled') || this.id == $('#previous').attr('id') && $("#previous").parent().hasClass('disabled'))
return 0; return 0;
if (this.id == $('#next').attr('id')) { if (this.id == $('#next').attr('id')) {
str = $("#next").attr('href'); str = $("#next").attr('href');
url = "/search?page="+/([0-9]+)/.exec(/page=([0-9]+)/.exec(str)[0])[0]; url = "/search?page="+/([0-9]+)/.exec(/page=([0-9]+)/.exec(str)[0])[0];
}else if (this.id == $('#previous').attr('id')) { }else
if (this.id == $('#previous').attr('id')) {
str = $("#previous").attr('href'); str = $("#previous").attr('href');
url = "/search?page="+/([0-9]+)/.exec(/page=([0-9]+)/.exec(str)[0])[0]; url = "/search?page="+/([0-9]+)/.exec(/page=([0-9]+)/.exec(str)[0])[0];
}else { }else {
url = "/search"; url = "/search";
} }
$('#oeuvreRes').empty(); $('#oeuvreRes').empty();
dataSend = "_token = $('#_tokenRes').val()," dataSend = {
+"auteur = ('#auteur').val()," _token : $('#_tokenRes').val(),
+"designation = $('#designation').val()," auteur: $('#auteur').val(),
+"matiere = $('#matiere').val()," designation: $('#designation').val(),
+"domaine = $('#domaine').val()," matiere: $('#matiere').val(),
+"technique = $('#technique').val()," domaine: $('#domaine').val(),
+"debut = $('#debut').val()," technique: $('#technique').val(),
+"fin = $('#fin').val()"; debut: $('#debut').val(),
fin: $('#fin').val()
var r = new XMLHttpRequest(); };
r.open("POST", url, true); $.post(url,
r.onreadystatechange = function () { dataSend,
if (r.readyState != 4 || r.status != 200) function( data ) {
{
$("#oeuvreRes").append('<div class="alert alert-danger">'
+'<strong>Oouups!</strong> Il y a un problème.<br><br>'
+'<ul>'
+'<li>Erreur lors de la récupération</li>'
+'</ul>'
+'</div>'
);
return;
}
data = r.responseText;
if (data.length == 0 ) if (data.length == 0 )
$("#oeuvreRes").append("Aucune Oeuvre Trouvé.."); $("#oeuvreRes").append("Aucune Oeuvre Trouvé..");
data.data.forEach( function(el) { data.data.forEach( function(el) {
@ -112,23 +97,28 @@ $('#search_button, #previous, #next').click(function(event) {
+'<img src="http://www.augustins.org/documents/10180/156407/' + el.urlPhoto + '"/>' +'<img src="http://www.augustins.org/documents/10180/156407/' + el.urlPhoto + '"/>'
+'</a></div>'); +'</a></div>');
}); });
if(data.prev_page_url == null) { if(data.prev_page_url == null) {
$("#previous").parent().addClass('disabled'); $("#previous").parent().addClass('disabled');
}else { }else {
$("#previous").attr('href', data.prev_page_url); $("#previous").attr('href', data.prev_page_url);
$("#previous").parent().removeClass('disabled'); $("#previous").parent().removeClass('disabled');
} }
if(data.next_page_url == null) { if(data.next_page_url == null) {
$("#next").parent().addClass('disabled'); $("#next").parent().addClass('disabled');
}else { }else {
$("#next").attr('href', data.next_page_url); $("#next").attr('href', data.next_page_url);
$("#next").parent().removeClass('disabled'); $("#next").parent().removeClass('disabled');
} }
}, "json" )
}; .fail(function() {
r.send(dataSend); $("#oeuvreRes").append('<div class="alert alert-danger">'
+'<strong>Oouups!</strong> Il y a un problème.<br><br>'
+'<ul>'
+'<li>Erreur lors de la récupération</li>'
+'</ul>'
+'</div>'
);
});
}); });