bartender.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. $(document).delegate( '.js-bartend', 'click', function () {
  2. $.ajax({
  3. url: '/ajax/bartender.php',
  4. data: {
  5. action: 'shake',
  6. dossier: $(this).data('dossier'),
  7. projetId: $(this).data('projet-id'),
  8. projetPadPrincipal: $(this).data('projet-pad-principal'),
  9. projetPadGarde: $(this).data('projet-pad-garde')
  10. },
  11. success: function (data) {
  12. if (data.status === 'error')
  13. alert('Bartender says: '+data.errors.join(' '));
  14. else
  15. setTimeout(status,1000);
  16. },
  17. error: function () {
  18. alert("Je n'ai pas pu contacter le barman pour presser le projet...");
  19. }
  20. });
  21. return false;
  22. });
  23. function status () {
  24. $('.js-status').each( function () {
  25. var statusdiv = $(this);
  26. $.ajax({
  27. url: '/ajax/bartender.php',
  28. data: {
  29. action: 'status',
  30. dossier: statusdiv.data('dossier'),
  31. projetId: statusdiv.data('projet-id')
  32. },
  33. success: function (data) {
  34. if (data.status === 'error') {
  35. alert('Bartender says: '+data.errors.join(' '));
  36. }
  37. statusdiv.find('.js-status-placeholder').text(data.status);
  38. statusdiv.find('.js-time-placeholder').text(data.time);
  39. if (data.status === 'IN_PROGRESS') // on relance la vérif de statut dans 3s pour voir si la compil est terminée
  40. setTimeout(status,3000);
  41. },
  42. error: function () {
  43. alert("Je n'ai pas pu contacter le barman pour le statut de compilation...");
  44. }
  45. });
  46. });
  47. }
  48. $(document).ready( function () {
  49. status();
  50. });