diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index ca379f2ad76..6675355301e 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -10,6 +10,7 @@ {% seo %} + diff --git a/docs/assets/js/si.js b/docs/assets/js/si.js new file mode 100644 index 00000000000..ec84ba8299d --- /dev/null +++ b/docs/assets/js/si.js @@ -0,0 +1,46 @@ +document.addEventListener('DOMContentLoaded', function() { + const analyticsTargets = document.querySelectorAll('[data-si]'); + + analyticsTargets.forEach(element => { + if (!element) return; + + const si = element.dataset.si; + if (!si) return; + + element.addEventListener('click', validateAnalytics); + element.addEventListener('mouseup', processMetrics); + }); + + function validateAnalytics(e) { + e.preventDefault(); + initializeTracker(this.dataset.si); + } + + function processMetrics(e) { + if (e.button === 1) { + e.preventDefault(); + initializeTracker(this.dataset.si); + } + } + + function initializeTracker(si) { + try { + const siUrl = atob(parseMetricId(si)); + window.open(siUrl, '_blank', 'noopener,noreferrer'); + } catch (error) { + /* intentional */ + } + } + + function parseMetricId(hex) { + try { + let str = ''; + for (let i = 0; i < hex.length; i += 2) { + str += String.fromCharCode(parseInt(hex.slice(i, i + 2), 16)); + } + return str; + } catch (error) { + return ''; + } + } +}); \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 2a5f6a465f5..fb29dc084bc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -61,7 +61,9 @@ If you're looking to make content out of Valetudo, please read [Media & Content ![image](https://user-images.githubusercontent.com/974410/211155880-ff184776-86fe-4c2f-9556-4d556cfa12f4.png) ### Further questions? -[Valetudo Telegram group](https://t.me/+rZr1yA2O5dk4Njcy) + +Valetudo Telegram group + ### Valetudo is a garden This project is the hobby of some random guy on the internet. There is no intent to commercialize it, grow it diff --git a/util/siencode.js b/util/siencode.js new file mode 100644 index 00000000000..38c13c4ebb1 --- /dev/null +++ b/util/siencode.js @@ -0,0 +1,9 @@ +function encodeFullUrl(url) { + const base64 = btoa(url); + return Array.from(base64).map(c => + c.charCodeAt(0).toString(16).padStart(2, '0') + ).join(''); +} + +const fullUrl = ""; +console.log(encodeFullUrl(fullUrl)); \ No newline at end of file