PageSourceSearch

https://biky.ai/wp-content/themes/keybe-biky/includes/price-calculator/js/script.js?ver=20260820

js biky.ai collected 2026-10-05 13:59:40 UTC 8,317 bytes, 247 lines download raw bytes

1document.addEventListener('DOMContentLoaded', () => {
2	const calculator = document.querySelector('.biky-price-calculator');
3	if (calculator) {
4		const calculatorItems = document.querySelectorAll('.biky-price-calculator .item');
5		const firstMonthRadios = document.querySelectorAll('input[name="plan-1"]');
6		const selects = calculator.querySelectorAll('.biky-price-calculator select');
7		const lang = window.bikyCalculatorData?.lang || 'es';
8		const printTranslations = {
9			en: { month: 'Month', onboardingNote: ' (Plan + Onboarding + Tier)', totalLabel: 'Total Month: ' },
10			es: { month: 'Mes', onboardingNote: ' (Plan + Onboarding + Tier)', totalLabel: 'Total Mes: ' },
11			pt: { month: 'Mês', onboardingNote: ' (Plano + Onboarding + Tier)', totalLabel: 'Total Mês: ' },
12		};
13		const t = printTranslations[lang] || printTranslations.es;
14		selects.forEach(select => {
15			select.selectedIndex = 0;
16		});
17		const radios = calculator.querySelectorAll('.biky-price-calculator input[type="radio"]');
18		radios.forEach(r => r.checked = false);
19		document.querySelectorAll('.biky-price-calculator input[type="radio"], .biky-price-calculator select').forEach(field => {
20			field.addEventListener('change', calculateTotals);
21		});
22		function calculateTotals() {
23			let grandTotal = 0;
24			let totalTiers = 0;
25			let totalPlans = 0;
26			let onboarding = 0;
27			calculatorItems.forEach((item, index) => {
28				const selectedPlan = item.querySelector('input[type="radio"]:checked');
29				const select = item.querySelector('select');
30				const monthTotalEl = item.querySelector('.total-price-month');
31				const planPrice = selectedPlan
32					? parseFloat(selectedPlan.value) || 0
33					: 0;
34				const tierPrice = parseFloat(select.value) || 0;
35				if (index === 0 && selectedPlan) {
36					onboarding = parseFloat(selectedPlan.dataset.onboarding) || 0;
37				}
38				const monthTotal = planPrice + tierPrice;
39				monthTotalEl.textContent = '$' + formatNumber(monthTotal);
40				totalPlans += planPrice;
41				totalTiers += tierPrice;
42				grandTotal += monthTotal;
43			});
44			const adjustedPlanTotal = totalPlans - onboarding;
45			document.querySelector('.total-plan').textContent = 'USD $' + formatNumber(adjustedPlanTotal);
46			document.querySelector('.total-onboarding').textContent = 'USD $' + formatNumber(onboarding);
47			document.querySelector('.total-tier').textContent = 'USD $' + formatNumber(totalTiers);
48			document.querySelector('.total-price').textContent = 'USD $' + formatNumber(grandTotal);
49		}
50		function formatNumber(num) {
51			return num.toLocaleString('en-US', {
52				minimumFractionDigits: 2,
53				maximumFractionDigits: 2
54			});
55		}
56		firstMonthRadios.forEach((radio, index) => {
57			radio.addEventListener('change', () => {
58				calculator.classList.add('active');
59				document.querySelectorAll('.biky-price-calculator .item').forEach(item => {
60					const radios = item.querySelectorAll('input[type="radio"]');
61					if (radios[index]) {
62						radios[index].checked = true;
63					}
64				});
65				calculateTotals();
66			});
67		});
68		// IMPRIMIR
69		const printPdf = document.querySelector('#download-pdf');
70		printPdf.addEventListener('click', (event) => {
71			printDiv();
72		});
73		function printDiv() {
74			const printList = document.querySelector('.print-list-months');
75			printList.innerHTML = '';
76			calculatorItems.forEach((item, index) => {
77				let monthName = item.querySelector('.month-title').childNodes[0].textContent.trim();
78				monthName = monthName.replace('Month', t.month);
79				if (index === 0) {
80					monthName += t.onboardingNote;
81				}
82				const selectedPlan = item.querySelector('input[type="radio"]:checked');
83				const selectedPlanLabel = selectedPlan
84					? item.querySelector(`label[for="${selectedPlan.id}"]`).textContent.trim()
85					: '-';
86				const select = item.querySelector('select');
87				const selectedTier = select.options[select.selectedIndex].textContent.trim();
88				const monthTotal = item.querySelector('.total-price-month').textContent.trim();
89				const totalLabel = t.totalLabel;
90				printList.innerHTML += `
91				<p class="print-month-row">
92					<span class="name">${monthName}</span>
93					<span>${selectedPlanLabel}</span>
94					<span>${selectedTier}</span>
95					<span>${totalLabel}${monthTotal}</span>
96				</p>
97			`;
98			});
99			document.querySelector('.print-total-plan').textContent = document.querySelector('.total-plan').textContent;
100			document.querySelector('.print-total-onboarding').textContent = document.querySelector('.total-onboarding').textContent;
101			document.querySelector('.print-total-tier').textContent = document.querySelector('.total-tier').textContent;
102			document.querySelector('.print-total-price').textContent = document.querySelector('.total-price').textContent;
103			const content = document.querySelector('#biky-price-calculator-print').innerHTML;
104			const printHtml = `
105			<html>
106				<head>
107					<title>PDF</title>
108					<style>
109						body {
110							font-family: sans-serif;
111							padding: 40px;
112							font-size: 8pt;
113						}
114						.print-list-months {
115							margin-top: 4rem;
116							//column-count: 3;
117							//column-gap: 2rem;
118							display: grid;
119							gap: 0 24px;
120							grid-template-columns: repeat(3, minmax(0, 1fr));
121						}
122						.print-list-months p {
123							//border: 1px solid #000;
124							margin: 0;
125							padding: 1rem 0;
126						}
127						.print-list-months p span{
128							padding: .25em 0;
129						}
130						.print-totals p span,
131						.print-list-months p span{
132							display: block;
133						}
134						.print-list-months p span.name{
135							font-weight: 700;
136						}
137						.print-totals {
138							margin-top: 2rem;
139						}
140						.print-totals p {
141							column-count: 2;
142							column-gap: 2rem;
143						}
144						.print-totals p span.number{
145							font-weight: 700;
146							text-align: right;
147						}
148						.print-info{
149							margin-top: 3rem;
150							font-size: 8pt;
151						}
152						.print-info p {
153							margin: .5em 0;
154						}
155						.print-top {
156							columns: 2;
157						}
158						.print-bottom p{
159							margin: 0;
160						}
161						.print-top .text {
162							letter-spacing: .5em;
163						}
164						.print-top .logo {
165							text-align: right;
166						}
167						.print-bottom {
168							columns: 2;
169							margin-top: 6rem;
170						}
171						.print-bottom .logo-biky {
172							letter-spacing: .5em;
173						}
174						.print-bottom .logo-biky img {
175							width: 15em;
176						}
177						.print-bottom .logo-keybe {
178							text-align: right;
179						}
180						.print-bottom .logo-keybe img {
181							width: 4em;
182						}
183					</style>
184				</head>
185				<body>
186					${content}
187				</body>
188			</html>
189			`;
190			const printFrame = document.createElement('iframe');
191			printFrame.style.cssText = 'position:fixed;right:0;bottom:0;width:0;height:0;border:0;';
192			printFrame.setAttribute('aria-hidden', 'true');
193			const removePrintFrame = () => {
194				if (printFrame.parentNode) {
195					printFrame.parentNode.removeChild(printFrame);
196				}
197			};
198			printFrame.onload = () => {
199				printFrame.contentWindow.focus();
200				printFrame.contentWindow.print();
201				printFrame.contentWindow.addEventListener('afterprint', removePrintFrame);
202				setTimeout(removePrintFrame, 5000);
203			};
204			printFrame.srcdoc = printHtml;
205			document.body.appendChild(printFrame);
206		}
207	}
208});
209// LOAD FORM
210const lang = window.bikyCalculatorData?.lang || 'es';
211if (lang === 'en') {
212	window.addEventListener('load', function () {
213		var configChat = {
214			apiKey: '6b468b19-53eb-40a1-9012-664cafb722d6',
215			containerId: 'calculator-form-en',
216			formId: '6a15c06766bc7706e48857ba',
217			forceLanguage: 'en'
218		};
219		window.keybe.loadFormTesseract(configChat);
220	});
221} else if (lang === 'pt') {
222	window.addEventListener('load', function () {
223		var configChat = {
224			apiKey: '09e731ea-57b7-49ce-8b80-33b534c04801',
225			containerId: 'calculator-form-pt',
226			formId: '6a74a6313cca47d535a438ef',
227			forceLanguage: 'pt'
228		};
229		window.keybe.loadFormTesseract(configChat);
230	});
231} else {
232	window.addEventListener('load', function () {
233		var configChat = {
234			apiKey: '6b468b19-53eb-40a1-9012-664cafb722d6',
235			containerId: 'calculator-form-es',
236			formId: '6a15b58b66bc7706e48853a6'
237		};
238		window.keybe.loadFormTesseract(configChat);
239	});
240}
241window.addEventListener('success_kb_calculator', function (event) {
242	const wrapCalculator = document.querySelector('.biky-price-calculator');
243	if (wrapCalculator) {
244		wrapCalculator.classList.add('show-calculator');
245	}
246});
247

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.