32 lines
1.3 KiB
Markdown
32 lines
1.3 KiB
Markdown
|
|
# Development Guidelines
|
||
|
|
|
||
|
|
## Build/Test Commands
|
||
|
|
```bash
|
||
|
|
python3 -m http.server 8000 # Test: http://localhost:8000
|
||
|
|
# No build system - pure HTML/JS project
|
||
|
|
```
|
||
|
|
|
||
|
|
## Code Style
|
||
|
|
- **JS**: ES6+ vanilla, 2-space indent, semicolons, camelCase methods, PascalCase classes
|
||
|
|
- **Quotes**: Single for JS strings, double for HTML attributes
|
||
|
|
- **DOM**: Cache element refs, check existence before manipulation
|
||
|
|
- **Globals**: Minimize - use class instances for state (e.g., `window.trackingConsent`)
|
||
|
|
- **Errors**: Use console.log for debug, alert/confirm for user interaction
|
||
|
|
|
||
|
|
## Project Structure
|
||
|
|
- `index.html` - Complete demo with all JS/CSS inline
|
||
|
|
- `integration-example.js` - Framework integration examples
|
||
|
|
- `translations` object - i18n with 'en'/'no' ISO codes, localStorage persistence
|
||
|
|
|
||
|
|
## Key APIs
|
||
|
|
```javascript
|
||
|
|
localStorage.getItem('gdpr-tracking-consent') // 'true' or 'false'
|
||
|
|
localStorage.getItem('gdpr-language') // 'en' or 'no'
|
||
|
|
window.trackingConsent.enableTracking() // Programmatic control
|
||
|
|
document.addEventListener('trackingModeChanged', handler) // Events
|
||
|
|
```
|
||
|
|
|
||
|
|
## Integration Notes
|
||
|
|
- Google Analytics: Update consent via `gtag('consent', 'update', {...})`
|
||
|
|
- Cookies: Auto-cleanup of `_ga`, `_gid`, `_gat`, `_fbp`, `_fbc` when disabled
|
||
|
|
- GDPR compliant by default - minimal tracking until explicit consent
|