mirror of
https://github.com/Intense-Finance/BeFree.git
synced 2026-11-16 10:45:24 -06:00
Share cards, special prices, optional hub map links, an off-canvas category menu, dark alerts, and readable light-surface links come from the live theme. Store names, URLs, handles, and product blocks are not included; those settings start blank. Co-authored-by: Intense Finance <if@if.finance>
47 lines
1.8 KiB
JavaScript
47 lines
1.8 KiB
JavaScript
/* BeFree OpenCart Theme — GPLv3 — generated with Grok (xAI). See README.md. */
|
|
(function () {
|
|
function read(id) {
|
|
var el = document.getElementById(id);
|
|
return el ? Number(el.value) : 0;
|
|
}
|
|
function paint() {
|
|
var annual = document.getElementById('pn-annual');
|
|
if (!annual) return;
|
|
var trucks = read('pn-trucks') || 12;
|
|
var gallons = read('pn-gallons') || 8;
|
|
var services = read('pn-services') || 4;
|
|
var total = trucks * gallons * services;
|
|
annual.textContent = total.toLocaleString();
|
|
var advice = document.getElementById('pn-advice');
|
|
if (!advice) return;
|
|
var pack = total > 800 ? 'a bulk tote' : (total > 200 ? 'a drum' : 'case quantity');
|
|
advice.textContent = 'About ' + total.toLocaleString() + ' units a year. Start the quote at ' + pack + ', then confirm the real pack size on the product label.';
|
|
}
|
|
document.addEventListener('input', function (event) {
|
|
if (event.target && event.target.closest && event.target.closest('#pn-advisor')) paint();
|
|
});
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', paint);
|
|
} else {
|
|
paint();
|
|
}
|
|
})();
|
|
|
|
/* Optional obfuscated address: <a class="bf-em" data-e="reversed user|domain">. No address is shipped. */
|
|
(function () {
|
|
function decodeAddresses() {
|
|
document.querySelectorAll('a.bf-em[data-e]').forEach(function (anchor) {
|
|
var raw = anchor.getAttribute('data-e') || '';
|
|
var email = raw.split('').reverse().join('').replace('|', '@');
|
|
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
|
anchor.setAttribute('href', 'mailto:' + email);
|
|
}
|
|
});
|
|
}
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', decodeAddresses);
|
|
} else {
|
|
decodeAddresses();
|
|
}
|
|
})();
|