0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

特定ユーザーのQiita記事一覧を得る(4)

Last updated at Posted at 2021-09-18

前回の記事のアップデートです。
記事を作成日時でソートするようにしました。
増えてきた自分の記事を検索するのにも役立ちます。

動作デモ
前回同様ローカル環境でも動作します。

[更新部分]

    var ALL_DISP_TAG = 'All';

    function dispData(_resArr,_tag=""){
      createButtons(_resArr,_tag);
      var articles = [];
      for(var i=0;i<_resArr.length;++i){
        if((_tag=="")||(_tag==ALL_DISP_TAG)||(articleContainsTag(_resArr[i],_tag))){
          var tmpStr = '<a href="'+_resArr[i]['url']+'" target="_blank">'+ _resArr[i]['title']+'</a><br/>';
          articles.push({'title':tmpStr, 'created_at':_resArr[i]['created_at']});
        }
      }
      articles.sort(function(a,b){ return ( a.created_at < b.created_at ) ? 1 : -1; });

      var str="";
      for(var i=0;i<articles.length;++i)
        str += articles[i]['created_at']+" "+articles[i]['title'];

      document.getElementById('iResult').innerHTML = str;
    }

結果:
image.png

作成日時ではなくアップデート日時ソートしたい場合は
created_at を updated_at にします。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?