Latkoski

Untitled

Dec 21st, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.85 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  3.     <head>
  4.         <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  5.         <title>My music</title>
  6.         <link rel="stylesheet" href="style.css" type="text/css" />
  7.         <script type="text/javascript" src="jquery-1.8.3.min.js"></script>
  8.         <script type="text/javascript" src="jquery.tablesorter.js"></script>
  9.         <script type="text/javascript" src="jquery.editinplace.js"></script>
  10.         <script type='text/javascript'>
  11.        
  12.        
  13.         getEntries();
  14.            
  15.                 function getEntries(){
  16.                    
  17.                     $.ajax({
  18.                         //url: "http://gdata.youtube.com/feeds/api/playlists/PL48A83AD3506C9D36?v=2&alt=json",
  19.                         url: "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=PL48A83AD3506C9D36&key=AIzaSyAyvig5VkfPt_lBR4sFl-ajsULtgUHmTwA",
  20.                         dataType: "jsonp",
  21.                        
  22.                         success: function (data) {
  23.                             var video_id="";
  24.                             $.each(data.items, function (i,item) {
  25.                                 video_id = video_id + item.snippet.resourceId.videoId + ',';
  26.                             });
  27.                             video_id = video_id.substring(0, video_id.length - 1);
  28.                             console.log(video_id);
  29.                             $.ajax({
  30.                                 url: "https://www.googleapis.com/youtube/v3/videos?part=contentDetails%2Cstatistics%2Csnippet%2Cplayer&id=" + video_id + "&key=AIzaSyAyvig5VkfPt_lBR4sFl-ajsULtgUHmTwA",
  31.                                 dataType: "jsonp",
  32.                                
  33.                                 success: function (data) {
  34.                                     $.each(data.items, function (i,item) {
  35.                                         var title = item.snippet.title;
  36.                                         var thumb = item.snippet.thumbnails.default.url;
  37.                                         var numLikes = item.statistics.likeCount;
  38.                                         var numDislikes = item.statistics.dislikeCount;
  39.                                         var viewCount = item.statistics.viewCount;
  40.                                        
  41.                                         $('#entries tbody').append("<tr><td id='editinplace'>" + title + "</td> <td><img alt='"+ title+ "' src='"+ thumb +"'></img></td><td>" + numLikes + "</td><td>" + numDislikes + "</td><td>" + viewCount + "</td>" + "<td style='display: none' id='delete'><input type='button' class='del' value='Избриши'/></td>" +"</tr>");
  42.                                     });
  43.                                     $("table").trigger("update");
  44.                                     setEditInPlace();
  45.                                 }  
  46.                             });
  47.                            
  48.                             $("table").trigger("update");
  49.                             setEditInPlace();
  50.                         }  
  51.                     });
  52.                
  53.                  }
  54.                  
  55.                  
  56.                  setEditInPlace();
  57.                  function setEditInPlace()
  58.                     {
  59.                         $("td").each(function() {
  60.                             var id = $(this).attr("id");
  61.                             if (id == 'editinplace'){
  62.                                 $(this).editInPlace({
  63.                                     callback: function(unused, enteredText) { return enteredText; },
  64.                                     show_buttons: true
  65.                                 });
  66.                             }
  67.                         });
  68.                     }
  69.             $(document).ready(function(){
  70.            
  71.            
  72.            
  73.            
  74.                 $("#entries").tablesorter();
  75.                
  76.                 $("#edit").click(function() {
  77.                     var text = $("#edit").val();
  78.                     if (text == 'Измени')
  79.                     {
  80.                         $("#edit").val('Затвори');
  81.                         $("td").each(function() {
  82.                             var id = $(this).attr("id");
  83.                             if (id == 'delete') $(this).show('slow');
  84.                         });
  85.                     }
  86.                     else
  87.                     {
  88.                         $("#edit").val('Измени');
  89.                         $("td").each(function() {
  90.                             var id = $(this).attr("id");
  91.                             if (id == 'delete') $(this).hide('slow');
  92.                         });
  93.                     }
  94.                 });
  95.                 $('.del').live('click',function(){
  96.                         $(this).parent().parent().remove();
  97.                         $("#entries").trigger("update");
  98.                 });
  99.             });
  100.         </script>
  101.     </head>
  102.  
  103.     <body>
  104.     <h1>My music</h1>
  105.  
  106.     <table id="entries" class="tablesorter" border="0" cellpadding="5" cellspacing="10">
  107.         <thead>
  108.             <tr>
  109.                 <th>Title</th>
  110.                 <th>Image</th>
  111.                 <th>No. of likes</th>
  112.                 <th>No. of dislikes</th>
  113.                 <th>View count</th>
  114.                 <th><input type="button" id="edit" value="Измени" /></th>
  115.             </tr>
  116.         </thead>
  117.         <tbody>
  118.            
  119.         </tbody>
  120.     </table>
  121.    
  122.     </body>
Advertisement
Add Comment
Please, Sign In to add comment