PHP & JavaScript Room :: 設置サンプル

実行結果

設置サンプル

指定したユーザーのvimeo動画リストを取得して表示

参照:oEmbed API

設置サンプルのソース

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Language" content="ja" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta http-equiv="imagetoolbar" content="no" />
      <title>設置サンプル</title>
      <link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
      <script type="text/javascript">
          $(function() {
             $.getJSON(
                 "http://vimeo.com/api/v2/user5750510/videos.json?callback=?",
               function(data) {
                   $('#load').fadeOut();
                   $.each(data, function(i,item){
                      var s='';
                      s+='<dt><a href="http://vimeo.com/'+item.id+'"><img src="'+item.thumbnail_small+'" /></a></dt>';
                      s+='<dd>';
                      s+='<div class="title"><img src="'+item.user_portrait_small+'" />&nbsp;<a href="http://vimeo.com/'+item.id+'">'+item.title+'</a> by <a href="/'+item.user_url+'">'+item.user_name+'</a></div>';
                      s+='<p>説明文:'+item.description+'</p>';
                         s+='<p>';
                         s+='公開日:'+formatDate(item.upload_date)+'|';
                         s+='お気入り登録数:'+addFigure(item.stats_number_of_likes)+'回|';
                         s+='コメント数:'+addFigure(item.stats_number_of_comments)+'回|';
                         s+='再生回数:'+addFigure(item.stats_number_of_plays)+'回';
                      s+='</p>';
                         s+='<p>';
                         s+='タグ:'+item.tags+'px|';
                         s+='動画の幅:'+item.width+'px|';
                         s+='動画の高さ:'+item.height+'px';
                      s+='</p>';
                      s+='</dd>';
                       $("#demo").append('<dl class="video cf">'+s+'</dl>');
                       $(".video").fadeIn(1000);
                   });
               }
            );
         });
         /* 日付フォーマット */
         var formatDate = function(dateString) {
            var d = new Date(dateString);
            var day = d.getDate();
            var month = d.getMonth()+1;
            var year = d.getFullYear();
            return year+"年"+month+"月"+day+"日";
         }
         /* 3桁区切り */
         function addFigure(str) {
            var num = new String(str).replace(/,/g, "");
            while(num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
            return num;
         }
      </script>
      <!-- CSS -->
      <style type="text/css">
         img{
            vertical-align:middle;
         }
         #demo {
            margin:0; padding:0;
         }
         #demo dl {
            margin:5px 0; padding:0;
            clear:both;
         }
         #demo dt {
            margin:0; padding:3px;
            width:100px; height:75px;
            -webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;
            border:1px solid #ccc;
            float:left;
            clear:both;
            overflow:hidden;
         }
         #demo dt img {
            overflow:hidden;
            width:100px; height:75px;
         }
         #demo dd {
            margin:0 0 0 120px; padding:0;
         }
         #demo dd p {
            margin:3px 0; padding:0;
            font-size:80%;
         }
         #demo dd div.title {
            font-size:110%;
            font-weight:bold;
         }
         #demo dd span {
            color:#ff6699;
            font-weight:bold;
         }
      </style>
   <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
   <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP &amp; JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
      <div id="wrap">
         <h1>設置サンプル</h1>
         <h2>指定したユーザーのvimeo動画リストを取得して表示</h2>
         <p>参照:<a href='http://vimeo.com/api/docs/oembed'>oEmbed API</a></p>
<!-- CODE -->
<div id="load"><img src='/content/img/ajax/loadingIcon.gif'></div>
<div id="demo"></div>
<!-- / CODE -->
      </div>
   </body>
</html>