dphelper 4.2.2 → 4.3.0
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.
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/package.json +1 -19
- package/types/dphelper.d.ts +1 -1
- package/markdown/ai.md +0 -345
- package/markdown/anchor.md +0 -156
- package/markdown/array.md +0 -208
- package/markdown/audio.md +0 -113
- package/markdown/avoid.md +0 -53
- package/markdown/biometric.md +0 -338
- package/markdown/browser.md +0 -203
- package/markdown/check.md +0 -65
- package/markdown/color.md +0 -159
- package/markdown/compress.md +0 -310
- package/markdown/cookie.md +0 -115
- package/markdown/coords.md +0 -127
- package/markdown/credits.md +0 -56
- package/markdown/date.md +0 -260
- package/markdown/disable.md +0 -109
- package/markdown/dispatch.md +0 -108
- package/markdown/element.md +0 -53
- package/markdown/event.md +0 -85
- package/markdown/fetch.md +0 -122
- package/markdown/form.md +0 -302
- package/markdown/format.md +0 -122
- package/markdown/i18n.md +0 -292
- package/markdown/image.md +0 -298
- package/markdown/json.md +0 -269
- package/markdown/load.md +0 -133
- package/markdown/logging.md +0 -99
- package/markdown/math.md +0 -172
- package/markdown/memory.md +0 -85
- package/markdown/navigation.md +0 -152
- package/markdown/net.md +0 -60
- package/markdown/obj.md +0 -242
- package/markdown/path.md +0 -46
- package/markdown/promise.md +0 -94
- package/markdown/sanitize.md +0 -118
- package/markdown/screen.md +0 -78
- package/markdown/scrollbar.md +0 -82
- package/markdown/security.md +0 -289
- package/markdown/shortcut.md +0 -100
- package/markdown/socket.md +0 -134
- package/markdown/sse.md +0 -120
- package/markdown/svg.md +0 -167
- package/markdown/sync.md +0 -147
- package/markdown/system.md +0 -78
- package/markdown/terminal.md +0 -73
- package/markdown/text.md +0 -245
- package/markdown/timer.md +0 -98
- package/markdown/tools.md +0 -111
- package/markdown/translators.md +0 -65
- package/markdown/trigger.md +0 -99
- package/markdown/triggers.md +0 -133
- package/markdown/type.md +0 -109
- package/markdown/types.md +0 -102
- package/markdown/ui.md +0 -45
- package/markdown/window.md +0 -211
- package/markdown/worker.md +0 -223
package/markdown/date.md
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
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*
|
package/markdown/disable.md
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
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*
|
package/markdown/dispatch.md
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
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*
|
package/markdown/element.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# element
|
|
2
|
-
|
|
3
|
-
Element manipulation utilities for scaling and responsive design.
|
|
4
|
-
|
|
5
|
-
## Functions
|
|
6
|
-
|
|
7
|
-
| Function | Description | Example |
|
|
8
|
-
|----------|-------------|---------|
|
|
9
|
-
| `fitScale` | Scale element based on window size | `dphelper.element.fitScale('#container', 1, true)` |
|
|
10
|
-
| `scaleBasedOnWindow` | Scale element to fit window | `dphelper.element.scaleBasedOnWindow('#chart', 1, false)` |
|
|
11
|
-
|
|
12
|
-
## Description
|
|
13
|
-
|
|
14
|
-
Element scaling and responsive utilities:
|
|
15
|
-
- **Auto Scaling** - Scale elements with window resize
|
|
16
|
-
- **Fit to Window** - Scale to fit or fill viewport
|
|
17
|
-
- **Responsive** - Maintain aspect ratio
|
|
18
|
-
|
|
19
|
-
## Usage Examples
|
|
20
|
-
|
|
21
|
-
### Scale Element
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
// Basic scaling
|
|
25
|
-
dphelper.element.fitScale('#myElement', 1);
|
|
26
|
-
|
|
27
|
-
// Scale to fit window
|
|
28
|
-
dphelper.element.fitScale('#chart', 1, true);
|
|
29
|
-
|
|
30
|
-
// Custom scale
|
|
31
|
-
dphelper.element.fitScale('#preview', 0.5);
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Responsive Charts
|
|
35
|
-
|
|
36
|
-
```javascript
|
|
37
|
-
// Make chart responsive
|
|
38
|
-
dphelper.element.fitScale('#chart-container', 1, true);
|
|
39
|
-
|
|
40
|
-
// Element scales automatically on window resize
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Details
|
|
44
|
-
|
|
45
|
-
- **Author:** Dario Passariello
|
|
46
|
-
- **Version:** 0.0.2
|
|
47
|
-
- **Creation Date:** 20230527
|
|
48
|
-
- **Last Modified:** 20230527
|
|
49
|
-
- **Environment:** Client-side only (browser)
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
*Automatically generated document*
|
package/markdown/event.md
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# event
|
|
2
|
-
|
|
3
|
-
Event handling utilities for DOM events, drag, and keyboard.
|
|
4
|
-
|
|
5
|
-
## Functions
|
|
6
|
-
|
|
7
|
-
| Function | Description | Example |
|
|
8
|
-
|----------|-------------|---------|
|
|
9
|
-
| `list` | Show attached event listeners | `dphelper.event.list(element)` |
|
|
10
|
-
| `multi` | Attach multiple events | `dphelper.event.multi(element, 'click hover', handler)` |
|
|
11
|
-
| `copy` | Click copy element text | to `dphelper.event.copy('#element')` |
|
|
12
|
-
| `onDrag` | Handle element dragging | `dphelper.event.onDrag('.popup')` |
|
|
13
|
-
| `keys` | Get keyboard event properties | `dphelper.event.keys(e)` |
|
|
14
|
-
|
|
15
|
-
## Description
|
|
16
|
-
|
|
17
|
-
Complete event utilities:
|
|
18
|
-
- **Multi Events** - Attach multiple events at once
|
|
19
|
-
- **Drag** - Drag and drop handling
|
|
20
|
-
- **Copy** - Click to copy to clipboard
|
|
21
|
-
- **Keyboard** - Key event properties
|
|
22
|
-
|
|
23
|
-
## Usage Examples
|
|
24
|
-
|
|
25
|
-
### Multiple Event Listeners
|
|
26
|
-
|
|
27
|
-
```javascript
|
|
28
|
-
// Attach multiple events
|
|
29
|
-
dphelper.event.multi(
|
|
30
|
-
document.querySelector('#button'),
|
|
31
|
-
'click hover focus',
|
|
32
|
-
(e) => console.log(e.type)
|
|
33
|
-
);
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Copy to Clipboard
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
// Click element to copy its text
|
|
40
|
-
dphelper.event.copy('#text-to-copy');
|
|
41
|
-
|
|
42
|
-
// User clicks, text is copied to clipboard
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Keyboard Events
|
|
46
|
-
|
|
47
|
-
```javascript
|
|
48
|
-
// Get keyboard event properties
|
|
49
|
-
document.addEventListener('keydown', (e) => {
|
|
50
|
-
const keys = dphelper.event.keys(e);
|
|
51
|
-
|
|
52
|
-
console.log(keys.key); // 'a', 'Enter', 'Escape'
|
|
53
|
-
console.log(keys.ctrl); // true/false
|
|
54
|
-
console.log(keys.alt); // true/false
|
|
55
|
-
console.log(keys.shift); // true/false
|
|
56
|
-
|
|
57
|
-
// Check for shortcuts
|
|
58
|
-
if (keys.ctrl && keys.key === 's') {
|
|
59
|
-
e.preventDefault();
|
|
60
|
-
save();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Drag and Drop
|
|
66
|
-
|
|
67
|
-
```javascript
|
|
68
|
-
// Enable dragging
|
|
69
|
-
dphelper.event.onDrag('.draggable-popup');
|
|
70
|
-
|
|
71
|
-
// Element can now be dragged
|
|
72
|
-
// Position saved to localStorage
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Details
|
|
76
|
-
|
|
77
|
-
- **Author:** Dario Passariello
|
|
78
|
-
- **Version:** 0.0.2
|
|
79
|
-
- **Creation Date:** 20210101
|
|
80
|
-
- **Last Modified:** 20260220
|
|
81
|
-
- **Environment:** Client-side only (browser)
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
*Automatically generated document*
|