← back to Tradity-hunivers__Couverture

Function bodies 16 total

All specs Real LLM only Function bodies
closeBanner function · javascript · L128-L134 (7 LOC)
cookies.js
  function closeBanner(choice) {
    localStorage.setItem('cookie_consent', choice);
    banner.style.transform = 'translateY(100%)';
    setTimeout(function() {
      if (banner.parentNode) banner.parentNode.removeChild(banner);
    }, 500);
  }
applyMobile function · javascript · L141-L161 (21 LOC)
cookies.js
  function applyMobile(e) {
    if (e.matches) {
      inner.style.flexDirection = 'column';
      inner.style.padding = '1.25rem 1.25rem';
      inner.style.margin = '0 .75rem 1rem';
      text.style.flex = '1 1 auto';
      text.style.fontSize = '.875rem';
      btns.style.width = '100%';
      acceptBtn.style.flex = '1';
      refuseBtn.style.flex = '1';
    } else {
      inner.style.flexDirection = '';
      inner.style.padding = '1.5rem 2rem';
      inner.style.margin = '0 auto 1.25rem';
      text.style.flex = '1 1 300px';
      text.style.fontSize = '.925rem';
      btns.style.width = '';
      acceptBtn.style.flex = '';
      refuseBtn.style.flex = '';
    }
  }
padNum function · javascript · L32-L34 (3 LOC)
js/app.js
  function padNum(n) {
    return String(n).padStart(4, '0');
  }
resizeCanvas function · javascript · L36-L40 (5 LOC)
js/app.js
  function resizeCanvas() {
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    if (images[currentFrame]) drawFrame(currentFrame);
  }
drawFrame function · javascript · L42-L58 (17 LOC)
js/app.js
  function drawFrame(idx) {
    const img = images[idx];
    if (!img || !img.complete) return;
    ctx.fillStyle = '#0D0D14'; // match --bg-dark
    ctx.fillRect(0, 0, canvas.width, canvas.height);

    const iw = img.naturalWidth || img.width;
    const ih = img.naturalHeight || img.height;
    const cw = canvas.width;
    const ch = canvas.height;
    const scale = Math.max(cw / iw, ch / ih) * IMAGE_SCALE;
    const dw = iw * scale;
    const dh = ih * scale;
    const dx = (cw - dw) / 2;
    const dy = (ch - dh) / 2;
    ctx.drawImage(img, dx, dy, dw, dh);
  }
preloadFrames function · javascript · L61-L78 (18 LOC)
js/app.js
  function preloadFrames() {
    return new Promise((resolve) => {
      for (let i = 1; i <= FRAME_COUNT; i++) {
        const img = new Image();
        img.src = FRAME_PATH + padNum(i) + '.jpg';
        img.onload = img.onerror = function () {
          loaded++;
          const pct = Math.round((loaded / FRAME_COUNT) * 100);
          loaderFill.style.width = pct + '%';
          loaderPercent.textContent = pct + '%';
          if (loaded >= FRAME_COUNT) {
            resolve();
          }
        };
        images[i - 1] = img;
      }
    });
  }
init function · javascript · L81-L110 (30 LOC)
js/app.js
  async function init() {
    resizeCanvas();
    window.addEventListener('resize', resizeCanvas);

    await preloadFrames();

    // Draw first frame
    drawFrame(0);
    canvasReady = true;

    // Hide loader
    loader.classList.add('done');
    setTimeout(() => { loader.style.display = 'none'; }, 700);

    // Init Lenis
    initLenis();

    // Init GSAP
    initGSAP();

    // Hero entrance animation
    animateHero();

    // Misc
    initBurger();
    initDropdown();
    initScrollHeader();
    initYear();
    initFormPersist();
  }
Repobility · code-quality intelligence · https://repobility.com
initLenis function · javascript · L114-L127 (14 LOC)
js/app.js
  function initLenis() {
    lenis = new Lenis({
      duration: 1.2,
      easing: function (t) { return Math.min(1, 1.001 - Math.pow(2, -10 * t)); },
      orientation: 'vertical',
      smoothWheel: true,
    });

    lenis.on('scroll', ScrollTrigger.update);
    gsap.ticker.add(function (time) {
      lenis.raf(time * 1000);
    });
    gsap.ticker.lagSmoothing(0);
  }
initGSAP function · javascript · L130-L219 (90 LOC)
js/app.js
  function initGSAP() {
    gsap.registerPlugin(ScrollTrigger);

    /* --- Canvas scroll-driven video with circle wipe --- */
    // Set the scroll container height to accommodate FRAME_SPEED
    const scrollH = FRAME_COUNT * FRAME_SPEED * (window.innerHeight / 100);
    scrollContainer.style.minHeight = Math.max(scrollH, 800 * parseFloat(getComputedStyle(document.documentElement).fontSize) / 16) + 'px';

    // Actually let's set a concrete min-height in vh
    scrollContainer.style.minHeight = '900vh';

    // Canvas starts hidden, reveals immediately on first scroll
    gsap.set(canvas, { opacity: 0, clipPath: 'circle(0% at 50% 50%)' });

    // Hero -> Canvas: starts as soon as scroll begins
    ScrollTrigger.create({
      trigger: '#hero',
      start: 'top top',
      end: 'bottom top',
      scrub: true,
      onUpdate: function (self) {
        const p = self.progress;
        var op = Math.min(p * 3, 1);
        canvas.style.opacity = op;
        if (canvasTint) canvasTint.s
animateHero function · javascript · L222-L255 (34 LOC)
js/app.js
  function animateHero() {
    const tl = gsap.timeline({ delay: 0.3 });

    tl.to('.hero-label', {
      opacity: 1,
      y: 0,
      duration: 0.8,
      ease: 'power3.out',
    })
    .to('.hero-title .word', {
      opacity: 1,
      y: 0,
      duration: 0.9,
      ease: 'power3.out',
      stagger: 0.15,
    }, '-=0.4')
    .to('.hero-sub', {
      opacity: 1,
      y: 0,
      duration: 0.7,
      ease: 'power3.out',
    }, '-=0.4')
    .to('.hero-actions', {
      opacity: 1,
      y: 0,
      duration: 0.7,
      ease: 'power3.out',
    }, '-=0.3')
    .to('.hero-scroll-hint', {
      opacity: 0.6,
      duration: 0.8,
      ease: 'power2.out',
    }, '-=0.2');
  }
animateSections function · javascript · L258-L413 (156 LOC)
js/app.js
  function animateSections() {
    const sections = document.querySelectorAll('.scroll-section');

    sections.forEach(function (section) {
      const anim = section.dataset.animation;
      const label = section.querySelector('.section-label');
      const heading = section.querySelector('.section-heading');
      const body = section.querySelector('.section-body');
      const cta = section.querySelector('.section-cta');

      switch (anim) {

        case 'slide-left': {
          const tl = gsap.timeline({
            scrollTrigger: {
              trigger: section,
              start: 'top 70%',
              end: 'top 30%',
              scrub: false,
              once: true,
            },
          });
          if (label) tl.to(label, { opacity: 1, y: 0, x: 0, duration: 0.6, ease: 'power3.out' });
          if (heading) tl.fromTo(heading, { opacity: 0, x: -80 }, { opacity: 1, x: 0, y: 0, duration: 0.8, ease: 'power3.out' }, '-=0.3');
          if (body) tl.to(body, { opac
initBurger function · javascript · L416-L432 (17 LOC)
js/app.js
  function initBurger() {
    var burger = document.getElementById('burger');
    var mm = document.getElementById('mobileMenu');
    if (!burger || !mm) return;

    burger.addEventListener('click', function () {
      mm.classList.toggle('open');
      burger.classList.toggle('active');
    });

    mm.querySelectorAll('a').forEach(function (a) {
      a.addEventListener('click', function () {
        mm.classList.remove('open');
        burger.classList.remove('active');
      });
    });
  }
initDropdown function · javascript · L435-L449 (15 LOC)
js/app.js
  function initDropdown() {
    document.querySelectorAll('.dropdown-toggle').forEach(function (btn) {
      btn.addEventListener('click', function (e) {
        e.preventDefault();
        btn.parentElement.classList.toggle('open');
      });
    });
    document.addEventListener('click', function (e) {
      if (!e.target.closest('.nav-dropdown')) {
        document.querySelectorAll('.nav-dropdown.open').forEach(function (d) {
          d.classList.remove('open');
        });
      }
    });
  }
initScrollHeader function · javascript · L452-L468 (17 LOC)
js/app.js
  function initScrollHeader() {
    var header = document.getElementById('header');
    var toTop = document.getElementById('toTop');

    window.addEventListener('scroll', function () {
      header.classList.toggle('scrolled', window.scrollY > 40);
      toTop.classList.toggle('show', window.scrollY > 600);
    }, { passive: true });

    toTop.addEventListener('click', function () {
      if (lenis) {
        lenis.scrollTo(0);
      } else {
        window.scrollTo({ top: 0, behavior: 'smooth' });
      }
    });
  }
initYear function · javascript · L471-L474 (4 LOC)
js/app.js
  function initYear() {
    var el = document.getElementById('year');
    if (el) el.textContent = new Date().getFullYear();
  }
Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
initFormPersist function · javascript · L477-L510 (34 LOC)
js/app.js
  function initFormPersist() {
    var form = document.getElementById('devisForm');
    if (!form) return;
    var key = 'bauer_devis';

    // Restore
    try {
      var saved = JSON.parse(localStorage.getItem(key));
      if (saved) {
        Object.keys(saved).forEach(function (name) {
          var field = form.elements[name];
          if (field) field.value = saved[name];
        });
      }
    } catch (e) {}

    // Save on input
    form.addEventListener('input', function () {
      var data = {};
      Array.from(form.elements).forEach(function (el) {
        if (el.name && el.value) data[el.name] = el.value;
      });
      try { localStorage.setItem(key, JSON.stringify(data)); } catch (e) {}
    });

    // Clear on submit
    form.addEventListener('submit', function (e) {
      e.preventDefault();
      try { localStorage.removeItem(key); } catch (e) {}
      // Could send via fetch here
      alert('Merci ! Votre demande de devis a bien été envoyée. Nous vous recontacter