Header Ads Widget

Responsive Advertisement
Loading Recent Posts...

bkeafbbjukv

<!-- Outer Structural Wrapper for Page Margins and Spacing -->
<div class="custom-slider-layout-wrapper">

  <!-- Slider Styles -->
  <style>
    :root {
      --primary-color: #ff5722;
      --text-dark: #333333;
    }
    
    .custom-slider-layout-wrapper {
      max-width: 1200px;
      width: 100%;
      margin: 25px auto 0 auto;
      padding: 0 15px;
      box-sizing: border-box;
    }

    .custom-slider-container {
      position: relative;
      width: 100%;
      height: 420px;
      background: #ffffff;
      overflow: hidden;
      border-radius: 4px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }
    .custom-slider-wrapper {
      display: flex;
      width: 500%;
      height: 100%;
      transition: transform 0.5s ease-in-out;
    }
    .custom-slide {
      width: 20%;
      height: 100%;
      position: relative;
    }
    .custom-slide img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .custom-slide-content {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
      color: #ffffff;
      padding: 35px 25px;
    }
    .custom-slide-content a {
      color: #ffffff;
      text-decoration: none;
    }
    .custom-slide-content a:hover {
      text-decoration: underline;
    }
    .custom-tag {
      display: inline-block;
      background-color: var(--primary-color);
      color: #ffffff;
      padding: 4px 10px;
      font-size: 11px;
      font-weight: bold;
      text-transform: uppercase;
      border-radius: 3px;
      margin-bottom: 10px;
      letter-spacing: 1px;
    }
    .custom-slide-title {
      font-size: 24px;
      margin-bottom: 8px;
      font-weight: 600;
    }
    .custom-slide-desc {
      font-size: 14px;
      color: #e0e0e0;
      line-height: 1.4;
    }
    .custom-nav-btn {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      background-color: rgba(255, 255, 255, 0.85);
      border: none;
      width: 45px;
      height: 45px;
      border-radius: 50%;
      cursor: pointer;
      font-size: 20px;
      color: var(--text-dark);
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 2px 8px rgba(0,0,0,0.2);
      transition: background 0.3s, color 0.3s;
      z-index: 10;
    }
    .custom-nav-btn:hover {
      background-color: var(--primary-color);
      color: #ffffff;
    }
    .custom-prev { left: 20px; }
    .custom-next { right: 20px; }
    .custom-dots-container {
      position: absolute;
      bottom: 20px;
      right: 25px;
      display: flex;
      gap: 8px;
      z-index: 10;
    }
    .custom-dot {
      width: 10px;
      height: 10px;
      background-color: rgba(255, 255, 255, 0.4);
      border-radius: 50%;
      cursor: pointer;
      transition: background-color 0.3s, transform 0.3s;
    }
    .custom-dot.active {
      background-color: var(--primary-color);
      transform: scale(1.2);
    }
    
    /* Loading Spinner Styling */
    .slider-loading {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100%;
      font-size: 16px;
      color: #666;
    }
  </style>

  <!-- Slider Containers (Populated Dynamically via JavaScript) -->
  <div class="custom-slider-container" id="sliderMainContainer">
    <div class="slider-loading">Loading Recent Posts...</div>
  </div>

</div>

<!-- Automated Feeds Logic -->
<script>
  (function() {
    // 1. Fetch JSON data from your site feed directly
    fetch('/feeds/posts/default?alt=json&max-results=5')
      .then(response => response.json())
      .then(data => {
        const entries = data.feed.entry || [];
        if (entries.length === 0) {
          document.getElementById('sliderMainContainer').innerHTML = '<div class="slider-loading">No posts found.</div>';
          return;
        }

        // 2. Setup internal markup shells
        let slidesHtml = '<div class="custom-slider-wrapper" id="customSliderWrapper">';
        let dotsHtml = '<div class="custom-dots-container" id="customDotsContainer">';

        entries.forEach((entry, idx) => {
          // Parse post title
          const title = entry.title.$t;
          
          // Parse post canonical link address URL
          let postUrl = '';
          for (let i = 0; i < entry.link.length; i++) {
            if (entry.link[i].rel === 'alternate') {
              postUrl = entry.link[i].href;
              break;
            }
          }

          // Parse image thumbnail thumbnail attachments or fallback if empty
          let imgSrc = 'https://unsplash.com';
          if (entry.media$thumbnail) {
            // Converts tiny Blogger thumbnail address to high-resolution original image scaling width standard 
            imgSrc = entry.media$thumbnail.url.replace('/s72-c/', '/s1600/');
            imgSrc = imgSrc.replace('-c/', '/');
          } else if (entry.content && entry.content.$t) {
            // Backup parser check to search inside post body contents string directly for images
            const imgMatch = entry.content.$t.match(/<img[^>]+src="([^">]+)"/);
            if (imgMatch && imgMatch[1]) imgSrc = imgMatch[1];
          }

          // Parse snippet text values summaries 
          let summary = '';
          if (entry.summary && entry.summary.$t) {
            summary = entry.summary.$t.substring(0, 140) + '...';
          } else if (entry.content && entry.content.$t) {
            summary = entry.content.$t.replace(/<[^>]*>/g, '').substring(0, 140) + '...';
          }

          // Generate item elements structures string templates 
          slidesHtml += `
            <div class="custom-slide">
              <img src="${imgSrc}" alt="${title}">
              <div class="custom-slide-content">
                <span class="custom-tag">Recent</span>
                <h2 class="custom-slide-title"><a href="${postUrl}">${title}</a></h2>
                <p class="custom-slide-desc">${summary}</p>
              </div>
            </div>`;

          dotsHtml += `<div class="custom-dot ${idx === 0 ? 'active' : ''}" data-idx="${idx}"></div>`;
        });

        slidesHtml += '</div>';
        dotsHtml += '</div>';

        // 3. Inject full markup array strings directly inside main target component nodes
        const mainContainer = document.getElementById('sliderMainContainer');
        mainContainer.innerHTML = `
          ${slidesHtml}
          <button class="custom-nav-btn custom-prev" id="customPrevBtn">&#10094;</button>
          <button class="custom-nav-btn custom-next" id="customNextBtn">&#10095;</button>
          ${dotsHtml}
        `;

        // Initialize engine tracking variables loops controls handlers 
        initializeSliderEngine(entries.length);
      })
      .catch(err => {
        console.error("Error loading Blogger feed scripts: ", err);
        document.getElementById('sliderMainContainer').innerHTML = '<div class="slider-loading">Error loading posts slider layout elements.</div>';
      });

    // 4. Structural slider loops interaction handling animations block routines
    function initializeSliderEngine(totalSlides) {
      const wrapper = document.getElementById('customSliderWrapper');
      const prevBtn = document.getElementById('customPrevBtn');
      const nextBtn = document.getElementById('customNextBtn');
      const dots = document.querySelectorAll('.custom-dot');

      let currentIndex = 0;
      let autoSlideInterval;

      function updateSliderPosition() {
        wrapper.style.transform = `translateX(-${currentIndex * (100 / totalSlides)}%)`;
        dots.forEach((dot, idx) => {
          dot.classList.toggle('active', idx === currentIndex);
        });
      }

      function goToSlide(index) {
        currentIndex = index;
        updateSliderPosition();
        resetAutoSlide();
      }

      function nextSlide() {
        currentIndex = (currentIndex + 1) % totalSlides;
        updateSliderPosition();
      }

      function prevSlide() {
        currentIndex = (currentIndex - 1 + totalSlides) % totalSlides;
        updateSliderPosition();
      }

      nextBtn.addEventListener('click', () => { nextSlide(); resetAutoSlide(); });
      prevBtn.addEventListener('click', () => { prevSlide(); resetAutoSlide(); });
      
      dots.forEach(dot => {
        dot.addEventListener('click', (e) => {
          const idx = parseInt(e.target.getAttribute('data-idx'));
          goToSlide(idx);
        });
      });

      function startAutoSlide() { autoSlideInterval = setInterval(nextSlide, 5000); }
      function resetAutoSlide() { clearInterval(autoSlideInterval); startAutoSlide(); }

      startAutoSlide();
    }
  })();
</script>
<!-- Outer Structural Wrapper for Page Margins and Spacing -->
<div class="custom-slider-layout-wrapper">

  <!-- Slider Styles -->
  <style>
    :root {
      --primary-color: #ff5722;
      --text-dark: #333333;
    }
    
    .custom-slider-layout-wrapper {
      max-width: 1200px;
      width: 100%;
      margin: 25px auto 0 auto;
      padding: 0 15px;
      box-sizing: border-box;
    }

    .custom-slider-container {
      position: relative;
      width: 100%;
      height: 420px;
      background: #ffffff;
      overflow: hidden;
      border-radius: 4px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }
    .custom-slider-wrapper {
      display: flex;
      width: 500%;
      height: 100%;
      transition: transform 0.5s ease-in-out;
    }
    .custom-slide {
      width: 20%;
      height: 100%;
      position: relative;
    }
    .custom-slide img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
    .custom-slide-content {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
      color: #ffffff;
      padding: 35px 25px;
    }
    .custom-slide-content a {
      color: #ffffff;
      text-decoration: none;
    }
    .custom-slide-content a:hover {
      text-decoration: underline;
    }
    .custom-tag {
      display: inline-block;
      background-color: var(--primary-color);
      color: #ffffff;
      padding: 4px 10px;
      font-size: 11px;
      font-weight: bold;
      text-transform: uppercase;
      border-radius: 3px;
      margin-bottom: 10px;
      letter-spacing: 1px;
    }
    .custom-slide-title {
      font-size: 24px;
      margin-bottom: 8px;
      font-weight: 600;
    }
    .custom-slide-desc {
      font-size: 14px;
      color: #e0e0e0;
      line-height: 1.4;
    }
    .custom-nav-btn {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      background-color: rgba(255, 255, 255, 0.85);
      border: none;
      width: 45px;
      height: 45px;
      border-radius: 50%;
      cursor: pointer;
      font-size: 20px;
      color: var(--text-dark);
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 2px 8px rgba(0,0,0,0.2);
      transition: background 0.3s, color 0.3s;
      z-index: 10;
    }
    .custom-nav-btn:hover {
      background-color: var(--primary-color);
      color: #ffffff;
    }
    .custom-prev { left: 20px; }
    .custom-next { right: 20px; }
    .custom-dots-container {
      position: absolute;
      bottom: 20px;
      right: 25px;
      display: flex;
      gap: 8px;
      z-index: 10;
    }
    .custom-dot {
      width: 10px;
      height: 10px;
      background-color: rgba(255, 255, 255, 0.4);
      border-radius: 50%;
      cursor: pointer;
      transition: background-color 0.3s, transform 0.3s;
    }
    .custom-dot.active {
      background-color: var(--primary-color);
      transform: scale(1.2);
    }
    
    /* Loading Spinner Styling */
    .slider-loading {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100%;
      font-size: 16px;
      color: #666;
    }
  </style>

  <!-- Slider Containers (Populated Dynamically via JavaScript) -->
  <div class="custom-slider-container" id="sliderMainContainer">
    <div class="slider-loading">Loading Recent Posts...</div>
  </div>

</div>

<!-- Automated Feeds Logic -->
<script>
  (function() {
    // 1. Fetch JSON data from your site feed directly
    fetch('/feeds/posts/default?alt=json&max-results=5')
      .then(response => response.json())
      .then(data => {
        const entries = data.feed.entry || [];
        if (entries.length === 0) {
          document.getElementById('sliderMainContainer').innerHTML = '<div class="slider-loading">No posts found.</div>';
          return;
        }

        // 2. Setup internal markup shells
        let slidesHtml = '<div class="custom-slider-wrapper" id="customSliderWrapper">';
        let dotsHtml = '<div class="custom-dots-container" id="customDotsContainer">';

        entries.forEach((entry, idx) => {
          // Parse post title
          const title = entry.title.$t;
          
          // Parse post canonical link address URL
          let postUrl = '';
          for (let i = 0; i < entry.link.length; i++) {
            if (entry.link[i].rel === 'alternate') {
              postUrl = entry.link[i].href;
              break;
            }
          }

          // Parse image thumbnail thumbnail attachments or fallback if empty
          let imgSrc = 'https://unsplash.com';
          if (entry.media$thumbnail) {
            // Converts tiny Blogger thumbnail address to high-resolution original image scaling width standard 
            imgSrc = entry.media$thumbnail.url.replace('/s72-c/', '/s1600/');
            imgSrc = imgSrc.replace('-c/', '/');
          } else if (entry.content && entry.content.$t) {
            // Backup parser check to search inside post body contents string directly for images
            const imgMatch = entry.content.$t.match(/<img[^>]+src="([^">]+)"/);
            if (imgMatch && imgMatch[1]) imgSrc = imgMatch[1];
          }

          // Parse snippet text values summaries 
          let summary = '';
          if (entry.summary && entry.summary.$t) {
            summary = entry.summary.$t.substring(0, 140) + '...';
          } else if (entry.content && entry.content.$t) {
            summary = entry.content.$t.replace(/<[^>]*>/g, '').substring(0, 140) + '...';
          }

          // Generate item elements structures string templates 
          slidesHtml += `
            <div class="custom-slide">
              <img src="${imgSrc}" alt="${title}">
              <div class="custom-slide-content">
                <span class="custom-tag">Recent</span>
                <h2 class="custom-slide-title"><a href="${postUrl}">${title}</a></h2>
                <p class="custom-slide-desc">${summary}</p>
              </div>
            </div>`;

          dotsHtml += `<div class="custom-dot ${idx === 0 ? 'active' : ''}" data-idx="${idx}"></div>`;
        });

        slidesHtml += '</div>';
        dotsHtml += '</div>';

        // 3. Inject full markup array strings directly inside main target component nodes
        const mainContainer = document.getElementById('sliderMainContainer');
        mainContainer.innerHTML = `
          ${slidesHtml}
          <button class="custom-nav-btn custom-prev" id="customPrevBtn">&#10094;</button>
          <button class="custom-nav-btn custom-next" id="customNextBtn">&#10095;</button>
          ${dotsHtml}
        `;

        // Initialize engine tracking variables loops controls handlers 
        initializeSliderEngine(entries.length);
      })
      .catch(err => {
        console.error("Error loading Blogger feed scripts: ", err);
        document.getElementById('sliderMainContainer').innerHTML = '<div class="slider-loading">Error loading posts slider layout elements.</div>';
      });

    // 4. Structural slider loops interaction handling animations block routines
    function initializeSliderEngine(totalSlides) {
      const wrapper = document.getElementById('customSliderWrapper');
      const prevBtn = document.getElementById('customPrevBtn');
      const nextBtn = document.getElementById('customNextBtn');
      const dots = document.querySelectorAll('.custom-dot');

      let currentIndex = 0;
      let autoSlideInterval;

      function updateSliderPosition() {
        wrapper.style.transform = `translateX(-${currentIndex * (100 / totalSlides)}%)`;
        dots.forEach((dot, idx) => {
          dot.classList.toggle('active', idx === currentIndex);
        });
      }

      function goToSlide(index) {
        currentIndex = index;
        updateSliderPosition();
        resetAutoSlide();
      }

      function nextSlide() {
        currentIndex = (currentIndex + 1) % totalSlides;
        updateSliderPosition();
      }

      function prevSlide() {
        currentIndex = (currentIndex - 1 + totalSlides) % totalSlides;
        updateSliderPosition();
      }

      nextBtn.addEventListener('click', () => { nextSlide(); resetAutoSlide(); });
      prevBtn.addEventListener('click', () => { prevSlide(); resetAutoSlide(); });
      
      dots.forEach(dot => {
        dot.addEventListener('click', (e) => {
          const idx = parseInt(e.target.getAttribute('data-idx'));
          goToSlide(idx);
        });
      });

      function startAutoSlide() { autoSlideInterval = setInterval(nextSlide, 5000); }
      function resetAutoSlide() { clearInterval(autoSlideInterval); startAutoSlide(); }

      startAutoSlide();
    }
  })();
</script>

Post a Comment

0 Comments