Sha256: 75618e68de49cd80ccf829d239a1e78ef09e496880fe0f6ed57257f08b4bd673

Contents?: true

Size: 789 Bytes

Versions: 1

Compression:

Stored size: 789 Bytes

Contents

$(document).ready(function() {
  setInterval(updateTimes, 1000);
});

function updateTimes() {
  var timeRemainings = $(".ends-in")
  if (timeRemainings.length > 0) {
    $.each(timeRemainings, updateTime);
  }
}

function updateTime(_, element) {
  var $element = $(element);
  var currentDatetime = new Date();
  var auctionEndDatetime = $element.data("auction-end-datetime");
  if (currentDatetime > auctionEndDatetime) {
    var pretext = $element.siblings()[0];
    pretext.addClass("green");
    pretext.innerHTML = "Complete";
    $element.remove();
  } else {
    var countdownString = countdown(
      null,
      auctionEndDatetime,
      countdown.DAYS|countdown.HOURS|countdown.MINUTES|countdown.SECONDS,
      2
    ).toString();
  }
  element.innerHTML = countdownString;
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_auction-0.0.1 app/assets/javascripts/spree/ends_in.js