suivifilms2.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. (function ($) {
  2. $.fn.follow = function () {
  3. this.each(function() {
  4. $(this).click(function(e) {
  5. e.preventDefault();
  6. let $icone = $(this).children('i');
  7. let contenu = $(this).data('content');
  8. let iconeEtatUn = $(this).data('icactif');
  9. let iconeEtatDeux = $(this).data('icinactif');
  10. let chemin = $(this).data('path');
  11. $.ajax({
  12. type: 'POST',
  13. url: chemin,
  14. data: 'id_film=' + contenu,
  15. success: function (data) {
  16. console.log(chemin);
  17. if ($icone.attr('class') === iconeEtatUn) {
  18. $icone.attr('class', iconeEtatDeux);
  19. } else {
  20. $icone.attr('class', iconeEtatUn);
  21. }
  22. return;
  23. },
  24. complete: function () {
  25. }
  26. })
  27. })
  28. })
  29. }
  30. })(jQuery);
  31. (function ($) {
  32. $.fn.seen = function () {
  33. this.each(function() {
  34. $(this).click(function(e) {
  35. e.preventDefault();
  36. let $icone = $(this).children('i');
  37. let contenu = $(this).data('content');
  38. let couleurNeutre = $(this).data('neutre');
  39. let couleurVu = $(this).data('vu');
  40. let couleurPasVu = $(this).data('pasvu');
  41. let chemin = $(this).data('path');
  42. $.ajax({
  43. type: 'POST',
  44. url: chemin,
  45. data: 'id_film=' + contenu,
  46. success: function (data) {
  47. if ($icone.attr('class') === couleurNeutre) {
  48. $icone.attr('class', couleurPasVu);
  49. $icone.next().attr('class', couleurNeutre);
  50. } else {
  51. $icone.attr('class', couleurNeutre);
  52. $icone.next().attr('class', couleurVu);
  53. }
  54. return;
  55. },
  56. complete: function () {
  57. }
  58. })
  59. })
  60. })
  61. }
  62. })(jQuery);