最新の20件見たい

  • /*
     * @title 最新の20件見たい
     * @description Hatena::Letの最新20件を表示
     * @include http://*
     * @license MIT License
     * @require jQuery
     */
    
    (function() {
      var getItem = function(json) {
        return json.query.results.item.map(function(d) {
          return [d.title + ' by id:' + d.creator, d.link];
        });
      };
      var makeHTML = function(item) {
        var fragment = document.createDocumentFragment();
        var ul = document.createElement('ul');
        item.forEach(function(d) {
          var li = document.createElement('li');
          li.style.margin = '0';
          li.style.listStyle = 'none';
          var a = document.createElement('a');
          a.href = d[1];
          a.style.color = '#fff';
          var text = document.createTextNode(d[0]);
          a.appendChild(text);
          li.appendChild(a);
          ul.appendChild(li);
        });
        ul.style.position = 'fixed';
        ul.style.top = ul.style.left = '0';
        ul.style.margin = '0';
        ul.style.padding = '1em';
        ul.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
        fragment.appendChild(ul);
        document.body.appendChild(fragment);
      };
      $.ajax({
        url : "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D'http%3A%2F%2Flet.hatelabo.jp%2Frss'&format=json&diagnostics=true&callback=callback",
        dataType : 'jsonp',
        jsonpCallback : 'callback',
        success : function(json) {
          var items = getItem(json);
          makeHTML(items);
        }
      });
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2010/05/28 16:44:50 - 2010-05-28