Files
interblue.pl/modules/dpdpoland/js/dpdpoland-swipbox-iframe.js
2026-03-31 22:07:39 +02:00

66 lines
2.8 KiB
JavaScript

/*
* Copyright 2025 DPD Polska Sp. z o.o.
*
* NOTICE OF LICENSE
*
* Licensed under the EUPL-1.2 or later.
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://joinup.ec.europa.eu/software/page/eupl
* It is also bundled with this package in the file LICENSE.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Licence is distributed on an AS IS basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions
* and limitations under the Licence.
*
* @author DPD Polska Sp. z o.o.
* @copyright 2025 DPD Polska Sp. z o.o.
* @license https://joinup.ec.europa.eu/software/page/eupl
*/
// noinspection JSUnresolvedReference
if (typeof dpdpolandSwipBoxEventCreated == 'undefined') {
var dpdpolandSwipBoxEventCreated = false;
}
var dpdpoland_swipbox_iframe = document.createElement("iframe");
dpdpoland_swipbox_iframe.setAttribute("id", "dpdpoland-widget-swipbox-iframe");
dpdpoland_swipbox_iframe.setAttribute("allow", "geolocation");
dpdpoland_swipbox_iframe.src = dpdpoland_iframe_swipbox_url;
dpdpoland_swipbox_iframe.style.width = "100%";
dpdpoland_swipbox_iframe.style.border = "none";
dpdpoland_swipbox_iframe.style.minHeight = "400px";
dpdpoland_swipbox_iframe.style.height = "768px";
var dpdpoland_swipbox_script = document.getElementById("dpdpoland-widget-swipbox");
if (dpdpoland_swipbox_script)
dpdpoland_swipbox_script.parentNode.insertBefore(dpdpoland_swipbox_iframe, dpdpoland_swipbox_script);
if (!dpdpolandSwipBoxEventCreated) {
var dpdpoland_swipbox_eventListener = window[window.addEventListener ? "addEventListener" : "attachEvent"];
var dpdpoland_swipbox_messageEvent = ("attachEvent" === dpdpoland_swipbox_eventListener) ? "onmessage" : "message";
dpdpoland_swipbox_eventListener(dpdpoland_swipbox_messageEvent, function (a) {
console.log('hit' + getDpdPolandIdSwipBoxCarrier() +' ' + getDpdPolandSelectedCarrier())
if (getDpdPolandIdSwipBoxCarrier() === getDpdPolandSelectedCarrier()) {
if (a.data.height && !isNaN(a.data.height)) {
dpdpoland_swipbox_iframe.style.height = a.data.height + "px"
} else if (a.data.point_id)
dpdPolandPointSelected(a.data.point_id);
}
}, !1);
dpdpolandSwipBoxEventCreated = true
}
function dpdPolandPointSelected(pudoCode) {
$('.container_dpdpoland_swipbox_error').css("display", "none");
$('.dpdpoland-swipbox-new-point').css("display", "none");
$('.dpdpoland-swipbox-selected-point').css("display", "block");
dpdPolandSavePudoCode(pudoCode, $('#dpdpolandSwipboxModal'));
dpdPolandGetPudoAddress(pudoCode, $('.dpdpoland-selected-point'))
}