<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">$(document).ready(() =&gt; {
  const listenBookmark = () =&gt; {
    $('button.bookmark').on('click', function () {
      if (this) {
        const id = $(this).attr('data-id');
        const model = $(this).attr('data-model');
        $.ajax({
          url: "/favourite/process",
          method: "POST",
          data: {id, model},
        })
          .done((request) =&gt; {
            if (request) {
              const data = JSON.parse(request);
              if (data.action === 'push') {
                $(this).addClass("active");
                toastr.success('Р’С‹ РґРѕР±Р°РІРёР»Рё РјР°С‚РµСЂРёР°Р» РІ РёР·Р±СЂР°РЅРЅРѕРµ!');
              } else if (data.action === 'pull') {
                $(this).removeClass("active");
                toastr.success('Р’С‹ СѓР±СЂР°Р»Рё РјР°С‚РµСЂРёР°Р» РёР· РёР·Р±СЂР°РЅРЅРѕРіРѕ');
                if ($('#favoriteRefresh').length) {
                  $.pjax.reload({container: '#favoriteRefresh', timeout: false});
                }
              }
            }
          })
          .fail((e) =&gt; {
            console.log(e);
            toastr.warning('РќРµРѕР±С…РѕРґРёРјРѕ Р°РІС‚РѕСЂРёР·РѕРІР°С‚СЊСЃСЏ!');
          });
      }
    });
  };

  $(document).on('ready pjax:success', function () {
    listenBookmark()
  });

  listenBookmark();
});
</pre></body></html>