Sha256: 901703bb27c0717d9cb042f00ffb5237921fd54f6c40c59b8fb29b87685764a5

Contents?: true

Size: 786 Bytes

Versions: 4

Compression:

Stored size: 786 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.html("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

4 entries across 4 versions & 1 rubygems

Version Path
solidus_auction-0.0.6 app/assets/javascripts/spree/ends_in.js
solidus_auction-0.0.5 app/assets/javascripts/spree/ends_in.js
solidus_auction-0.0.4 app/assets/javascripts/spree/ends_in.js
solidus_auction-0.0.3 app/assets/javascripts/spree/ends_in.js