403Webshell
Server IP : 147.234.39.149  /  Your IP : 172.30.80.1
Web Server : nginx/1.28.3
System : Linux AICRAFT 6.6.114.1-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Mon Dec 1 20:46:23 UTC 2025 x86_64
User : dphoto ( 1000)
PHP Version : 8.5.4
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/foggy.co.il/wordpress/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/foggy.co.il/wordpress/photobook-smart-layout.zip
PK]u\�Tv�
�
photobook-smart-layout.js// photobook-smart-layout.js
// Smart Layout - choose template by image aspect ratios

(function(){
  if (!window.DDPB_EDITOR_API) return;

  const API = window.DDPB_EDITOR_API;

  function getPhotoAspectType(meta){
    if (!meta || !meta.w || !meta.h) return 'square';
    const r = meta.w / meta.h;
    if (r > 1.2) return 'landscape';
    if (r < 0.8) return 'portrait';
    return 'square';
  }

  function getSlotAspectType(slot){
    const r = slot.w / slot.h;
    if (r > 1.2) return 'landscape';
    if (r < 0.8) return 'portrait';
    return 'square';
  }

  function scoreTemplate(photos, template){
    let score = 0;

    const slots = template;

    for (let i = 0; i < photos.length && i < slots.length; i++){
      const p = photos[i];
      const s = slots[i];

      const pType = getPhotoAspectType(p.meta);
      const sType = getSlotAspectType(s);

      if (pType === sType) score += 3;
      else if (pType === 'square' || sType === 'square') score += 1;

      const area = s.w * s.h;
      score += area * 0.1;
    }

    return score;
  }

  function pickBestTemplate(page){
    const layout = API.getPageLayout(page);
    const templates = API.getTemplateList(layout);

    if (!templates || !templates.length) return 0;

    const photos = (page.items || []);

    let bestIdx = 0;
    let bestScore = -Infinity;

    templates.forEach((tpl, idx) => {
      const s = scoreTemplate(photos, tpl);
      if (s > bestScore){
        bestScore = s;
        bestIdx = idx;
      }
    });

    return bestIdx;
  }

  async function applySmartLayout(pageIndex){
    const page = API.getPage(pageIndex);
    if (!page) return;

    // load image metadata
    for (const item of (page.items || [])){
      if (!item.meta){
        item.meta = await API.loadImgMeta(item);
      }
    }

    const idx = pickBestTemplate(page);

    API.applyTemplateByIndex(page, idx);
    API.ensureGridModel(page);
    API.markDirty();
    API.saveDraft();
    API.renderPagesGrid();
    API.renderPriceBar();
  }

  function injectButtons(){
    document.querySelectorAll('.ddpb-page').forEach((el, index) => {
      if (el.querySelector('.ddpb-tool-smartlayout')) return;

      const autoBtn = el.querySelector('.ddpb-tool-autolayout');
      if (!autoBtn) return;

      const btn = document.createElement('button');
      btn.type = 'button';
      btn.className = 'ddpb-tool ddpb-tool-smartlayout';
      btn.textContent = '✨ Smart Layout';

      btn.onclick = () => applySmartLayout(index);

      autoBtn.parentNode.insertBefore(btn, autoBtn);
    });
  }

  const obs = new MutationObserver(() => {
    injectButtons();
  });

  obs.observe(document.body, { childList:true, subtree:true });

  setTimeout(injectButtons, 500);

})();PK]u\9L�README_patch.txtAdd before boot():

window.DDPB_EDITOR_API = {
  getDraft: () => draft,
  getPage: (pageIndex) => (draft.pages && draft.pages[pageIndex]) ? draft.pages[pageIndex] : null,
  getPageLayout,
  getTemplateList,
  applyTemplateByIndex,
  ensureGridModel,
  markDirty,
  saveDraft,
  renderPagesGrid,
  renderPriceBar,
  refreshPageSettingsDeleteSelect,
  loadImgMeta,
  setToolbarStatus,
};

And enqueue:

wp_enqueue_script(
  'ddpb-smart-layout',
  plugins_url('assets/photobook-smart-layout.js', __FILE__),
  [$handle_js],
  '1.0.0',
  true
);
PK]u\�Tv�
�
�photobook-smart-layout.jsPK]u\9L���
README_patch.txtPK�>

Youez - 2016 - github.com/yon3zu
LinuXploit