Skip to content
Extraits de code Groupes Projets
Valider 378e16f7 rédigé par Tanguy CHARLES's avatar Tanguy CHARLES
Parcourir les fichiers

merge

parents 36d17b34 38c4d78f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -30,6 +30,13 @@ urlHasArgument();
?>
<?php
$url_alea = 'https://images-api.nasa.gov/search?year_start=2007&page='.random_int(0,99);
$resJSON = retrieveJsonFromUrl($url_alea);
$image = $resJSON->{'collection'}->{'items'}[random_int(0, 99)];
// var_dump($image);
?>
<html>
......@@ -37,36 +44,41 @@ urlHasArgument();
generateHeader('Image Alea');
generateUserbanner();
?>
<body style="background-image:url('./ressources/background/test2.jpeg'); text-align: center">
<body style="background-image:url('./ressources/background/test2.jpeg'); text-align: center" onload="initiateCDC(<?php echo "'".$_SESSION['id_user']."'"; ?>, <?php echo "'".$image->{'data'}[0]->{'nasa_id'}."'"; ?>)">
<!-- génération des bonnières -->
<?php
generateNavBar('image_alea');
?>
<h1 class="titre" style="text-align: center"> Image Aleatoire de la bibliotheque : </h1>
<?php
$url_alea = 'https://images-api.nasa.gov/search?year_start=2007&page='.random_int(0,99);
$resJSON = retrieveJsonFromUrl($url_alea);
$image = $resJSON->{'collection'}->{'items'}[random_int(0, 99)];
// var_dump($image);
?>
<div class="view container-fluid">
<div class="hover-container" style="margin: 3px">
<div class="hover-container">
<img class="img-fluid" style="margin: 4px" src=<?php echo $image->{'links'}[0]->{'href'} ?>>
<div class="content">
<div class="text scrollbar">
<div class="text scrollbar" style="height: calc(100% - 80px);">
<h4><?php echo $image->{'data'}[0]->{'title'} ?></h4>
<p style="font-size: 15px"><?php echo $image->{'data'}[0]->{'description'} ?></p>
</div>
<div class="actionrow" style="left: -120px;">
<div class="actionrow">
<form method="POST" action="download.php" target="_blank">
<input type="hidden" name="urlget" value=<?php echo $image->{'href'} ?>>
<input type="hidden" name="nasa_id" value=<?php echo $image->{'data'}[0]->{'nasa_id'} ?>>
<input type="hidden" name="title" value=<?php echo $image->{'data'}[0]->{'title'} ?>>
<input type="hidden" name="preview" value=<?php echo $image->{'links'}[0]->{'href'} ?>>
<input type="image" name="submit" alt="Submit" class="download" width="13%" src="./ressources/icons/dwnld.png" onmouseover="this.src='./ressources/icons/dwnldVert.png'" onmouseout="this.src='./ressources/icons/dwnld.png'">
<table style="margin-right:5%"><tbody><tr><td align="left" width="10%">
<input type="image" name="submit" alt="Submit" class="download" width="100%" src="./ressources/icons/dwnld.png" onmouseover="this.src='./ressources/icons/dwnldVert.png'" onmouseout="this.src='./ressources/icons/dwnld.png'"></td>
<td width="61%"></td>
<td width="19%"></td>
<td align="right" width="10%">
<?php if (isset($_SESSION["id_user"])): ?>
<div id="emplacementCDC"></div>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
......@@ -80,4 +92,4 @@ urlHasArgument();
<?php generateFooter(); ?>
</body>
</html>
\ No newline at end of file
</html>
......@@ -371,6 +371,15 @@ function switchCDCbutton(user, encodedId, ancienEtat) {
}
}
// fonction appelée au chargement de image_alea.php pour démarrer les infos des coups de coeur
function initiateCDC(user, Id) {
console.log("COUCOU");
var encodedId = stringToIntList(Id);
console.log(encodedId);
document.getElementById('emplacementCDC').innerHTML = '<div id="emplacementCDC_'+encodedId+'"><img alt="Coup de coeur" width="105%" style="cursor: pointer;" onclick="switchCDCbutton(' + user + ',\'' + encodedId + '\',\'blanc\')" src="./ressources/icons/coeurBlanc.png"></img></div>';
}
function isInReviewlist(id) {
var liste = $('#' + 'Reviewlist' + " li");
var encoded_id = stringToIntList(id);
......
......@@ -13,26 +13,106 @@ var displayer = {
startdisplay: function(idToDat, whereToDisplay) {
var liste = $('#'+idToDat+" li");
$('#'+whereToDisplay).html('<div id="'+whereToDisplay+'row" class="row"></div>');
liste.each(function() {
// console.log("__");
// console.log($(this).text());
var currentID = intListToString($(this).text());
// console.log(currentID);
requestHandler.retrieveJsonFromUrl('https://images-api.nasa.gov/asset/'+currentID, function(json) {
console.log(json);
$('#'+whereToDisplay+'row').append('<div class="col"><div class="view container-fluid"><div class="hover-container" style="margin: 3px">'+
'<img class="img-fluid" style="margin: 4px" src='+json.collection.items[2].href+'>'+
'<div class="content">'+
// '<div class="text scrollbar">'+
// '<h4><?php echo $image->{'data'}[0]->{'title'} ?></h4>'+
// '<p style="font-size: 15px"><?php echo $image->{'data'}[0]->{'description'} ?></p>'+
// '</div>'+
'<div class="actionrow" style="left: -120px;">'+
'<form method="POST" action="download.php" target="_blank">'+
'<input type="hidden" name="urlget" value="'+correctionURLLink(json.collection.items[5].href)+'">'+
'<input type="hidden" name="nasa_id" value="'+currentID+'">'+
'<input type="hidden" name="title" value="img-nasa">'+
'<input type="hidden" name="preview" value='+json.collection.items[2].href+'>'+
'<input type="image" name="submit" alt="Submit" class="download" width="13%" src="./ressources/icons/dwnld.png" onmouseover="this.src=\'./ressources/icons/dwnldVert.png\'" onmouseout="this.src=\'./ressources/icons/dwnld.png\'">'+
'</form>'+
'</div>'+
'</div>'+
'</div>'+
'</div></div>');
});
});
}
}
console.log(currentID);
<<<<<<< HEAD
=======
var displayerMoyReview = {
startdisplay: function(idToDat, whereToDisplay) {
var liste = $('#'+idToDat+" li");
$('#'+whereToDisplay).html('<div id="'+whereToDisplay+'row" class="row"></div>');
liste.each(function() {
var currentID = intListToString(this. getElementsByClassName('idPhoto')[0].innerHTML);
var moyenne = this.getElementsByClassName('moyenne')[0].innerHTML;
console.log("id : "+currentID+" ; moyenne : "+moyenne);
requestHandler.retrieveJsonFromUrl('https://images-api.nasa.gov/asset/'+currentID, function(json) {
$('#'+whereToDisplay+'row').append(
'<div class="col"><img width=300 src="'+json.collection.items[2].href+'"><p>pas de description</p></div>'
$('#'+whereToDisplay+'row').append('<div class="col"><img width=300 src="'+json.collection.items[2].href+'"><p>Cette photo à été notée avec une moyenne de '+displayerMoyReview.troncate(moyenne)+' étoiles</p></div>')
});
});
},
troncate: function(moy) {
var length = 3;
return moy.substring(0, length)
}
}
);
var displayerNbCDC = {
startdisplay: function(idToDat, whereToDisplay) {
var liste = $('#'+idToDat+" li");
$('#'+whereToDisplay).html('<div id="'+whereToDisplay+'row" class="row"></div>');
liste.each(function() {
console.log("coucou");
var currentID = intListToString(this.getElementsByClassName('idPhoto')[0].innerHTML);
var nbCDC = this.getElementsByClassName('nbCDC')[0].innerHTML;
console.log("id : "+currentID+" ; nbCDC : "+nbCDC);
requestHandler.retrieveJsonFromUrl('https://images-api.nasa.gov/asset/'+currentID, function(json) {
$('#'+whereToDisplay+'row').append('<div class="col"><img width=300 src="'+json.collection.items[2].href+'"><p>Cette photo a '+nbCDC+' coups de coeur</p></div>');
});
});
}
}
>>>>>>> 38c4d78fee3719e64f5807bff44c8c60bfb5db39
var requestHandler = {
retrieveJsonFromUrl: function(url, callback) {
var xhr = new XMLHttpRequest();
......@@ -77,4 +157,15 @@ var requestHandler = {
function startDisplayer(IDsource, IDdestination) {
console.log("démarrage");
displayer.startdisplay(IDsource, IDdestination);
}
function startDisplayerNbCDC(IDsource, IDdestination) {
console.log("démarrage displayer CDC");
displayerNbCDC.startdisplay(IDsource, IDdestination);
}
function startDisplayerMoyReview(IDsource, IDdestination) {
console.log("démarrage du displayer Moyenne des reviews");
displayerMoyReview.startdisplay(IDsource, IDdestination);
}
\ No newline at end of file
......@@ -45,7 +45,7 @@ urlHasArgument();
<!DOCTYPE html>
<html>
<?php generateHeader('leaderboard'); ?>
<body onload="startDisplayer('NoteLeaderboard', 'NoteLeaderboardDisplayArea'); startDisplayer('CDCLeaderboard', 'CDCLeaderboardDisplayArea')" style="text-align: center;
<body onload="startDisplayerMoyReview('NoteLeaderboard', 'NoteLeaderboardDisplayArea'); startDisplayerNbCDC('CDCLeaderboard', 'CDCLeaderboardDisplayArea')" style="text-align: center;
background-image:url('./ressources/background/test2.jpeg');
background-repeat: no-repeat;
background-attachment: fixed;">
......@@ -59,7 +59,7 @@ urlHasArgument();
$test = $orderRepository->fetchAvgNoteOrder();
foreach ($test as $elem): ?>
<li><?php echo $elem->getIdPhoto(); ?></li>
<li><div class="idPhoto"><?php echo $elem->getIdPhoto(); ?></div><div class="moyenne"><?php echo $elem->getNote(); ?></div></li>
<?php endforeach; ?>
</div>
......@@ -68,7 +68,7 @@ urlHasArgument();
$test = $orderRepository->fetchCDCOrder();
foreach ($test as $elem): ?>
<li><?php echo $elem->getIdPhoto(); ?></li>
<li><div class="idPhoto"><?php echo $elem->getIdPhoto(); ?></div><div class="nbCDC"><?php echo $elem->getNbCDC(); ?></div></li>
<?php endforeach; ?>
</div>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter