dphelper 3.7.1 → 3.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/docs/README.md +385 -0
  2. package/docs/SUMMARY.md +83 -0
  3. package/docs/_config.yml +1 -0
  4. package/docs/markdown/ai.md +345 -0
  5. package/docs/markdown/anchor.md +156 -0
  6. package/docs/markdown/array.md +208 -0
  7. package/docs/markdown/audio.md +113 -0
  8. package/docs/markdown/avoid.md +53 -0
  9. package/docs/markdown/biometric.md +338 -0
  10. package/docs/markdown/browser.md +203 -0
  11. package/docs/markdown/check.md +65 -0
  12. package/docs/markdown/color.md +159 -0
  13. package/docs/markdown/compress.md +310 -0
  14. package/docs/markdown/cookie.md +115 -0
  15. package/docs/markdown/coords.md +127 -0
  16. package/docs/markdown/credits.md +56 -0
  17. package/docs/markdown/date.md +260 -0
  18. package/docs/markdown/disable.md +109 -0
  19. package/docs/markdown/dispatch.md +108 -0
  20. package/docs/markdown/element.md +53 -0
  21. package/docs/markdown/event.md +85 -0
  22. package/docs/markdown/fetch.md +122 -0
  23. package/docs/markdown/form.md +302 -0
  24. package/docs/markdown/format.md +122 -0
  25. package/docs/markdown/i18n.md +292 -0
  26. package/docs/markdown/image.md +298 -0
  27. package/docs/markdown/json.md +269 -0
  28. package/docs/markdown/load.md +133 -0
  29. package/docs/markdown/logging.md +99 -0
  30. package/docs/markdown/math.md +172 -0
  31. package/docs/markdown/memory.md +85 -0
  32. package/docs/markdown/navigation.md +152 -0
  33. package/docs/markdown/net.md +60 -0
  34. package/docs/markdown/obj.md +242 -0
  35. package/docs/markdown/path.md +46 -0
  36. package/docs/markdown/promise.md +94 -0
  37. package/docs/markdown/sanitize.md +118 -0
  38. package/docs/markdown/screen.md +78 -0
  39. package/docs/markdown/scrollbar.md +82 -0
  40. package/docs/markdown/security.md +289 -0
  41. package/docs/markdown/shortcut.md +100 -0
  42. package/docs/markdown/socket.md +134 -0
  43. package/docs/markdown/sse.md +120 -0
  44. package/docs/markdown/svg.md +167 -0
  45. package/docs/markdown/sync.md +147 -0
  46. package/docs/markdown/system.md +78 -0
  47. package/docs/markdown/terminal.md +73 -0
  48. package/docs/markdown/text.md +245 -0
  49. package/docs/markdown/timer.md +98 -0
  50. package/docs/markdown/tools.md +111 -0
  51. package/docs/markdown/translators.md +65 -0
  52. package/docs/markdown/trigger.md +99 -0
  53. package/docs/markdown/triggers.md +133 -0
  54. package/docs/markdown/type.md +109 -0
  55. package/docs/markdown/types.md +102 -0
  56. package/docs/markdown/ui.md +45 -0
  57. package/docs/markdown/window.md +211 -0
  58. package/docs/markdown/worker.md +223 -0
  59. package/index.cjs +1 -1
  60. package/index.js +1 -1
  61. package/package.json +1 -1
@@ -0,0 +1,127 @@
1
+ # coords
2
+
3
+ Coordinate and geometry utilities for GPS, mapping, and calculations.
4
+
5
+ ## Functions
6
+
7
+ | Function | Description | Example |
8
+ |----------|-------------|---------|
9
+ | `degreesToRadians` | Convert degrees to radians | `dphelper.coords.degreesToRadians(45)` |
10
+ | `latToMeters` | Convert latitude to meters | `dphelper.coords.latToMeters([40.68, -74.04])` |
11
+ | `toVector` | Convert coordinates to 3D vector | `dphelper.coords.toVector([lat, lon, alt])` |
12
+ | `convertToDecDegrees` | Convert DMS to decimal degrees | `dphelper.coords.convertToDecDegrees(39, 5, 59, 'N')` |
13
+ | `distance` | Calculate distance between two points (Haversine) | `dphelper.coords.distance([lat1, lon1], [lat2, lon2])` |
14
+ | `polarToCartesian` | Convert polar to Cartesian coordinates | `dphelper.coords.polarToCartesian(x, y, radius, angle)` |
15
+ | `mapDegreesToPixels` | Map degrees to pixel values | `dphelper.coords.mapDegreesToPixels(deg, min, max, minPx, maxPx, pad)` |
16
+
17
+ ## Description
18
+
19
+ Coordinate manipulation toolkit:
20
+ - **Unit Conversion** - Degrees, radians, meters
21
+ - **Distance Calculation** - Haversine formula for GPS
22
+ - **Coordinate Systems** - Polar, Cartesian, 3D vectors
23
+ - **Mapping** - Degrees to pixels for maps
24
+
25
+ ## Usage Examples
26
+
27
+ ### Degree/Radian Conversion
28
+
29
+ ```javascript
30
+ // Degrees to radians
31
+ console.log(dphelper.coords.degreesToRadians(0)); // 0
32
+ console.log(dphelper.coords.degreesToRadians(90)); // 1.57...
33
+ console.log(dphelper.coords.degreesToRadians(180)); // 3.14...
34
+ console.log(dphelper.coords.degreesToRadians(360)); // 6.28...
35
+ ```
36
+
37
+ ### Distance Calculation (GPS)
38
+
39
+ ```javascript
40
+ // Distance between New York and Washington DC
41
+ const nyc = [40.7128, -74.0060];
42
+ const dc = [38.9072, -77.0369];
43
+
44
+ const dist = dphelper.coords.distance(nyc, dc);
45
+ console.log(dist);
46
+ // { km: 328.54, mi: 204.18, nMi: 177.4 }
47
+
48
+ // Calculate travel distance for logistics
49
+ const locations = [
50
+ [40.7128, -74.0060], // NYC
51
+ [39.9526, -75.1652], // Philadelphia
52
+ [39.2894, -76.6152], // Baltimore
53
+ [38.9072, -77.0369] // Washington DC
54
+ ];
55
+
56
+ function calculateTotalDistance(points) {
57
+ let total = 0;
58
+ for (let i = 0; i < points.length - 1; i++) {
59
+ const dist = dphelper.coords.distance(points[i], points[i + 1]);
60
+ total += dist.km;
61
+ }
62
+ return total;
63
+ }
64
+ ```
65
+
66
+ ### Coordinate Conversion
67
+
68
+ ```javascript
69
+ // Convert DMS to decimal degrees
70
+ // 39° 5' 59" N -> decimal
71
+ const dec = dphelper.coords.convertToDecDegrees(39, 5, 59, 'N');
72
+ console.log(dec); // 39.0997...
73
+
74
+ // With South/West (negative)
75
+ const south = dphelper.coords.convertToDecDegrees(33, 51, 30, 'S');
76
+ console.log(south); // -33.8583...
77
+ ```
78
+
79
+ ### 3D Vector from GPS
80
+
81
+ ```javascript
82
+ // Convert GPS coordinates to 3D Earth-centered vector
83
+ const vector = dphelper.coords.toVector([40.7128, -74.0060, 0]);
84
+ console.log(vector);
85
+ // [x, y, z] in meters from Earth center
86
+ ```
87
+
88
+ ### Polar to Cartesian
89
+
90
+ ```javascript
91
+ // Convert polar to Cartesian for graphics
92
+ const cart = dphelper.coords.polarToCartesian(100, 100, 50, 90);
93
+ console.log(cart);
94
+ // { x: 100, y: 150 }
95
+
96
+ // Create circular motion
97
+ for (let angle = 0; angle < 360; angle += 30) {
98
+ const pos = dphelper.coords.polarToCartesian(200, 200, 80, angle);
99
+ console.log(`Angle ${angle}:`, pos);
100
+ }
101
+ ```
102
+
103
+ ### Map Pixel Mapping
104
+
105
+ ```javascript
106
+ // Map latitude to pixel for interactive maps
107
+ const pixel = dphelper.coords.mapDegreesToPixels(
108
+ 45, // Current degree
109
+ 30, // Min latitude
110
+ 60, // Max latitude
111
+ 0, // Min pixel
112
+ 500, // Max pixel
113
+ 10 // Padding
114
+ );
115
+ ```
116
+
117
+ ## Details
118
+
119
+ - **Author:** Dario Passariello
120
+ - **Version:** 0.0.2
121
+ - **Creation Date:** 20210101
122
+ - **Last Modified:** 20260220
123
+ - **Environment:** Client-side only (browser)
124
+
125
+ ---
126
+
127
+ *Automatically generated document*
@@ -0,0 +1,56 @@
1
+ # credits
2
+
3
+ Application startup credits and initialization logger.
4
+
5
+ ## Functions
6
+
7
+ | Function | Description |
8
+ |----------|-------------|
9
+ | `credits` | Logs application startup information to console |
10
+
11
+ ## Description
12
+
13
+ Displays application information on startup:
14
+ - **Version** - Current application version
15
+ - **Author** - Developer credits
16
+ - **Console Logging** - Grouped, styled output
17
+
18
+ ## Usage Examples
19
+
20
+ ### Automatic Startup
21
+
22
+ ```javascript
23
+ // Automatically called on dphelper initialization
24
+ // Shows in console:
25
+ //
26
+ // ┌─────────────────────────────────────┐
27
+ // │ dphelper v1.0.0 │
28
+ // │ by Dario Passariello started │
29
+ // │ name: dphelper │
30
+ // │ version: 1.0.0 │
31
+ // └─────────────────────────────────────┘
32
+
33
+ // Output is styled with orange color for visibility
34
+ ```
35
+
36
+ ### Console Output
37
+
38
+ ```javascript
39
+ // When called, displays:
40
+ // dphelper v1.0.0
41
+ // by Dario Passariello started
42
+ // name: dphelper
43
+ // version: 1.0.0
44
+ ```
45
+
46
+ ## Details
47
+
48
+ - **Author:** Dario Passariello
49
+ - **Version:** 0.0.1
50
+ - **Creation Date:** 20210101
51
+ - **Last Modified:** 20210101
52
+ - **Environment:** Client-side only (browser)
53
+
54
+ ---
55
+
56
+ *Automatically generated document*
@@ -0,0 +1,260 @@
1
+ # date
2
+
3
+ Comprehensive date and time manipulation utilities with support for multiple formats, locales, and timezone handling.
4
+
5
+ ## Functions
6
+
7
+ | Function | Description | Example |
8
+ |----------|-------------|---------|
9
+ | `days` | Returns array of day names in specified language | `dphelper.date.days('en')` |
10
+ | `months` | Returns array of month names in specified language | `dphelper.date.months('en')` |
11
+ | `year` | Returns current year | `dphelper.date.year()` |
12
+ | `toIso` | Converts date to ISO format (localized) | `dphelper.date.toIso(value, 'en')` |
13
+ | `toMMDDYYYY` | Converts to MMDDYYYY format | `dphelper.date.toMMDDYYYY(value)` |
14
+ | `toYYYYMMDD` | Converts to YYYYMMDD format (database-friendly) | `dphelper.date.toYYYYMMDD(value)` |
15
+ | `toHuman` | Converts to human-readable format | `dphelper.date.toHuman(value)` |
16
+ | `convert` | Converts date between formats using month array | `dphelper.date.convert(value, format)` |
17
+ | `iso2Epoch` | Converts ISO date to epoch milliseconds | `dphelper.date.iso2Epoch(value)` |
18
+ | `localIsoTime` | Gets local ISO time for a date | `dphelper.date.localIsoTime(value)` |
19
+ | `utc` | Gets current UTC time string | `dphelper.date.utc()` |
20
+ | `parse` | Parses date with custom separator | `dphelper.date.parse(value, '/')` |
21
+ | `addDays` | Adds days to a date | `dphelper.date.addDays(date, 5)` |
22
+ | `dateTimeToString` | Converts date to formatted string | `dphelper.date.dateTimeToString(date)` |
23
+ | `isoToHuman` | Converts ISO to human format with time | `dphelper.date.isoToHuman(value, '@')` |
24
+ | `fullDate` | Returns DD-MM-YYYY HH:MM:SS format | `dphelper.date.fullDate()` |
25
+ | `epoch` | Returns current epoch time in milliseconds | `dphelper.date.epoch()` |
26
+ | `diffInDays` | Calculates difference between two dates in days | `dphelper.date.diffInDays(d1, d2)` |
27
+ | `diffInWeeks` | Calculates difference between two dates in weeks | `dphelper.date.diffInWeeks(d1, d2)` |
28
+ | `diffInMonths` | Calculates difference between two dates in months | `dphelper.date.diffInMonths(d1, d2)` |
29
+ | `diffInYears` | Calculates difference between two dates in years | `dphelper.date.diffInYears(d1, d2)` |
30
+ | `dateToYMD` | Converts date to YYYY-MM-DD format | `dphelper.date.dateToYMD(date)` |
31
+ | `collection` | Returns various date format representations | `dphelper.date.collection({ type: 'toISOString' })` |
32
+ | `timeZones` | Returns array of all supported timezones | `dphelper.date.timeZones()` |
33
+
34
+ ## Description
35
+
36
+ Complete date manipulation library providing:
37
+ - **Format Conversion** - ISO, MMDDYYYY, YYYYMMDD, human-readable
38
+ - **Localization** - Multi-language day/month names
39
+ - **Timezone Support** - UTC, local time, timezone list
40
+ - **Date Arithmetic** - Add days, calculate differences
41
+ - **Epoch/Unix Time** - Convert to/from milliseconds
42
+ - **Date Collections** - Multiple format representations
43
+
44
+ ## Usage Examples
45
+
46
+ ### Getting Current Date Information
47
+
48
+ ```javascript
49
+ // Get current year
50
+ console.log(dphelper.date.year()); // 2026
51
+
52
+ // Get current UTC time
53
+ console.log(dphelper.date.utc()); // "Mon, 02 Mar 2026 09:44:55 GMT"
54
+
55
+ // Get full date and time
56
+ console.log(dphelper.date.fullDate()); // "02-03-2026 09:44:55"
57
+
58
+ // Get current epoch time
59
+ console.log(dphelper.date.epoch()); // 1709375095000
60
+
61
+ // Get supported timezones
62
+ console.log(dphelper.date.timeZones()); // ["Africa/Abidjan", "America/Adak", ...]
63
+ ```
64
+
65
+ ### Format Conversions
66
+
67
+ ```javascript
68
+ const date = new Date('2026-03-15T10:30:00Z');
69
+
70
+ // To ISO format (localized)
71
+ console.log(dphelper.date.toIso(date, 'en')); // "March 15, 2026"
72
+ console.log(dphelper.date.toIso(date, 'it')); // "15 marzo 2026"
73
+
74
+ // To MMDDYYYY
75
+ console.log(dphelper.date.toMMDDYYYY(date)); // "03152026"
76
+
77
+ // To YYYYMMDD (database format)
78
+ console.log(dphelper.date.toYYYYMMDD(date)); // "20260315"
79
+
80
+ // To human readable
81
+ console.log(dphelper.date.toHuman(date)); // "Sunday, March 15, 2026"
82
+
83
+ // To YYYY-MM-DD
84
+ console.log(dphelper.date.dateToYMD(date)); // "2026-03-15"
85
+
86
+ // ISO to human with custom separator
87
+ console.log(dphelper.date.isoToHuman('2026-03-15T14:30:00', '@'));
88
+ // "15 March 2026 @ 14:30"
89
+ ```
90
+
91
+ ### Date Parsing
92
+
93
+ ```javascript
94
+ // Parse date with custom separator
95
+ console.log(dphelper.date.parse('03152026', '/')); // "03/15/2026"
96
+ console.log(dphelper.date.parse('15.03.2026', '.')); // "15.03.2026"
97
+
98
+ // Convert between formats using month array
99
+ const months = dphelper.date.months('en');
100
+ console.log(dphelper.date.convert('03152026', months)); // "15 March 2026"
101
+ ```
102
+
103
+ ### Date Arithmetic
104
+
105
+ ```javascript
106
+ const today = new Date('2026-03-15');
107
+
108
+ // Add days to a date
109
+ const nextWeek = dphelper.date.addDays(today, 7);
110
+ console.log(nextWeek); // Date object for 2026-03-22
111
+
112
+ const lastMonth = dphelper.date.addDays(today, -30);
113
+ console.log(lastMonth); // Date object for 2026-02-13
114
+ ```
115
+
116
+ ### Date Differences
117
+
118
+ ```javascript
119
+ const date1 = new Date('2026-01-01');
120
+ const date2 = new Date('2026-03-15');
121
+
122
+ // Calculate differences
123
+ console.log(dphelper.date.diffInDays(date1, date2)); // 73 days
124
+ console.log(dphelper.date.diffInWeeks(date1, date2)); // 10 weeks
125
+ console.log(dphelper.date.diffInMonths(date1, date2)); // 2 months
126
+ console.log(dphelper.date.diffInYears(date1, date2)); // 0 years
127
+
128
+ // Calculate age
129
+ const birthDate = new Date('1990-05-20');
130
+ const now = new Date();
131
+ const age = dphelper.date.diffInYears(birthDate, now);
132
+ console.log(age); // 35 (approximately)
133
+ ```
134
+
135
+ ### Epoch/Unix Time Conversion
136
+
137
+ ```javascript
138
+ const isoDate = '2026-03-15T10:30:00Z';
139
+
140
+ // ISO to epoch (milliseconds)
141
+ console.log(dphelper.date.iso2Epoch(isoDate)); // 1778979000000
142
+
143
+ // Current epoch
144
+ console.log(dphelper.date.epoch()); // 1709375095000
145
+
146
+ // Epoch back to date
147
+ const epoch = 1709375095000;
148
+ const date = new Date(epoch);
149
+ console.log(date.toISOString()); // "2026-03-02T09:44:55.000Z"
150
+ ```
151
+
152
+ ### Local vs UTC Time
153
+
154
+ ```javascript
155
+ const date = new Date();
156
+
157
+ // Get local ISO time
158
+ console.log(dphelper.date.localIsoTime(date));
159
+ // "2026-03-02T02:44:55.123"
160
+
161
+ // Get UTC time
162
+ console.log(dphelper.date.utc());
163
+ // "Mon, 02 Mar 2026 09:44:55 GMT"
164
+ ```
165
+
166
+ ### Date Collection (Multiple Formats)
167
+
168
+ ```javascript
169
+ const date = new Date('2026-03-15T14:30:00');
170
+
171
+ // Get various representations
172
+ console.log(dphelper.date.collection({ date, type: 'toDateString' }));
173
+ // "Sun Mar 15 2026"
174
+
175
+ console.log(dphelper.date.collection({ date, type: 'toISOString' }));
176
+ // "2026-03-15T14:30:00.000Z"
177
+
178
+ console.log(dphelper.date.collection({ date, type: 'toLocaleDateString' }));
179
+ // "3/15/2026"
180
+
181
+ console.log(dphelper.date.collection({ date, type: 'toLocaleString' }));
182
+ // "3/15/2026, 7:30:00 AM"
183
+
184
+ console.log(dphelper.date.collection({ date, type: 'toISOStringShort' }));
185
+ // "2026-03-15"
186
+ ```
187
+
188
+ ### Localization
189
+
190
+ ```javascript
191
+ // Get day names in different languages
192
+ console.log(dphelper.date.days('en'));
193
+ // ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
194
+
195
+ console.log(dphelper.date.days('it'));
196
+ // ["lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato", "domenica"]
197
+
198
+ // Get month names in different languages
199
+ console.log(dphelper.date.months('en'));
200
+ // ["January", "February", "March", ...]
201
+
202
+ console.log(dphelper.date.months('it'));
203
+ // ["gennaio", "febbraio", "marzo", ...]
204
+ ```
205
+
206
+ ## Advanced Usage
207
+
208
+ ### Date Range Calculator
209
+
210
+ ```javascript
211
+ function getDateRange(startDate, endDate) {
212
+ const days = dphelper.date.diffInDays(startDate, endDate);
213
+ const weeks = dphelper.date.diffInWeeks(startDate, endDate);
214
+ const months = dphelper.date.diffInMonths(startDate, endDate);
215
+
216
+ return { days, weeks, months };
217
+ }
218
+
219
+ const start = new Date('2026-01-01');
220
+ const end = new Date('2026-12-31');
221
+ console.log(getDateRange(start, end));
222
+ // { days: 364, weeks: 52, months: 11 }
223
+ ```
224
+
225
+ ### Timestamp Logger
226
+
227
+ ```javascript
228
+ function logWithTimestamp(message) {
229
+ const timestamp = dphelper.date.fullDate();
230
+ console.log(`[${timestamp}] ${message}`);
231
+ }
232
+
233
+ logWithTimestamp('Application started');
234
+ // [02-03-2026 09:44:55] Application started
235
+ ```
236
+
237
+ ### Database Date Handler
238
+
239
+ ```javascript
240
+ // Save to database
241
+ const dbDate = dphelper.date.toYYYYMMDD(new Date());
242
+ console.log(dbDate); // "20260302"
243
+
244
+ // Read from database
245
+ const dbValue = "20260315";
246
+ const displayDate = dphelper.date.toHuman(new Date(dbValue));
247
+ console.log(displayDate); // "Sunday, March 15, 2026"
248
+ ```
249
+
250
+ ## Details
251
+
252
+ - **Author:** Dario Passariello
253
+ - **Version:** 0.0.2
254
+ - **Creation Date:** 20210101
255
+ - **Last Modified:** 20260220
256
+ - **Environment:** Works in both client and server environments
257
+
258
+ ---
259
+
260
+ *Automatically generated document*
@@ -0,0 +1,109 @@
1
+ # disable
2
+
3
+ Disabling browser functionalities on DOM elements.
4
+
5
+ ## Functions
6
+
7
+ | Function | Description | Example |
8
+ |----------|-------------|---------|
9
+ | `select` | Disable text selection | `dphelper.disable.select(el)` |
10
+ | `spellCheck` | Disable spell checking | `dphelper.disable.spellCheck(tmr)` |
11
+ | `rightClick` | Disable context menu | `dphelper.disable.rightClick(el)` |
12
+ | `copy` | Disable copy functionality | `dphelper.disable.copy(el)` |
13
+ | `paste` | Disable paste functionality | `dphelper.disable.paste(el)` |
14
+
15
+ ## Description
16
+
17
+ Browser functionality control:
18
+ - **Text Selection** - Prevent user from selecting text
19
+ - **Context Menu** - Disable right-click menu
20
+ - **Clipboard** - Disable copy/paste operations
21
+ - **Spell Check** - Turn off browser spell checking
22
+ - **Element Targeting** - Apply to specific elements or entire page
23
+
24
+ ## Usage Examples
25
+
26
+ ### Disable Text Selection
27
+
28
+ ```javascript
29
+ // Disable selection on entire page
30
+ dphelper.disable.select();
31
+
32
+ // Disable on specific element
33
+ dphelper.disable.select('#protected-content');
34
+
35
+ // Re-enable selection (manual CSS)
36
+ document.body.style.userSelect = 'text';
37
+ ```
38
+
39
+ ### Disable Right-Click Context Menu
40
+
41
+ ```javascript
42
+ // Disable right-click on entire page
43
+ dphelper.disable.rightClick();
44
+
45
+ // Disable on specific container
46
+ dphelper.disable.rightClick('#game-area');
47
+
48
+ // Useful for games or protected content
49
+ const protectedArea = document.getElementById('protected');
50
+ dphelper.disable.rightClick('#protected');
51
+ ```
52
+
53
+ ### Disable Copy/Paste
54
+
55
+ ```javascript
56
+ // Disable copy on specific element
57
+ dphelper.disable.copy('#secure-input');
58
+
59
+ // Disable paste
60
+ dphelper.disable.paste('#no-paste-input');
61
+
62
+ // Combined for form security
63
+ dphelper.disable.copy('. confidential-data');
64
+ dphelper.disable.paste('.confidential-data');
65
+ ```
66
+
67
+ ### Disable Spell Check
68
+
69
+ ```javascript
70
+ // Disable spell check (default 5000ms delay)
71
+ dphelper.disable.spellCheck();
72
+
73
+ // Custom timing
74
+ dphelper.disable.spellCheck(3000);
75
+
76
+ // Apply to text inputs
77
+ document.querySelectorAll('input[type="text"], textarea').forEach(el => {
78
+ el.spellcheck = false;
79
+ });
80
+ ```
81
+
82
+ ### Complete Protection Setup
83
+
84
+ ```javascript
85
+ // Full content protection
86
+ function protectContent(selector) {
87
+ dphelper.disable.select(selector);
88
+ dphelper.disable.rightClick(selector);
89
+ dphelper.disable.copy(selector);
90
+ }
91
+
92
+ // Protect premium article
93
+ protectContent('.premium-content');
94
+
95
+ // Protect user profile
96
+ protectContent('#user-profile');
97
+ ```
98
+
99
+ ## Details
100
+
101
+ - **Author:** Dario Passariello
102
+ - **Version:** 0.0.2
103
+ - **Creation Date:** 20210101
104
+ - **Last Modified:** 20260220
105
+ - **Environment:** client (browser)
106
+
107
+ ---
108
+
109
+ *Automatically generated document*
@@ -0,0 +1,108 @@
1
+ # dispatch
2
+
3
+ Custom event dispatch and listener management utilities.
4
+
5
+ ## Functions
6
+
7
+ | Function | Description | Example |
8
+ |----------|-------------|---------|
9
+ | `set` | Dispatch a custom event | `dphelper.dispatch.set('myEvent', { detail: data })` |
10
+ | `listen` | Listen for custom events | `dphelper.dispatch.listen('myEvent', callback)` |
11
+ | `remove` | Remove event listener | `dphelper.dispatch.remove('myEvent')` |
12
+
13
+ ## Description
14
+
15
+ Custom event management:
16
+ - **Dispatch** - Fire custom events with data
17
+ - **Listen** - Register event handlers
18
+ - **Manage** - Remove listeners
19
+
20
+ ## Usage Examples
21
+
22
+ ### Dispatching Events
23
+
24
+ ```javascript
25
+ // Simple event
26
+ dphelper.dispatch.set('user:login');
27
+
28
+ // With data
29
+ dphelper.dispatch.set('user:login', {
30
+ detail: { userId: 123, timestamp: Date.now() }
31
+ });
32
+
33
+ // Application events
34
+ dphelper.dispatch.set('app:loaded');
35
+ dphelper.dispatch.set('data:updated', { detail: { source: 'api' } });
36
+ ```
37
+
38
+ ### Listening for Events
39
+
40
+ ```javascript
41
+ // Listen for event
42
+ dphelper.dispatch.listen('user:login', (e) => {
43
+ console.log('User logged in:', e.detail);
44
+ });
45
+
46
+ // Multiple handlers
47
+ dphelper.dispatch.listen('data:updated', (e) => {
48
+ console.log('Data updated:', e.detail);
49
+ });
50
+
51
+ // App lifecycle
52
+ dphelper.dispatch.listen('app:loaded', () => {
53
+ console.log('App ready!');
54
+ initializeApp();
55
+ });
56
+ ```
57
+
58
+ ### Removing Listeners
59
+
60
+ ```javascript
61
+ // Remove specific listener
62
+ dphelper.dispatch.remove('user:login');
63
+
64
+ // Clean up on component unmount
65
+ function cleanup() {
66
+ dphelper.dispatch.remove('myEvent');
67
+ }
68
+ ```
69
+
70
+ ### Complete Event System
71
+
72
+ ```javascript
73
+ class EventBus {
74
+ constructor() {
75
+ this.listeners = {};
76
+ }
77
+
78
+ on(event, callback) {
79
+ dphelper.dispatch.listen(event, callback);
80
+ }
81
+
82
+ emit(event, data) {
83
+ dphelper.dispatch.set(event, { detail: data });
84
+ }
85
+
86
+ off(event) {
87
+ dphelper.dispatch.remove(event);
88
+ }
89
+ }
90
+
91
+ // Usage
92
+ const events = new EventBus();
93
+
94
+ events.on('user:action', (e) => console.log('Action:', e.detail));
95
+ events.emit('user:action', { type: 'click', target: 'button' });
96
+ ```
97
+
98
+ ## Details
99
+
100
+ - **Author:** Dario Passariello
101
+ - **Version:** 0.0.2
102
+ - **Creation Date:** 20231231
103
+ - **Last Modified:** 20240612
104
+ - **Environment:** Client-side only (browser)
105
+
106
+ ---
107
+
108
+ *Automatically generated document*