Advertisement
orenchuck

Mimun Yashir reques cloud function

Nov 15th, 2022
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. //---------mob
  2.  
  3. <script>
  4. (function () {
  5. function triggerAdoricCarousel() {
  6. var titleContainer = document.querySelector('li.current');
  7. if (titleContainer) {
  8. var title = decodeURIComponent(window.title_param).trim();
  9. var dataSourceUrl = 'https://us-east4-adoric-production.cloudfunctions.net/Support_MimumYashir_dynamicCars?carTitle=' + title;
  10. try {
  11. var xhr = new XMLHttpRequest();
  12. var data = null;
  13. xhr.addEventListener('readystatechange', function () {
  14. if (this.readyState === 4) {
  15. var response = JSON.parse(this.responseText);
  16. if (response.length > 3) {
  17. sessionStorage.setItem('showCarsCarousel', this.responseText);
  18. window.adoric && adoric.trigger('showCarsCarousel');
  19. }
  20. }
  21. });
  22. xhr.open('GET', dataSourceUrl);
  23. xhr.send(JSON.stringify(data));
  24. } catch (error) {
  25. console.log('error ', error.message);
  26. }
  27. }
  28. }
  29.  
  30. if (document.readyState === 'loading') {
  31. document.addEventListener('DOMContentLoaded', triggerAdoricCarousel);
  32. } else {
  33. triggerAdoricCarousel();
  34. }
  35.  
  36. })();
  37. </script>
  38.  
  39.  
  40. //----------dt
  41.  
  42. <script>
  43. (function () {
  44. function triggerAdoricCarousel() {
  45. var titleContainer = document.querySelector('li.current a');
  46. if (titleContainer) {
  47. var title = titleContainer.title;
  48. var dataSourceUrl = 'https://us-east4-adoric-production.cloudfunctions.net/Support_MimumYashir_dynamicCars?carTitle=' + title;
  49. try {
  50. var xhr = new XMLHttpRequest();
  51. var data = null;
  52. xhr.addEventListener('readystatechange', function () {
  53. if (this.readyState === 4) {
  54. var response = JSON.parse(this.responseText);
  55. if (response.length > 3) {
  56. sessionStorage.setItem('showCarsCarousel', this.responseText);
  57. window.adoric && adoric.trigger('showCarsCarouselDT');
  58. }
  59. }
  60. });
  61. xhr.open('GET', dataSourceUrl);
  62. xhr.send(JSON.stringify(data));
  63. } catch (error) {
  64. console.log('error ', error.message);
  65. }
  66. }
  67. }
  68.  
  69. if (document.readyState === 'loading') {
  70. document.addEventListener('DOMContentLoaded', triggerAdoricCarousel);
  71. } else {
  72. triggerAdoricCarousel();
  73. }
  74. })();
  75. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement