PageSourceSearch

https://suite.st/js/pricing.js

js suite.st collected 2026-09-24 09:22:31 UTC 3,132 bytes, 120 lines download raw bytes

1$(function () {
2	let isDesktopView = false;
3	let usdRate = 1.2;
4	let currentCurrency = 'euro';
5	let currentBillingPeriod = 'annually';
6
7	const priceDataStatic = {
8		sweet: {monthly: 549, annually: 494},
9		superSweet: {monthly: 1039, annually: 935},
10		theSweetest: {monthly: 1859, annually: 1673},
11	};
12
13	function updateView() {
14		isDesktopView = window.matchMedia && window.matchMedia('(min-width: 1200px)').matches;
15	}
16
17	function setPlanExpanding() {
18		$('.plan').on('click', function() {
19			const $plan = $(this);
20
21			if (!isDesktopView) {
22				$plan.toggleClass('expanded').find('a').fadeToggle(200);
23				$plan.find('.details').slideToggle(200);
24			}
25		});
26
27		$('.plan [data-title]').on('click', function(e) {
28			if (!isDesktopView) {
29				e.stopPropagation();
30			}
31		});
32	}
33
34	$(window).on('resize', function() {
35		updateView();
36	});
37
38	function requestDomain() {
39		const hostname = window.location.hostname;
40		const regexToSearch = /.*www-(\w+).suite.st.*/;
41		if (hostname === 'suite.st') {
42			return 'the.suite.st';
43		} else if (regexToSearch.test(hostname)) {
44			return `${hostname.match(regexToSearch)[1]}.suite.st`;
45		} else {
46			return '';
47		}
48	}
49
50	// Fetch exchange rate
51	if (requestDomain()) {
52		fetch(`https://${requestDomain()}/api/exchangeRate`, {method: 'GET', Accept: '*/*',})
53			.then(res => res.json())
54			.then(data => {
55				usdRate = data.eurToUsd;
56				window.pricingUsdRate = usdRate;
57				updateAllPrices();
58			})
59			.catch(err => {
60				console.log('Cannot GET USD rate data', err);
61				updateAllPrices();
62			});
63	} else {
64		updateAllPrices();
65	}
66
67	function updateAllPrices() {
68		updatePriceValues();
69		updateCurrencySymbols();
70	}
71
72	function updatePriceValues() {
73		const dataPriceElements = document.querySelectorAll('[data-price]');
74
75		dataPriceElements.forEach((nodeElement) => {
76			const nodeName = nodeElement.getAttribute('name');
77			if (Object.prototype.hasOwnProperty.call(priceDataStatic, nodeName)) {
78				let price = priceDataStatic[nodeName][currentBillingPeriod];
79
80				// If annually selected, apply 10% discount to monthly price
81				if (currentBillingPeriod === 'annually' && priceDataStatic[nodeName].monthly) {
82					price = Math.round(priceDataStatic[nodeName].monthly * 0.9);
83				}
84
85				// Convert to USD if needed (remove +5%, just multiply by exchange rate)
86				if (currentCurrency === 'dollars') {
87					price = Math.round(price * usdRate);
88				}
89
90				nodeElement.innerText = price;
91			}
92		});
93	}
94
95	function updateCurrencySymbols() {
96		const currencySymbols = document.querySelectorAll('#subscriptions .currency-symbol');
97		const symbol = currentCurrency === 'euro' ? '€' : '$';
98
99		currencySymbols.forEach((el) => {
100			el.innerHTML = symbol;
101		});
102	}
103
104	if (typeof window.registerSwitcherCallback === 'function') {
105		window.registerSwitcherCallback('billing-switcher', function(newPeriod) {
106			currentBillingPeriod = newPeriod;
107			updateAllPrices();
108		});
109
110		window.registerSwitcherCallback('currency-switcher', function(newCurrency) {
111			currentCurrency = newCurrency;
112			updateAllPrices();
113		});
114	} else {
115		console.error('Switcher.js not loaded!');
116	}
117
118	updateView();
119	setPlanExpanding();
120});

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.