(function() {
  var UpdateStatus;

  UpdateStatus = (function() {

    function UpdateStatus() {
      this.date = "#contents .tableWrapper table .date";
      this.beforeSpan = 60;
      this.newIcon = '<span class="newmark"><img src="/images/common/icon_new.gif" /></span>';
      this.updateIcon = '<span class="updatemark"><img src="/images/common/icon_up.gif" /></span>';
      this.specialIcon = '<span class="special"><img src="/images/common/icon_recommend.gif" /></span>';
      this.updateAfterString = "<span>更新</span>";
    }

    UpdateStatus.prototype.status = function() {
      var before, beforeString, beforeTime, now, nowTime, twoMonthTime, updateAfterString, updatedate, updatedateString,
        _this = this;
      now = new Date();
      nowTime = now.getTime();
      twoMonthTime = 1000 * 60 * 60 * 24 * this.beforeSpan;
      beforeTime = nowTime - twoMonthTime;
      before = new Date();
      before.setTime(beforeTime);
      beforeString = this.stringByDate(before);
      $(this.date).each(function(i) {
        var d;
        d = $(_this.date).eq(i);
        return d.parent().append(_this.specialIcon);
      });
      $(this.date).find(".created").each(function(i) {
        var d, text;
        d = $(_this.date).find(".created").eq(i);
        text = d.text();
        if (text > beforeString) {
          d.parent().parent().find(".special").remove();
          return d.parent().parent().append(_this.newIcon);
        }
      });
      $(this.date).find(".updated").each(function(i) {
        var d, text;
        d = $(_this.date).find(".updated").eq(i);
        text = d.text();
        if (text > beforeString) {
          d.parent().parent().find(".special").remove();
          return d.parent().parent().append(_this.updateIcon);
        }
      });
      $("td").has(".newmark").has(".updatemark").each(function(i) {
        var d;
        d = $("td").has(".newmark").has(".updatemark").eq(i);
        return d.find(".newmark").css({
          "display": "none"
        });
      });
      updatedate = now;
      updatedate.setDate(1);
      updatedateString = this.stringByDate(updatedate);
      updateAfterString = this.updateAfterString;
      return $(this.date).each(function(i) {
        var created, current, datetext, td, updated, _ref, _ref2;
        td = $(this).parent();
        updated = (_ref = td.find(".updated")) != null ? _ref.text() : void 0;
        created = (_ref2 = td.find(".created")) != null ? _ref2.text() : void 0;
        current = updatedateString;
        if (updated > updatedateString) {
          current = updated;
        } else if (created > updatedateString) {
          current = created;
        }
        datetext = current.replace(/([0-9]{4})([0-9]{2})([0-9]{2})/, "$1.$2.$3");
        return td.append("<span>" + datetext + "</span>" + updateAfterString);
      });
    };

    UpdateStatus.prototype.stringByDate = function(date) {
      var dd, mm, yy;
      yy = date.getYear();
      mm = date.getMonth() + 1;
      dd = date.getDate();
      if (yy < 2000) yy += 1900;
      if (mm < 10) mm = "0" + mm;
      if (dd < 10) dd = "0" + dd;
      return "" + yy + mm + dd;
    };

    return UpdateStatus;

  })();

  $(document).ready(function() {
    var status;
    status = new UpdateStatus();
    return status.status();
  });

}).call(this);

