diff --git a/mapy/oneMap.js b/mapy/oneMap.js
index 80be67f..aefdc1b 100644
--- a/mapy/oneMap.js
+++ b/mapy/oneMap.js
@@ -33,7 +33,7 @@ function getMarkerIcon(courierId){
}
// Zmienne trzymające id dostaw z mapą i czy mapa już była załadowana
-const deliveryPickupPoints = [] ;
+const deliveryPickupPoints = [];
let finpostjs = false;
// Funkcja inicjująca mapę
function loadMap() {
@@ -185,8 +185,7 @@ function loadMap() {
runSearchPickup();
}
if (!finpostjs) {
- console.log("pickup_sites_list.js loaded");
- finpostjs = true;
+ finpostjs = true;
pickup_sites.courierId = ITEM_ID;
runSearchPickup();
@@ -636,9 +635,10 @@ function handleShowSigninModalFromEmailModal(e){
}
// EventListener zmian w kontenerze cop_seection1
+document.getElementById("cop_seection1").addEventListener("change", (e) => {
const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"];
const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"];
-document.getElementById("cop_seection1").addEventListener("change", (e) => {
+
// Walidacja zipcode, nipu i emaila
if(validateRequestId.includes(e.target.id)) return validateRequest(e.target);
@@ -653,11 +653,14 @@ document.getElementById("cop_seection1").addEventListener("change", (e) => {
// Walidacja ulicy i numeru domu
if(e.target.id === "client_street" || e.target.id === "delivery_street") validateStreet(e.target);
+
// Walidacja numeru telefonu
if(e.target.id === "client_phone" || e.target.id === "delivery_phone") validatePhone(e.target);
+
// Walidacja loginu i hasła rejestracji
if(e.target.classList.contains("register__login")) testLogin();
if(e.target.classList.contains("register__password")) testPassword();
+
// Walidacja imienia nazwiska miasta i firmy(wymagające po prostu nie bycia pustym)
if(notEmptyFieldsId.includes(e.target.id)) validateNotEmpty(e.target);
@@ -667,6 +670,7 @@ document.getElementById("cop_seection1").addEventListener("change", (e) => {
else clearValidation(e.target);
};
});
+
// Funkcje walidacji poszczególnych elementów
function validateStreet(streetEl){
const streetParts = streetEl.value.split(" ");
@@ -1296,16 +1300,10 @@ function handleClickVoucherSubmit(){
// Przeliczenie i pokazanie ceny w podsumowaniu
let xhrs;
-const productsWorthPriceEl = document.querySelector("#order2_products_worth .operation_value");
-const deliveryCostEl = document.querySelector("#order2_shipping_value .operation_value");
-const paymentCostEl = document.querySelector("#order2_paymentcost_value .operation_value");
-const insuranceValueEl = document.querySelector("#order2_insurance_value .operation_value");
-const totalRebateEl = document.querySelector("#order2_total_rebate .operation_value");
-const saldoValueEl = document.querySelector("#order2_saldo_value .operation_value");
-const productsPointsEl = document.querySelector("#order2_products_points .operation_value");
-const summaryCostEl = document.getElementById("summary-cost");
-const summaryPointsEl = document.getElementById("summary-points");
function calculateBasketCost() {
+const deliveryCostEl = document.querySelector("#order2_shipping_value .operation_value");
+const productsPointsEl = document.querySelector("#order2_products_points .operation_value");
+const summaryPointsEl = document.getElementById("summary-points");
// Przygotowanie informacji o metodzie dostawy i platnosci
const orderInfo = {
delivery: document.querySelector('.ajax_cop input[name="shipping"]:checked') ? document.querySelector('.ajax_cop input[name="shipping"]:checked').value : "0-1",
@@ -1317,7 +1315,7 @@ function calculateBasketCost() {
dataType: "json",
data: orderInfo,
success: function (t) {
- productsWorthPriceEl.innerHTML = formatPrice(t.products_worth, t.currency_sign) + "" + orderTxt.gross + "";
+ document.querySelector("#order2_products_worth .operation_value").innerHTML = formatPrice(t.products_worth, t.currency_sign) + "" + orderTxt.gross + "";
// Sprawdź cene dostawy
if(t.shipping_undefined) deliveryCostEl.parentElement.style.display = "none";
@@ -1334,10 +1332,10 @@ function calculateBasketCost() {
deliveryCostEl.classList.add("cost_free");
}
}
- checkShowPrice(paymentCostEl, Number(t.prepaid_cost), t.currency_sign);
- checkShowPrice(insuranceValueEl, Number(t.insurance_cost), t.currency_sign);
- checkShowPrice(totalRebateEl, Number(t.total_rebate_without_shipping), t.currency_sign);
- checkShowPrice(saldoValueEl, Number(t.payment_amount_from_client_balance), t.currency_sign);
+ checkShowPrice(document.querySelector("#order2_paymentcost_value .operation_value"), Number(t.prepaid_cost), t.currency_sign);
+ checkShowPrice(document.querySelector("#order2_insurance_value .operation_value"), Number(t.insurance_cost), t.currency_sign);
+ checkShowPrice(document.querySelector("#order2_total_rebate .operation_value"), Number(t.total_rebate_without_shipping), t.currency_sign);
+ checkShowPrice(document.querySelector("#order2_saldo_value .operation_value"), Number(t.payment_amount_from_client_balance), t.currency_sign);
// Punkty zamówienia
if(t.products_worth_at_points){
@@ -1351,7 +1349,7 @@ function calculateBasketCost() {
}
// Cena całkowita
- summaryCostEl.innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "" + + "";
+ document.getElementById("summary-cost").innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "" + + "";
},
});
};
@@ -1369,9 +1367,9 @@ function formatPrice(price, currencySign) {
};
// Funkcja od ustalenia daty dostawy
+function deliveryDate(deliveryVal, delivery, pickuppoint) {
const deliveryMessageEl = document.querySelector("#order2_shiptime span:not(.operation_value)");
const deliveryDateEl = document.querySelector("#order2_shiptime .operation_value");
-function deliveryDate(deliveryVal, delivery, pickuppoint) {
const date = delivery.split("#");
// Wybranie nazwy zaleznie czy dostawa jest do twojego mieszkania czy nie
@@ -1386,8 +1384,8 @@ function deliveryDate(deliveryVal, delivery, pickuppoint) {
};
// Obsługa klilnięć na elementy w podsumowaniu
-const productsContainer = document.getElementById("checkout_step3_3");
document.getElementById("cop_seection3").addEventListener("click", (e) => {
+const productsContainer = document.getElementById("checkout_step3_3");
// Kliknięcie na przyciski "Pokaż pozozostałe produkty" i "Zwiń listę"
const togggleProducts = e.target.closest(".order_products_action");
@@ -1514,12 +1512,9 @@ async function removeCode(){
}
// Zmień widoczność kodu rabatowego
-const rebateOptionWrapper = document.querySelector(".rebate__options");
const rebateCodeContainer = document.querySelector(".rebate__code");
-const rebateActiveWrapper = document.querySelector(".rebate__active");
-const activeCodeEl = document.getElementById("active-code");
-const rebateOptionEl = document.getElementById("rebate_option");
function toggleActiveCode(show, error=false){
+const activeCodeEl = document.getElementById("active-code");
// Wyczyść walidacje
if(!error){
removeErrorMessage(rebateCode);
@@ -1527,8 +1522,8 @@ function toggleActiveCode(show, error=false){
}
// Zmień widoczność
- rebateOptionWrapper.style.display = show ? "none" : "flex";
- rebateActiveWrapper.style.display = show ? "block" : "none";
+ document.querySelector(".rebate__options").style.display = show ? "none" : "flex";
+ document.querySelector(".rebate__active").style.display = show ? "block" : "none";
if(!error) rebateCodeContainer.classList.remove("--fade-in");
else rebateCodeContainer.classList.add("--fade-in");
@@ -1536,15 +1531,14 @@ function toggleActiveCode(show, error=false){
// Zmień wartości
activeCodeEl.innerHTML = show ? rebateCode.value : "";
showInput = error ? true : false;
- rebateOptionEl.checked = error ? true : false;
+ document.getElementById("rebate_option").checked = error ? true : false;
if(!error) rebateCode.value = "";
else activeCodeEl.innerHTML = "";
}
// EventListenery dla kodu rabatowego
let showInput = false;
-const rebateCodeWrapper = document.querySelector(".rebate");
-rebateCodeWrapper.addEventListener("click", (e) => {
+document.querySelector(".rebate").addEventListener("click", (e) => {
// Rozwinięcie opcji rabatowej
if(e.target.id === "rebate_option" || e.target.classList.contains("rebate__active_change")){
showInput = !showInput;
@@ -1608,9 +1602,9 @@ async function validateFormInputs(query){
}
// Obsługa złożenia zamówienia
+document.querySelector(".order2_button_order").addEventListener("click", async () => {
const termsConditionsInput = document.getElementById("order2_terms_conditions");
const cancelConditionsInput = document.getElementById("order2_cancel");
-document.querySelector(".order2_button_order").addEventListener("click", async () => {
try {
app_shop.fn.ajaxLoadSite(1);
app_shop.vars.validation = 1;
@@ -1656,7 +1650,7 @@ document.querySelector(".order2_button_order").addEventListener("click", async (
let alertMessage = "";
// Element sprawdzający czy regulamin jest zaznaczony
- let termsAndConditions = document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked;
+ let termsAndConditions = termsConditionsInput.checked && cancelConditionsInput.checked;
if(!termsAndConditions) alertMessage += `${} ${}!
`;
// Błąd w formularzu
if(errorEl){
@@ -1842,6 +1836,7 @@ function checkNewsletter(logged, regular){
else if(document.querySelector(regular)) return document.querySelector(regular).checked ? 1 : 0;
else return 0;
}
+
// Funkcja wysyłająca zamówienie
function sendOrder(data){
$.ajax({
diff --git a/wydzielonyScript.js b/wydzielonyScript.js
index 6582197..594a5df 100644
--- a/wydzielonyScript.js
+++ b/wydzielonyScript.js
@@ -36,7 +36,7 @@ function getMarkerIcon(courierId){
}
// Zmienne trzymające id dostaw z mapą i czy mapa już była załadowana
-const deliveryPickupPoints = [] ;
+const deliveryPickupPoints = [];
let finpostjs = false;
// Funkcja inicjująca mapę
function loadMap() {
@@ -631,9 +631,10 @@ function handleShowSigninModalFromEmailModal(e){
}
// EventListener zmian w kontenerze cop_seection1
-const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"];
-const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"];
document.getElementById("cop_seection1").addEventListener("change", (e) => {
+ const validateRequestId = ["client_zipcode", "delivery_zipcode", "client_nip", "client_email"];
+ const notEmptyFieldsId = ["client_firstname", "client_lastname", "client_city", "delivery_firstname", "delivery_lastname", "delivery_city", "client_firm"];
+
// Walidacja zipcode, nipu i emaila
if(validateRequestId.includes(e.target.id)) return validateRequest(e.target);
@@ -648,11 +649,14 @@ document.getElementById("cop_seection1").addEventListener("change", (e) => {
// Walidacja ulicy i numeru domu
if(e.target.id === "client_street" || e.target.id === "delivery_street") validateStreet(e.target);
+
// Walidacja numeru telefonu
if(e.target.id === "client_phone" || e.target.id === "delivery_phone") validatePhone(e.target);
+
// Walidacja loginu i hasła rejestracji
if(e.target.classList.contains("register__login")) testLogin();
if(e.target.classList.contains("register__password")) testPassword();
+
// Walidacja imienia nazwiska miasta i firmy(wymagające po prostu nie bycia pustym)
if(notEmptyFieldsId.includes(e.target.id)) validateNotEmpty(e.target);
@@ -662,6 +666,7 @@ document.getElementById("cop_seection1").addEventListener("change", (e) => {
else clearValidation(e.target);
};
});
+
// Funkcje walidacji poszczególnych elementów
function validateStreet(streetEl){
const streetParts = streetEl.value.split(" ");
@@ -1291,16 +1296,10 @@ function handleClickVoucherSubmit(){
// Przeliczenie i pokazanie ceny w podsumowaniu
let xhrs;
-const productsWorthPriceEl = document.querySelector("#order2_products_worth .operation_value");
-const deliveryCostEl = document.querySelector("#order2_shipping_value .operation_value");
-const paymentCostEl = document.querySelector("#order2_paymentcost_value .operation_value");
-const insuranceValueEl = document.querySelector("#order2_insurance_value .operation_value");
-const totalRebateEl = document.querySelector("#order2_total_rebate .operation_value");
-const saldoValueEl = document.querySelector("#order2_saldo_value .operation_value");
-const productsPointsEl = document.querySelector("#order2_products_points .operation_value");
-const summaryCostEl = document.getElementById("summary-cost");
-const summaryPointsEl = document.getElementById("summary-points");
function calculateBasketCost() {
+ const deliveryCostEl = document.querySelector("#order2_shipping_value .operation_value");
+ const productsPointsEl = document.querySelector("#order2_products_points .operation_value");
+ const summaryPointsEl = document.getElementById("summary-points");
// Przygotowanie informacji o metodzie dostawy i platnosci
const orderInfo = {
delivery: document.querySelector('.ajax_cop input[name="shipping"]:checked') ? document.querySelector('.ajax_cop input[name="shipping"]:checked').value : "0-1",
@@ -1312,7 +1311,7 @@ function calculateBasketCost() {
dataType: "json",
data: orderInfo,
success: function (t) {
- productsWorthPriceEl.innerHTML = formatPrice(t.products_worth, t.currency_sign) + "" + orderTxt.gross + "";
+ document.querySelector("#order2_products_worth .operation_value").innerHTML = formatPrice(t.products_worth, t.currency_sign) + "" + orderTxt.gross + "";
// Sprawdź cene dostawy
if(t.shipping_undefined) deliveryCostEl.parentElement.style.display = "none";
@@ -1329,10 +1328,10 @@ function calculateBasketCost() {
deliveryCostEl.classList.add("cost_free");
}
}
- checkShowPrice(paymentCostEl, Number(t.prepaid_cost), t.currency_sign);
- checkShowPrice(insuranceValueEl, Number(t.insurance_cost), t.currency_sign);
- checkShowPrice(totalRebateEl, Number(t.total_rebate_without_shipping), t.currency_sign);
- checkShowPrice(saldoValueEl, Number(t.payment_amount_from_client_balance), t.currency_sign);
+ checkShowPrice(document.querySelector("#order2_paymentcost_value .operation_value"), Number(t.prepaid_cost), t.currency_sign);
+ checkShowPrice(document.querySelector("#order2_insurance_value .operation_value"), Number(t.insurance_cost), t.currency_sign);
+ checkShowPrice(document.querySelector("#order2_total_rebate .operation_value"), Number(t.total_rebate_without_shipping), t.currency_sign);
+ checkShowPrice(document.querySelector("#order2_saldo_value .operation_value"), Number(t.payment_amount_from_client_balance), t.currency_sign);
// Punkty zamówienia
if(t.products_worth_at_points){
@@ -1346,7 +1345,7 @@ function calculateBasketCost() {
}
// Cena całkowita
- summaryCostEl.innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "" + + "";
+ document.getElementById("summary-cost").innerHTML = formatPrice(t.total_to_pay, t.currency_sign) + "" + + "";
},
});
};
@@ -1364,9 +1363,9 @@ function formatPrice(price, currencySign) {
};
// Funkcja od ustalenia daty dostawy
-const deliveryMessageEl = document.querySelector("#order2_shiptime span:not(.operation_value)");
-const deliveryDateEl = document.querySelector("#order2_shiptime .operation_value");
function deliveryDate(deliveryVal, delivery, pickuppoint) {
+ const deliveryMessageEl = document.querySelector("#order2_shiptime span:not(.operation_value)");
+ const deliveryDateEl = document.querySelector("#order2_shiptime .operation_value");
const date = delivery.split("#");
// Wybranie nazwy zaleznie czy dostawa jest do twojego mieszkania czy nie
@@ -1381,8 +1380,8 @@ function deliveryDate(deliveryVal, delivery, pickuppoint) {
};
// Obsługa klilnięć na elementy w podsumowaniu
-const productsContainer = document.getElementById("checkout_step3_3");
document.getElementById("cop_seection3").addEventListener("click", (e) => {
+ const productsContainer = document.getElementById("checkout_step3_3");
// Kliknięcie na przyciski "Pokaż pozozostałe produkty" i "Zwiń listę"
const togggleProducts = e.target.closest(".order_products_action");
@@ -1509,12 +1508,9 @@ async function removeCode(){
}
// Zmień widoczność kodu rabatowego
-const rebateOptionWrapper = document.querySelector(".rebate__options");
const rebateCodeContainer = document.querySelector(".rebate__code");
-const rebateActiveWrapper = document.querySelector(".rebate__active");
-const activeCodeEl = document.getElementById("active-code");
-const rebateOptionEl = document.getElementById("rebate_option");
function toggleActiveCode(show, error=false){
+ const activeCodeEl = document.getElementById("active-code");
// Wyczyść walidacje
if(!error){
removeErrorMessage(rebateCode);
@@ -1522,8 +1518,8 @@ function toggleActiveCode(show, error=false){
}
// Zmień widoczność
- rebateOptionWrapper.style.display = show ? "none" : "flex";
- rebateActiveWrapper.style.display = show ? "block" : "none";
+ document.querySelector(".rebate__options").style.display = show ? "none" : "flex";
+ document.querySelector(".rebate__active").style.display = show ? "block" : "none";
if(!error) rebateCodeContainer.classList.remove("--fade-in");
else rebateCodeContainer.classList.add("--fade-in");
@@ -1531,15 +1527,14 @@ function toggleActiveCode(show, error=false){
// Zmień wartości
activeCodeEl.innerHTML = show ? rebateCode.value : "";
showInput = error ? true : false;
- rebateOptionEl.checked = error ? true : false;
+ document.getElementById("rebate_option").checked = error ? true : false;
if(!error) rebateCode.value = "";
else activeCodeEl.innerHTML = "";
}
// EventListenery dla kodu rabatowego
let showInput = false;
-const rebateCodeWrapper = document.querySelector(".rebate");
-rebateCodeWrapper.addEventListener("click", (e) => {
+document.querySelector(".rebate").addEventListener("click", (e) => {
// Rozwinięcie opcji rabatowej
if(e.target.id === "rebate_option" || e.target.classList.contains("rebate__active_change")){
showInput = !showInput;
@@ -1603,9 +1598,9 @@ async function validateFormInputs(query){
}
// Obsługa złożenia zamówienia
-const termsConditionsInput = document.getElementById("order2_terms_conditions");
-const cancelConditionsInput = document.getElementById("order2_cancel");
document.querySelector(".order2_button_order").addEventListener("click", async () => {
+ const termsConditionsInput = document.getElementById("order2_terms_conditions");
+ const cancelConditionsInput = document.getElementById("order2_cancel");
try {
app_shop.fn.ajaxLoadSite(1);
app_shop.vars.validation = 1;
@@ -1651,7 +1646,7 @@ document.querySelector(".order2_button_order").addEventListener("click", async (
let alertMessage = "";
// Element sprawdzający czy regulamin jest zaznaczony
- let termsAndConditions = document.getElementById("order2_terms_conditions").checked && document.getElementById("order2_cancel").checked;
+ let termsAndConditions = termsConditionsInput.checked && cancelConditionsInput.checked;
if(!termsAndConditions) alertMessage += `${} ${}!
`;
// Błąd w formularzu
if(errorEl){
@@ -1837,6 +1832,7 @@ function checkNewsletter(logged, regular){
else if(document.querySelector(regular)) return document.querySelector(regular).checked ? 1 : 0;
else return 0;
}
+
// Funkcja wysyłająca zamówienie
function sendOrder(data){
$.ajax({