diff --git a/public/js/picture_displayer.js b/public/js/picture_displayer.js index c43763fdcb5889e6694f12dc5bf8d14b46d942b5..3d5bc72a1628da6a33d2bc564637f421626ce54b 100644 --- a/public/js/picture_displayer.js +++ b/public/js/picture_displayer.js @@ -18,30 +18,30 @@ var displayer = { // console.log("__"); // console.log($(this).text()); - var currentID = intListToString($(this).text()); + var currentID = intListToString($(this).text()); // console.log(currentID); requestHandler.retrieveJsonFromUrl('https://images-api.nasa.gov/search?nasa_id='+currentID, function(json) { var real_im = json.collection.items[0]; $('#'+whereToDisplay+'row').append('<div class="view container">'+ '<div class="hover-container" style="margin: 3px">'+ - '<img class="img-fluid" style="margin: 4px" src='+real_im.links[0].href+'>'+ - '<div class="content">'+ - '<div class="text scrollbar">'+ - '<h4>'+real_im.data[0].title+'</h4>'+ - '<p style="font-size: 15px">'+real_im.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(real_im.href)+'">'+ - '<input type="hidden" name="nasa_id" value="'+currentID+'">'+ - '<input type="hidden" name="title" value="'+real_im.data[0].title+'">'+ - '<input type="hidden" name="preview" value="'+real_im.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\'">'+ - '</form>'+ - '</div>'+ - '</div>'+ + '<img class="img-fluid" style="margin: 4px" src='+real_im.links[0].href+'>'+ + '<div class="content">'+ + '<div class="text scrollbar">'+ + '<h4>'+real_im.data[0].title+'</h4>'+ + '<p style="font-size: 15px">'+real_im.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(real_im.href)+'">'+ + '<input type="hidden" name="nasa_id" value="'+currentID+'">'+ + '<input type="hidden" name="title" value="'+real_im.data[0].title+'">'+ + '<input type="hidden" name="preview" value="'+real_im.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\'">'+ + '</form>'+ + '</div>'+ '</div>'+ - '</div>'); + '</div>'+ + '</div>'); }); }); } @@ -57,31 +57,31 @@ var displayerMoyReview = { liste.each(function() { // console.log("__"); - var texte_li = $(this).text(); - var tab = texte_li.split(","); - if( tab[1].length > 3 ) - tab[1] = tab[1].substring(0,3); - var valeurMoy = parseFloat( tab[1] ); - if( valeurMoy >= 4.9 ) - var color =""; + var texte_li = $(this).text(); + var tab = texte_li.split(","); + if( tab[1].length > 3 ) + tab[1] = tab[1].substring(0,3); + var valeurMoy = parseFloat( tab[1] ); + if( valeurMoy >= 4.9 ) + var color =""; + else + { + if( valeurMoy >= 4.0 ) + var color = "yellow"; else { - if( valeurMoy >= 4.0 ) - var color = "yellow"; + if( valeurMoy >= 3.0 ) + var color = "white"; else - { - if( valeurMoy >= 3.0 ) - var color = "white"; - else - var color = "red"; - } + var color = "red"; } + } - var place = parseInt( tab[2] ); - if( place > 1 ) - tab[2] += "eme" - else - tab[2] += "er" + var place = parseInt( tab[2] ); + if( place > 1 ) + tab[2] += "eme" + else + tab[2] += "er" // console.log("ascii:" + tab[0] + ", " + tab[1]); var currentID = intListToString(tab[0]); @@ -91,31 +91,35 @@ var displayerMoyReview = { requestHandler.retrieveJsonFromUrl('https://images-api.nasa.gov/search?nasa_id='+currentID, function(json) { var real_im = json.collection.items[0]; $('#'+whereToDisplay+'row').append('<div class="view container">'+ - '<div class="hover-container" style="margin: 3px">'+ - '<img class="img-fluid" style="margin: 4px" src='+real_im.links[0].href+'>'+ - '<div class="content">'+ - '<div class="text scrollbar">'+ - '<h4>'+real_im.data[0].title+'</h4>'+ - '<p style="font-size: 15px">'+real_im.data[0].description+'</p>'+ - '</div>'+ - '<div class="actionrow" style="left: -120px;margin-bottom:15px;">'+ - '<form method="POST" action="download.php" target="_blank">'+ - '<input type="hidden" name="urlget" value="'+correctionURLLink(real_im.href)+'">'+ - '<input type="hidden" name="nasa_id" value="'+currentID+'">'+ - '<input type="hidden" name="title" value="'+real_im.data[0].title+'">'+ - '<input type="hidden" name="preview" value="'+real_im.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\'">'+ - '</form>'+ - '</div>'+ - '<div class="actionrow" style="color:'+color+';left:15px;margin-bottom:15px;right:15px;font-size:35px;font-family: abang">'+ - tab[1]+ - '</div>'+ - '<div class="actionrow" style="color:'+color+';margin-left: 45%;margin-bottom:15px;right:15px;font-size:35px;font-family: abang">'+ - tab[2]+ - '</div>'+ - '</div>'+ - '</div>'+ - '</div>'); + '<div class="hover-container" style="margin: 3px">'+ + '<img class="img-fluid" style="margin: 4px" src='+real_im.links[0].href+'>'+ + '<div class="content">'+ + '<div class="text scrollbar">'+ + '<h4>'+real_im.data[0].title+'</h4>'+ + '<p style="font-size: 15px">'+real_im.data[0].description+'</p>'+ + '</div>'+ + '<div class="actionrow" style="margin-bottom:15px;">'+ + '<form method="POST" action="download.php" target="_blank">'+ + '<input type="hidden" name="urlget" value="'+correctionURLLink(real_im.href)+'">'+ + '<input type="hidden" name="nasa_id" value="'+currentID+'">'+ + '<input type="hidden" name="title" value="'+real_im.data[0].title+'">'+ + '<input type="hidden" name="preview" value="'+real_im.links[0].href+'"">'+ + '<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="51%">'+ + '</td>'+ + '<td width="29%" style="color:'+color+'; font-size:170%;font-family: abang">'+tab[1]+ + '</td>'+ + '<td align="right" width="10%" style="color:'+color+'; font-size:170%;font-family: abang">'+tab[2]+ + '</td>'+ + '</tr></tbody></table>'+ + '</form>'+ + '</div>'+ + '</div>'+ + '</div>'+ + '</div>'); }); }); }, @@ -149,37 +153,29 @@ var displayerNbCDC = { var liste = $('#'+idToDat+" li"); $('#'+whereToDisplay).html('<div id="'+whereToDisplay+'row" class="row"></div>'); liste.each( - function() { + function() { // console.log("__"); - + var texte_li = $(this).text(); var tab = texte_li.split(","); // console.log("ascii:" + tab[0] + ", " + tab[1]); var currentID = intListToString(tab[0]); var nbCDC = parseInt( tab[1]); - console.log(10000*parseInt(tab[2], 10)); - setTimeout(affiche_dans_lordre(whereToDisplay, tab, currentID, nbCDC), 100*parseInt(tab[2], 10)); - } - ); - } -} - -function affiche_dans_lordre(whereToDisplay, tab, currentID, nbCDC ) { - if( nbCDC >= 25 ) - var color = "yellow" - else - { - if( nbCDC >= 10 ) - var color = "blue"; - else - var color = "white"; - } - - var place = parseInt( tab[2] ); - if( place > 1 ) - tab[2] += "eme" - else - tab[2] += "er" + if( nbCDC >= 25 ) + var color = "yellow" + else + { + if( nbCDC >= 10 ) + var color = "blue"; + else + var color = "white"; + } + + var place = parseInt( tab[2] ); + if( place > 1 ) + tab[2] += "eme" + else + tab[2] += "er" // console.log("decode:" +currentID); // console.log(currentID); @@ -187,31 +183,42 @@ function affiche_dans_lordre(whereToDisplay, tab, currentID, nbCDC ) { var real_im = json.collection.items[0]; $('#'+whereToDisplay+'row').append('<div class="view container">'+ '<div class="hover-container" style="margin: 3px">'+ - '<img class="img-fluid" style="margin: 4px" src='+real_im.links[0].href+'>'+ - '<div class="content">'+ - '<div class="text scrollbar">'+ - '<h4>'+real_im.data[0].title+'</h4>'+ - '<p style="font-size: 15px">'+real_im.data[0].description+'</p>'+ - '</div>'+ - '<div class="actionrow" style="left: -120px;margin-bottom:15px;">'+ - '<form method="POST" action="download.php" target="_blank">'+ - '<input type="hidden" name="urlget" value="'+correctionURLLink(real_im.href)+'">'+ - '<input type="hidden" name="nasa_id" value="'+currentID+'">'+ - '<input type="hidden" name="title" value="'+real_im.data[0].title+'">'+ - '<input type="hidden" name="preview" value="'+real_im.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\'">'+ - '</form>'+ - '</div>'+ - '<div class="actionrow" style="color:'+color+';left:15px;margin-bottom:15px;right:15px;font-size:35px;font-family: abang">'+ - tab[1]+ - '</div>'+ - '<div class="actionrow" style="color:'+color+';margin-left: 45%;margin-bottom:15px;right:15px;font-size:35px;font-family: abang">'+ - tab[2]+ - '</div>'+ - '</div>'+ + '<img class="img-fluid" style="margin: 4px" src='+real_im.links[0].href+'>'+ + '<div class="content">'+ + '<div class="text scrollbar">'+ + '<h4>'+real_im.data[0].title+'</h4>'+ + '<p style="font-size: 15px">'+real_im.data[0].description+'</p>'+ + '</div>'+ + '<div class="actionrow" style="margin-bottom:15px;">'+ + '<form method="POST" action="download.php" target="_blank">'+ + '<input type="hidden" name="urlget" value="'+correctionURLLink(real_im.href)+'">'+ + '<input type="hidden" name="nasa_id" value="'+currentID+'">'+ + '<input type="hidden" name="title" value="'+real_im.data[0].title+'">'+ + '<input type="hidden" name="preview" value="'+real_im.links[0].href+'"">'+ + '<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="51%">'+ + '</td>'+ + '<td width="29%" style="color:'+color+'; font-size:170%;font-family: abang">'+tab[1]+ + '</td>'+ + '<td align="right" width="10%" style="color:'+color+'; font-size:170%;font-family: abang">'+tab[2]+ + '</td>'+ + '</tr></tbody></table>'+ + '</form>'+ + '</div>'+ '</div>'+ - '</div>'); - }); + '</div>'+ + '</div>'); + }); +} +); + } +} + +function affiche_dans_lordre(whereToDisplay, tab, currentID, nbCDC ) { + } @@ -229,35 +236,35 @@ function affiche_dans_lordre(whereToDisplay, tab, currentID, nbCDC ) { var requestHandler = { retrieveJsonFromUrl: function(url, callback) { var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.responseType = 'json'; - xhr.onload = function() { - var status = xhr.status; - if (status === 200) { - callback(xhr.response); - } else { - console.log("erreur, le status de la réponse indique une anomalie"); - callback(xhr.response); - } - }; - xhr.send(); + xhr.open('GET', url, true); + xhr.responseType = 'json'; + xhr.onload = function() { + var status = xhr.status; + if (status === 200) { + callback(xhr.response); + } else { + console.log("erreur, le status de la réponse indique une anomalie"); + callback(xhr.response); + } + }; + xhr.send(); }, retrieveJsonFromUrlWithPassedParameter: function(url, callback, pass) { var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.responseType = 'json'; - xhr.onload = function() { - var status = xhr.status; - if (status === 200) { - callback(xhr.response, pass); - } else { - console.log("erreur, le status de la réponse indique une anomalie"); - callback(xhr.response, pass); - } - }; - xhr.send(); + xhr.open('GET', url, true); + xhr.responseType = 'json'; + xhr.onload = function() { + var status = xhr.status; + if (status === 200) { + callback(xhr.response, pass); + } else { + console.log("erreur, le status de la réponse indique une anomalie"); + callback(xhr.response, pass); + } + }; + xhr.send(); } }