modifié : SRC/public/js/ListeOeuvre.js
This commit is contained in:
parent
77544b7ed4
commit
61f4439942
@ -62,73 +62,63 @@ $('#enregistrer').click(function() {
|
||||
|
||||
// Afficher résultat de recherche d'oeuvre
|
||||
$('#search_button, #previous, #next').click(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if(this.id == $('#next').attr('id') && $("#next").parent().hasClass('disabled') || this.id == $('#previous').attr('id') && $("#previous").parent().hasClass('disabled'))
|
||||
return 0;
|
||||
|
||||
if (this.id == $('#next').attr('id')) {
|
||||
str = $("#next").attr('href');
|
||||
url = "/search?page="+/([0-9]+)/.exec(/page=([0-9]+)/.exec(str)[0])[0];
|
||||
}else if (this.id == $('#previous').attr('id')) {
|
||||
event.preventDefault();
|
||||
if(this.id == $('#next').attr('id') && $("#next").parent().hasClass('disabled') || this.id == $('#previous').attr('id') && $("#previous").parent().hasClass('disabled'))
|
||||
return 0;
|
||||
if (this.id == $('#next').attr('id')) {
|
||||
str = $("#next").attr('href');
|
||||
url = "/search?page="+/([0-9]+)/.exec(/page=([0-9]+)/.exec(str)[0])[0];
|
||||
}else
|
||||
if (this.id == $('#previous').attr('id')) {
|
||||
str = $("#previous").attr('href');
|
||||
url = "/search?page="+/([0-9]+)/.exec(/page=([0-9]+)/.exec(str)[0])[0];
|
||||
}else {
|
||||
url = "/search";
|
||||
}
|
||||
|
||||
$('#oeuvreRes').empty();
|
||||
dataSend = "_token = $('#_tokenRes').val(),"
|
||||
+"auteur = ('#auteur').val(),"
|
||||
+"designation = $('#designation').val(),"
|
||||
+"matiere = $('#matiere').val(),"
|
||||
+"domaine = $('#domaine').val(),"
|
||||
+"technique = $('#technique').val(),"
|
||||
+"debut = $('#debut').val(),"
|
||||
+"fin = $('#fin').val()";
|
||||
|
||||
var r = new XMLHttpRequest();
|
||||
r.open("POST", url, true);
|
||||
r.onreadystatechange = function () {
|
||||
if (r.readyState != 4 || r.status != 200)
|
||||
{
|
||||
$("#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 )
|
||||
$("#oeuvreRes").append("Aucune Oeuvre Trouvé..");
|
||||
data.data.forEach( function(el) {
|
||||
$("#oeuvreRes").append('<div class="col-xs-4 col-md-3">'
|
||||
+'<a href="#" class="thumbnail">'
|
||||
+'<img src="http://www.augustins.org/documents/10180/156407/' + el.urlPhoto + '"/>'
|
||||
+'</a></div>');
|
||||
});
|
||||
|
||||
if(data.prev_page_url == null) {
|
||||
$("#previous").parent().addClass('disabled');
|
||||
}else {
|
||||
$("#previous").attr('href', data.prev_page_url);
|
||||
$("#previous").parent().removeClass('disabled');
|
||||
}
|
||||
|
||||
if(data.next_page_url == null) {
|
||||
$("#next").parent().addClass('disabled');
|
||||
}else {
|
||||
$("#next").attr('href', data.next_page_url);
|
||||
$("#next").parent().removeClass('disabled');
|
||||
}
|
||||
|
||||
};
|
||||
r.send(dataSend);
|
||||
$('#oeuvreRes').empty();
|
||||
dataSend = {
|
||||
_token : $('#_tokenRes').val(),
|
||||
auteur: $('#auteur').val(),
|
||||
designation: $('#designation').val(),
|
||||
matiere: $('#matiere').val(),
|
||||
domaine: $('#domaine').val(),
|
||||
technique: $('#technique').val(),
|
||||
debut: $('#debut').val(),
|
||||
fin: $('#fin').val()
|
||||
};
|
||||
$.post(url,
|
||||
dataSend,
|
||||
function( data ) {
|
||||
if (data.length == 0 )
|
||||
$("#oeuvreRes").append("Aucune Oeuvre Trouvé..");
|
||||
data.data.forEach( function(el) {
|
||||
$("#oeuvreRes").append('<div class="col-xs-4 col-md-3">'
|
||||
+'<a href="#" class="thumbnail">'
|
||||
+'<img src="http://www.augustins.org/documents/10180/156407/' + el.urlPhoto + '"/>'
|
||||
+'</a></div>');
|
||||
});
|
||||
if(data.prev_page_url == null) {
|
||||
$("#previous").parent().addClass('disabled');
|
||||
}else {
|
||||
$("#previous").attr('href', data.prev_page_url);
|
||||
$("#previous").parent().removeClass('disabled');
|
||||
}
|
||||
if(data.next_page_url == null) {
|
||||
$("#next").parent().addClass('disabled');
|
||||
}else {
|
||||
$("#next").attr('href', data.next_page_url);
|
||||
$("#next").parent().removeClass('disabled');
|
||||
}
|
||||
}, "json" )
|
||||
.fail(function() {
|
||||
$("#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>'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user