suivifilms2.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. console.log(chemin);
  48. if ($icone.attr('class') === couleurNeutre) {
  49. $icone.attr('class', couleurPasVu);
  50. $icone.next().attr('class', couleurNeutre);
  51. } else {
  52. $icone.attr('class', couleurNeutre);
  53. $icone.next().attr('class', couleurVu);
  54. }
  55. return;
  56. },
  57. complete: function () {
  58. }
  59. })
  60. })
  61. })
  62. }
  63. })(jQuery);