Advertisement
piffy

Kitten Mania!

Aug 21st, 2022
1,154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.38 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <style>
  4.         div.gallery {
  5.             margin: 5px;
  6.             border: 1px solid #ccc;
  7.             float: left;
  8.             width: 180px;
  9.         }
  10.  
  11.         div.gallery:hover {
  12.             border: 1px solid #777;
  13.         }
  14.  
  15.         div.gallery img {
  16.             width: 100%;
  17.             height: auto;
  18.         }
  19.  
  20.         div.desc {
  21.             padding: 15px;
  22.             text-align: center;
  23.         }
  24.  
  25.     </style>
  26.     <meta charset="utf-8">
  27.     <title>Kitten Mania!</title>
  28.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  29. </head>
  30. <body>
  31. <h1>Kitten Mania!</h1>
  32. <h3>Amorevoli tesorini!</h3>
  33. <p id="timestamp"></p>
  34. <!--- Pulsante utilizzato per i test -->
  35. <!--button id="bottone1" onclick="getFlickerImg()">Mostra Galleria</button-->
  36. <div id="images">
  37.  
  38.     <!--- Questo si può togliere, è lasciato solo come modello -->
  39. <div class="gallery">
  40.         <img src='https://communibee.ca/wp-content/uploads/2019/07/600x400-placeholder.png' alt="600x400" width="600" height="400">
  41.     <div class="desc">
  42.         <a href="#">Add a description of the image here</a>
  43.     </div>
  44. </div>
  45.  
  46.  
  47. </div>
  48.  
  49. <script>
  50.  
  51.     function jsonFlickrFeed(json) {
  52.         $('#images').empty();
  53.         $("#timestamp").html("Ultimo controllo: "+new Date());
  54.         $.each(json.items, function(i, item) {
  55.             let link =$("<a />", {href : item.link, text : item.title});
  56.             $("<div class='gallery'>")
  57.                 .append(
  58.                     $("<img />").attr("src", item.media.m)
  59.  
  60.                 )
  61.                 .append(
  62.                     $("<div class='desc'>").append(link)
  63.                 ).appendTo("#images")
  64.         });
  65.     };
  66. <!-- Prima versione della funzione, usata come test di funzionamento -->
  67.     function jsonFlickrFeedTest(json) {
  68.         $('#images').empty();
  69.         $.each(json.items, function(i, item) {
  70.             $("<img />").attr("src", item.media.m).appendTo("#images");
  71.         });
  72.     };
  73.  
  74.     function getFlickerImg () {
  75.         $.ajax({
  76.             url: 'https://api.flickr.com/services/feeds/photos_public.gne',
  77.             dataType: 'jsonp',
  78.             data: { "tags": "kittens", "format": "json" }
  79.         });
  80.     }
  81.  
  82.     $( document ).ready(function() {
  83.         getFlickerImg () ;
  84.         setInterval(getFlickerImg,10000);
  85.     });
  86.  
  87. </script>
  88. </body>
  89. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement