Vinoteca: wine shop on 1C-Bitrix (module, template, components, pages)

This commit is contained in:
jimagie committed 2026-10-22 19:35:23 +05:00
commit 0590195880
593 files changed
+27942

No files matched your search

@@ -0,0 +1,46 @@
(function () {
function config() {
try {
return JSON.parse(document.getElementById('vino-config').textContent) || {};
} catch (e) {
return {};
}
}
function arm(guard) {
var cfg = config();
if (!guard || !cfg.altcha) return;
if (!document.querySelector('script[data-altcha]')) {
var script = document.createElement('script');
script.type = 'module';
script.src = cfg.altcha;
script.setAttribute('data-altcha', '');
document.head.appendChild(script);
return;
}
if (typeof guard.getState === 'function' && ['verified', 'verifying'].indexOf(guard.getState()) < 0) guard.verify();
}
function armed(guard) {
return new Promise(function (resolve) {
var tick = 0;
(function poll() {
var state = guard && typeof guard.getState === 'function' ? guard.getState() : '';
if (state === 'verified') return resolve(true);
var failed = state === 'error' || state === 'expired';
var idle = state === 'unverified' && tick >= 30;
if ((failed || idle) && tick % 30 === 0) guard.verify();
if (++tick > 150) return resolve(false);
setTimeout(poll, 100);
})();
});
}
function reset(guard) {
if (!guard) return;
if (typeof guard.reset === 'function') guard.reset();
if (typeof guard.verify === 'function') guard.verify();
}
window.VinoAltcha = { arm: arm, armed: armed, reset: reset };
})();