Guest User

Untitled

a guest
Jan 17th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. <li> Рейтинг КиноПоиска: <strong><span class="data-film-text" id="kp-page-rating">загрузка...</span></strong></li>
  2. <li> Рейтинг IMDb: <strong><span class="data-film-text" id="imdb-page-rating">загрузка...</span></strong></li>
  3. <script>
  4. var KP_SITE_ID = 737543;
  5. var getFilmRatingDataPAGE = function getFilmRatingDataPAGE(
  6. element,
  7. idt,
  8. callback
  9. ) {
  10. var id = element ? element.data("filmid") : idt;
  11. $.ajax({
  12. method: "GET",
  13. url:
  14. "https://cors-anywhere.herokuapp.com/https://rating.kinopoisk.ru/" +
  15. id +
  16. ".xml",
  17. success: function success(data) {
  18. callback(element, data);
  19. },
  20. error: function error() {
  21. $.ajax({
  22. url: "http://query.yahooapis.com/v1/public/yql",
  23. jsonp: "callback",
  24. dataType: "jsonp",
  25. data: {
  26. q:
  27. 'select * from xml where url="https://rating.kinopoisk.ru/' +
  28. id +
  29. '.xml"',
  30. format: "xml"
  31. },
  32. success: function success(data) {
  33. if (data.results[0]) {
  34. callback(element, data.results[0]);
  35. }
  36. }
  37. });
  38. }
  39. });
  40. };
  41. var renderFilmPageRatingDataPAGE = function(element, data) {
  42. $("#kp-page-rating")
  43. .text(
  44. $(data)
  45. .find("kp_rating")
  46. .text()
  47. )
  48. .prop(
  49. "title",
  50. "Голосов: " +
  51. $(data)
  52. .find("kp_rating")
  53. .attr("num_vote")
  54. .replace(/(d)(?=(d{3})+$)/g, "$1 ")
  55. );
  56. $("#imdb-page-rating")
  57. .text(
  58. $(data)
  59. .find("imdb_rating")
  60. .text()
  61. )
  62. .prop(
  63. "title",
  64. "Голосов: " +
  65. $(data)
  66. .find("imdb_rating")
  67. .attr("num_vote")
  68. .replace(/(d)(?=(d{3})+$)/g, "$1 ")
  69. );
  70. };
  71. if (KP_SITE_ID) {
  72. getFilmRatingDataPAGE(false, KP_SITE_ID, renderFilmPageRatingDataPAGE);
  73. }
  74. </script>
Add Comment
Please, Sign In to add comment