Refactor privacy notice implementation in index.html

- Introduced a dedicated function to display the privacy notice for users of the open source version.
- Updated the styling and content of the privacy notice for improved visibility and clarity.
- Added a DOMContentLoaded event listener to conditionally show the notice based on the environment and previous interactions.
This commit is contained in:
chamiakJ
2025-06-12 09:34:53 +05:30
parent e9f0162439
commit 1889c58598

View File

@@ -43,33 +43,44 @@
// Initialize analytics // Initialize analytics
initGoogleAnalytics(); initGoogleAnalytics();
// Show privacy notice only for open source version // Function to show privacy notice
if (window.location.hostname !== 'worklenz.com' && function showPrivacyNotice() {
window.location.hostname !== 'app.worklenz.com' &&
!localStorage.getItem('privacyNoticeShown')) {
const notice = document.createElement('div'); const notice = document.createElement('div');
notice.style.cssText = ` notice.style.cssText = `
position: fixed; position: fixed;
bottom: 20px; bottom: 16px;
right: 20px; right: 16px;
background: #fff; background: #222;
padding: 20px; color: #f5f5f5;
border-radius: 8px; padding: 12px 16px 10px 16px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1); border-radius: 7px;
box-shadow: 0 2px 8px rgba(0,0,0,0.18);
z-index: 1000; z-index: 1000;
max-width: 400px; max-width: 320px;
font-family: Inter, sans-serif; font-family: Inter, sans-serif;
border: 1px solid #333;
font-size: 0.95rem;
`; `;
notice.innerHTML = ` notice.innerHTML = `
<h3 style="margin-top: 0;">Analytics Notice</h3> <div style="margin-bottom: 6px; font-weight: 600; color: #fff; font-size: 1rem;">Analytics Notice</div>
<p>This open source project uses Google Analytics to understand usage patterns and improve the application.</p> <div style="margin-bottom: 8px; color: #f5f5f5;">This app uses Google Analytics for anonymous usage stats. No personal data is tracked.</div>
<p>We only collect anonymous usage data. No personal information is tracked.</p> <button onclick="this.parentElement.parentElement.remove(); localStorage.setItem('privacyNoticeShown', 'true');" style="padding: 5px 14px; background: #1890ff; color: white; border: none; border-radius: 3px; cursor: pointer; font-size: 0.95rem;">Got it</button>
<div style="display: flex; gap: 10px; margin-top: 15px;">
<button onclick="this.parentElement.parentElement.remove(); localStorage.setItem('privacyNoticeShown', 'true');" style="padding: 8px 16px; background: #1890ff; color: white; border: none; border-radius: 4px; cursor: pointer;">Got it</button>
</div>
`; `;
document.body.appendChild(notice); document.body.appendChild(notice);
} }
// Wait for DOM to be ready
document.addEventListener('DOMContentLoaded', function() {
// Check if we should show the notice
const isProduction = window.location.hostname === 'worklenz.com' ||
window.location.hostname === 'app.worklenz.com';
const noticeShown = localStorage.getItem('privacyNoticeShown') === 'true';
// Show notice if not in production and not shown before
if (!isProduction && !noticeShown) {
showPrivacyNotice();
}
});
</script> </script>
</head> </head>