PageSourceSearch

https://www.accademiamoda.it/wp-content/themes/iuad-theme/src/js/custom/news-infinite-scroll.js?ver=1.0.0

js accademiamoda.it collected 2026-10-04 13:24:17 UTC 2,088 bytes, 79 lines download raw bytes

1jQuery(function ($) {
2  const $listing = $('[data-iuad-news-listing]')
3  if (!$listing.length) return
4
5  const $grid = $listing.find('[data-iuad-news-grid]')
6  const $sentinel = $listing.find('[data-iuad-news-sentinel]')
7
8  if (!$grid.length || !$sentinel.length) return
9
10  const cfg = (typeof window.iuadNewsInfinite !== 'undefined') ? window.iuadNewsInfinite : {}
11
12  let page = 1
13  let loading = false
14  let done = false
15
16  async function loadNext() {
17    if (loading || done) return
18    loading = true
19
20    try {
21      const form = new URLSearchParams()
22      form.set('action', 'iuad_load_more_news_infinite')
23      form.set('nonce', cfg.nonce || '')
24      form.set('page', String(page + 1))
25      form.set('lang', cfg.lang || '')
26
27      const res = await fetch(cfg.ajaxurl, {
28        method: 'POST',
29        headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
30        body: form.toString(),
31        credentials: 'same-origin'
32      })
33
34      const json = await res.json()
35      if (!json || !json.success || !json.data) {
36        done = true
37        return
38      }
39
40      if (json.data.html) {
41        $grid.append(json.data.html)
42      }
43
44      page = parseInt(json.data.page, 10) || (page + 1)
45      if (!json.data.has_more) {
46        done = true
47      }
48    } catch (e) {
49      // se fallisce, evitiamo loop infinito di richieste
50      done = true
51    } finally {
52      loading = false
53    }
54  }
55
56  if (!('IntersectionObserver' in window)) {
57    // fallback semplice: carica al primo scroll vicino al fondo
58    $(window).on('scroll', function () {
59      if (done || loading) return
60      const scrollBottom = window.scrollY + window.innerHeight
61      const docHeight = document.documentElement.scrollHeight
62      if (docHeight - scrollBottom < 600) {
63        loadNext()
64      }
65    })
66    return
67  }
68
69  const io = new IntersectionObserver((entries) => {
70    entries.forEach((entry) => {
71      if (entry.isIntersecting) {
72        loadNext()
73      }
74    })
75  }, { root: null, rootMargin: '800px 0px', threshold: 0 })
76
77  io.observe($sentinel.get(0))
78})
79

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.