Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/extmag/shiplab/view/frontend/web/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/extmag/shiplab/view/frontend/web/js/access-point.js
/**
 * @api
 */
require([
    'jquery',
    'underscore',
    'ko',
    'Magento_Checkout/js/model/quote',
    'Magento_Ui/js/modal/modal',
    'mage/translate',
    'mage/url',
    'Extmag_Shiplab/js/latinize',
    'Extmag_Shiplab/js/depends'
], function (
    $,
    _,
    ko,
    quote,
    modal,
    $t,
    urlBuilder,
    latinize,
    frontDepends
) {
    'use strict';
    var CarrierAccessPoint = {
        callBack: function () {
        },
        startAction: function (callback) {
            this.callBack = callback;
            if (
                quote.shippingMethod()
                && quote.shippingMethod()['carrier_code'] == 'extmag'
                && quote.shippingMethod()['extension_attributes']
                && quote.shippingMethod()['extension_attributes']['access_point'] == '1'
            ) {
                let carrier = quote.shippingMethod()['extension_attributes']['access_point_carrier_code'];
                let address = {};
                address['city'] = quote.shippingAddress().city;
                address['state_code'] = quote.shippingAddress().regionCode;
                if (!address['state_code']) {
                    address['state_code'] = quote.shippingAddress().region;
                }
                address['postal_code'] = quote.shippingAddress().postcode;
                address['country_code'] = quote.shippingAddress().countryId;
                this.openPopupAP(address, carrier);
            } else {
                window.isCarrierAccessPoint = true;
                this.callBack();
            }
        },
        openPopupAP: function (address, carrier) {
            let modalDialog = $('<div class="ui-dialog-content ui-widget-content"></div>').modal({
                type: 'popup',
                modalClass: 'edit-ap-popup',
                title: frontDepends.getPopupTitle(carrier),
                responsive: true
            }), AddressRequestLine = [];

            if (address['city'].length > 0) {
                AddressRequestLine[AddressRequestLine.length] = 'city=' + encodeURIComponent(latinize.latinize(address['city']));
            }

            if (address['state_code'].length > 0) {
                AddressRequestLine[AddressRequestLine.length] = 'state=' + encodeURIComponent(latinize.latinize(address['state_code']));
            }

            if (address['postal_code'].length > 0) {
                AddressRequestLine[AddressRequestLine.length] = 'postal=' + encodeURIComponent(latinize.latinize(address['postal_code']));
            }

            if (address['country_code'].length > 0) {
                AddressRequestLine[AddressRequestLine.length] = 'country=' + encodeURIComponent(address['country_code']);
                AddressRequestLine[AddressRequestLine.length] = 'searchCountry=' + encodeURIComponent(address['country_code']);
                AddressRequestLine[AddressRequestLine.length] = 'countrySite=' + encodeURIComponent(address['country_code']);
            }

            let callbackUrl = encodeURIComponent(urlBuilder.build("extmag_shiplab/accessPoint/callback/carrier/" + carrier) + "?");
            let iframeUrl = urlBuilder.build("extmag_" + carrier + "shipping/locator/iframe/");
            let frame = $('<iframe src="' + iframeUrl + '?oId=' + (Math.floor(Math.random() * 1000000) + 1) + '&cburl=' + callbackUrl + '&' + AddressRequestLine.join("&") + frontDepends.getCarrierUrlParams(carrier, address) + '" style="width:100%; height: 77vh" frameborder="0"></iframe>')[0].outerHTML;
            let topText = '';
            if (quote.shippingMethod()
                && quote.shippingMethod()['extension_attributes']
                && quote.shippingMethod()['extension_attributes']['access_point_top_text']
            ) {
                topText = $('<div class="access-point-popup-top-text"></div>').text(quote.shippingMethod()['extension_attributes']['access_point_top_text'])[0].outerHTML;
            }

            modalDialog.html(topText + frame).modal('openModal');
        },
        setAccessPointAddress: function () {
            this.closeAccessPointPopup();
            window.isCarrierAccessPoint = true;
            this.callBack();
        },
        closeAccessPointPopup: function () {
            window.isCarrierAccessPoint = false;
            $('button.action-close').trigger("click");
        }
    };

    window.CarrierAccessPoint = CarrierAccessPoint;

    return CarrierAccessPoint;
});

Spamworldpro Mini