github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/js/signed.js (about)

     1  ;(function($) {
     2      (function mLongPolling() {
     3          setTimeout(function() {
     4              var container;
     5              if (document.getElementById("mlist")) {
     6                  container = $("#mlist");
     7              } else {
     8                  return true;
     9              };
    10              $.ajax({
    11                  url: "/api/messages/",
    12                  success: function(data) {
    13                      var s = "";
    14                      if (data) {
    15                          $.each(data, function(idx, item) {
    16                              var avatar = "";
    17                              if (item.Avatar) {
    18                                  avatar = item.Avatar;
    19                              } else {
    20                                  avatar = '/identicon/' + item.Sender + '/100/default.png';
    21                              }
    22                              s = s + '<li class="list-group-item"><div class="clearfix"><a href="/user/' + item.Sender + '/" class="pull-left thumb-sm avatar b-3x m-r"><img src="' + avatar + '" class="img-circle"></a><small class="pull-right">' + jsDateDiff(item.Created) + '</small><div class="clear"><div class="h3 m-t-xs m-b-xs"><a href="/connect/' + item.Sender + '/">' + item.Sender + '</a> <i class="fa fa-circle text-success pull-right text-xs m-t-sm"></i></div><small class="text-muted">' + item.Content + '</small></div></div></li>';
    23                          });
    24                      } else {
    25                          s = '<li class="list-group-item"><div class="clearfix"><div class="clear"><div class="h3 m-t-xs m-b-xs">尚无消息</div><small class="text-muted">你尚未收到好友消息..</small></div></div></li>';
    26                      };
    27                      container.html(s);
    28                  },
    29                  dataType: "json",
    30                  complete: mLongPolling
    31              });
    32          }, 30000);
    33      })();
    34  })(jQuery);