403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/wbs24.ozonapinew/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/wbs24.ozonapinew/handlers.js
class Wbs24OzonapinewHandlers {
  admin = null;

  constructor(objects = []) {
    this.admin = objects['Wbs24OzonapinewAdmin'] || new Wbs24OzonapinewAdmin();
  }

  addHandlersForAccounts(accounts) {
    document.addEventListener("DOMContentLoaded", () => {
      for (let index of accounts) {
        let account = this.admin.getAccountPrefixByIndex(index);

        this.addCheckboxHandler(account);
        this.addWarningMessageHandler(account);
        this.addGetDeliveryServicesHandler(account, index);
        this.addStockPropertiesHandlers(account, index);
        this.addSiteIdHandlers(account, index);
      }
    });
  }

  addCheckboxHandler(account) {
    let checkboxTrackNumber = document.querySelector(`input[name="${account}allowSendTrackNumber"]`);

    if (checkboxTrackNumber) {
      if (checkboxTrackNumber.value == 'Y') {
        checkboxTrackNumber.checked = true;
      }

      checkboxTrackNumber.addEventListener('change', (event) => {
        if (event.currentTarget.checked) {
          checkboxTrackNumber.value = 'Y';
        } else {
          checkboxTrackNumber.value = 'N';
        }
      });
    }
  }

  addWarningMessageHandler(account) {
    const requiredSelectNames = [
      account + 'siteId',
      account + 'deliveryServiceId',
      account + 'paymentSystemId',
      account + 'personTypeId',
      account + 'propertyOfExternalOrderNumber',
      account + 'propertyOfShipmentDate',
    ];

    for (let name of requiredSelectNames) {
      let select = document.querySelector(`select[name=${name}]`);

      if (select) {
        select.addEventListener('change', () => {
          const allSelectsAreSet = this.admin.areAllSelectsSet(requiredSelectNames);
          const note = document.querySelector(`.wbs24_ozonapinew_option_${account}site_note`);

          if (note) note.style.display = allSelectsAreSet ? "none" : "table-row";
        });
      }
    }
  }

  addGetDeliveryServicesHandler(account, accountIndex) {
    let button = document.querySelector(`.wbs24_ozonapinew_${account}get_delivery_services`);
    if (button) {
      button.addEventListener('click', async (e) => {
        e.preventDefault();

        await this.request('get_delivery_services', accountIndex);
        document.forms.wbs24_ozonapinew.save.click()
      });
    }
  }

  async request(action, accountIndex) {
    let url =
      '/bitrix/tools/wbs24.ozonapinew/ajax.php?ACTION=' + action
      + '&account_index=' + accountIndex
    ;
    let response = await fetch(url);
    let result = await response.json();

    return result;
  }

  addStockPropertiesHandlers(account, index) {
    let stockType = document.querySelector(`select[name=${account}stockType]`);
    let stockOptions = document.querySelectorAll(`.${account}wbs24-stock-properties`);

    if (stockType && stockOptions) {

      if (stockType.value == 'stocks_from_property') {
        stockOptions.forEach(stockOption => {
          let stockOptionTr = stockOption.closest('tr');
          stockOptionTr.style.display = 'table-row';
        });
      } else {
        stockOptions.forEach(stockOption => {
          let stockOptionTr = stockOption.closest('tr');
          stockOptionTr.style.display = 'none';
        })
      }

      stockType.addEventListener('change', (event) => {
        if (event.target.value == 'stocks_from_property') {
          stockOptions.forEach(stockOption => {
            let stockOptionTr = stockOption.closest('tr');
            stockOptionTr.style.display = 'table-row';
          });
        } else {
          stockOptions.forEach(stockOption => {
            let stockOptionTr = stockOption.closest('tr');
            stockOptionTr.style.display = 'none';
          })
        }
      });
    }
  }

  addSiteIdHandlers(account, index) {
    let siteIds = document.querySelectorAll(`select[name=${account}siteId]`);
    let saveButton = document.querySelector('input[name="save"]');

    if (siteIds && saveButton) {
      siteIds.forEach(siteId => {
        siteId.addEventListener("change", (e) => {
          let siteId = e.target.value;
          saveButton.click();
        });
      });
    }
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit