const $ = require('jquery');
class CarusoBasket {
  constructor() {
    this.updateCarusoBasket();
  }

  updateCarusoBasket() {
    const $basketElem = $(".caruso-basket");
    const carusoJsonUrl = $basketElem.data("carusobasketjson");

    $.getJSON(carusoJsonUrl, {
        _: new Date().getTime()
      },
      function (data) {
        if (data.warenkorb && data.warenkorb.anzahl) {
          $basketElem.html(
            "<sup>" + data.warenkorb.anzahl
            + "</sup>");
        }
      });

  }
}

  $('.caruso-basket').each(function () {
    new CarusoBasket();
  });


