heartbeat.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * Created by logicp on 5/28/17.
  3. */
  4. (function($, Drupal, drupalSettings) {
  5. Drupal.behaviors.heartbeat = {
  6. attach: function (context, settings) {
  7. Drupal.AjaxCommands.prototype.selectFeed = function(ajax, response, status) {
  8. console.log(response.feed);
  9. console.dir(drupalSettings);
  10. console.dir(context);
  11. console.dir(settings);
  12. $.ajax({
  13. type:'POST',
  14. url:'/heartbeat/render_feed/' + response.feed,
  15. success: function(response) {
  16. // feedElement = document.getElementById('block-heartbeatblock');
  17. feedElement = document.querySelector('.heartbeat-stream');
  18. feedElement.innerHTML = response;
  19. console.dir(feedElement);
  20. console.dir(response);
  21. }
  22. });
  23. // #block-heartbeatblock
  24. }
  25. Drupal.AjaxCommands.prototype.updateFeed = function(ajax, response, status) {
  26. feed = response.feed;
  27. timestamp = response.timestamp;
  28. }
  29. }
  30. }
  31. })(jQuery, Drupal, drupalSettings);