@iobroker/adapter-react-v5 3.1.34 → 3.1.35
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/Components/404.js +0 -23
- package/Components/404.js.map +1 -1
- package/Components/ColorPicker.js +6 -37
- package/Components/ColorPicker.js.map +1 -1
- package/Components/ComplexCron.js +10 -84
- package/Components/ComplexCron.js.map +1 -1
- package/Components/CustomModal.js +29 -54
- package/Components/CustomModal.js.map +1 -1
- package/Components/FileBrowser.js +15 -265
- package/Components/FileBrowser.js.map +1 -1
- package/Components/FileViewer.js +7 -68
- package/Components/FileViewer.js.map +1 -1
- package/Components/Icon.d.ts +1 -1
- package/Components/Icon.js +2 -42
- package/Components/Icon.js.map +1 -1
- package/Components/IconPicker.js +6 -28
- package/Components/IconPicker.js.map +1 -1
- package/Components/IconSelector.js +3 -55
- package/Components/IconSelector.js.map +1 -1
- package/Components/Image.js +1 -38
- package/Components/Image.js.map +1 -1
- package/Components/JsonConfigComponent/ChipInput.js +66 -197
- package/Components/JsonConfigComponent/ChipInput.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigAlive.js +0 -31
- package/Components/JsonConfigComponent/ConfigAlive.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigAutocomplete.js +6 -39
- package/Components/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js +6 -52
- package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigCRON.js +5 -39
- package/Components/JsonConfigComponent/ConfigCRON.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigCertificateSelect.js +4 -42
- package/Components/JsonConfigComponent/ConfigCertificateSelect.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigCheckbox.js +0 -28
- package/Components/JsonConfigComponent/ConfigCheckbox.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigChip.js +4 -33
- package/Components/JsonConfigComponent/ConfigChip.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigColor.js +0 -34
- package/Components/JsonConfigComponent/ConfigColor.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigCoordinates.js +0 -33
- package/Components/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigCustom.js +14 -73
- package/Components/JsonConfigComponent/ConfigCustom.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigDatePicker.js +0 -25
- package/Components/JsonConfigComponent/ConfigDatePicker.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigFile.js +0 -46
- package/Components/JsonConfigComponent/ConfigFile.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigFileSelector.js +7 -126
- package/Components/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigFunc.js +0 -34
- package/Components/JsonConfigComponent/ConfigFunc.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigGeneric.js +15 -110
- package/Components/JsonConfigComponent/ConfigGeneric.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigIP.js +2 -35
- package/Components/JsonConfigComponent/ConfigIP.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigImageUpload.js +4 -44
- package/Components/JsonConfigComponent/ConfigImageUpload.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigInstanceSelect.js +1 -59
- package/Components/JsonConfigComponent/ConfigInstanceSelect.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigJsonEditor.js +7 -40
- package/Components/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigLanguage.js +2 -42
- package/Components/JsonConfigComponent/ConfigLanguage.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigNumber.js +2 -45
- package/Components/JsonConfigComponent/ConfigNumber.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigObjectId.js +6 -40
- package/Components/JsonConfigComponent/ConfigObjectId.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigPanel.js +7 -91
- package/Components/JsonConfigComponent/ConfigPanel.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigPassword.js +0 -42
- package/Components/JsonConfigComponent/ConfigPassword.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigPattern.js +0 -25
- package/Components/JsonConfigComponent/ConfigPattern.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigRoom.js +0 -34
- package/Components/JsonConfigComponent/ConfigRoom.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigSelect.js +4 -34
- package/Components/JsonConfigComponent/ConfigSelect.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigSelectSendTo.js +11 -67
- package/Components/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigSendto.js +8 -91
- package/Components/JsonConfigComponent/ConfigSendto.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigSetState.js +0 -55
- package/Components/JsonConfigComponent/ConfigSetState.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigSlider.js +0 -28
- package/Components/JsonConfigComponent/ConfigSlider.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigStaticDivider.js +0 -21
- package/Components/JsonConfigComponent/ConfigStaticDivider.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigStaticHeader.js +0 -24
- package/Components/JsonConfigComponent/ConfigStaticHeader.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigStaticImage.js +0 -23
- package/Components/JsonConfigComponent/ConfigStaticImage.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigStaticText.js +0 -31
- package/Components/JsonConfigComponent/ConfigStaticText.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigTable.js +13 -105
- package/Components/JsonConfigComponent/ConfigTable.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigTabs.js +2 -35
- package/Components/JsonConfigComponent/ConfigTabs.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigText.js +0 -34
- package/Components/JsonConfigComponent/ConfigText.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigTextSendTo.js +0 -37
- package/Components/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigTimePicker.js +0 -25
- package/Components/JsonConfigComponent/ConfigTimePicker.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigTopic.js +0 -29
- package/Components/JsonConfigComponent/ConfigTopic.js.map +1 -1
- package/Components/JsonConfigComponent/ConfigUser.js +2 -40
- package/Components/JsonConfigComponent/ConfigUser.js.map +1 -1
- package/Components/JsonConfigComponent/index.js +5 -81
- package/Components/JsonConfigComponent/index.js.map +1 -1
- package/Components/Loader.js +2 -20
- package/Components/Loader.js.map +1 -1
- package/Components/Loaders/PT.js +2 -20
- package/Components/Loaders/PT.js.map +1 -1
- package/Components/Loaders/Vendor.js +2 -21
- package/Components/Loaders/Vendor.js.map +1 -1
- package/Components/Logo.js +6 -39
- package/Components/Logo.js.map +1 -1
- package/Components/MDUtils.js +3 -27
- package/Components/MDUtils.js.map +1 -1
- package/Components/ObjectBrowser.d.ts +1 -1
- package/Components/ObjectBrowser.js +181 -788
- package/Components/ObjectBrowser.js.map +1 -1
- package/Components/Router.js +7 -31
- package/Components/Router.js.map +1 -1
- package/Components/SaveCloseButtons.js +2 -32
- package/Components/SaveCloseButtons.js.map +1 -1
- package/Components/Schedule.js +29 -251
- package/Components/Schedule.js.map +1 -1
- package/Components/SelectWithIcon.d.ts +1 -1
- package/Components/SelectWithIcon.js +0 -48
- package/Components/SelectWithIcon.js.map +1 -1
- package/Components/SimpleCron/cron2text.js +45 -91
- package/Components/SimpleCron/cron2text.js.map +1 -1
- package/Components/SimpleCron/cronText.js +0 -6
- package/Components/SimpleCron/cronText.js.map +1 -1
- package/Components/SimpleCron/index.js +19 -102
- package/Components/SimpleCron/index.js.map +1 -1
- package/Components/SimpleCron/jquery.cron.locale.js +44 -24
- package/Components/SimpleCron/jquery.cron.locale.js.map +1 -1
- package/Components/TabContainer.js +2 -23
- package/Components/TabContainer.js.map +1 -1
- package/Components/TabContent.js +2 -22
- package/Components/TabContent.js.map +1 -1
- package/Components/TabHeader.js +1 -17
- package/Components/TabHeader.js.map +1 -1
- package/Components/TableResize.js +6 -51
- package/Components/TableResize.js.map +1 -1
- package/Components/TextWithIcon.js +0 -20
- package/Components/TextWithIcon.js.map +1 -1
- package/Components/ToggleThemeMenu.js +5 -13
- package/Components/ToggleThemeMenu.js.map +1 -1
- package/Components/TreeTable.js +4 -121
- package/Components/TreeTable.js.map +1 -1
- package/Components/UploadImage.js +17 -60
- package/Components/UploadImage.js.map +1 -1
- package/Components/Utils.js +87 -263
- package/Components/Utils.js.map +1 -1
- package/Components/copy-to-clipboard.js +16 -38
- package/Components/copy-to-clipboard.js.map +1 -1
- package/Components/withWidth.js +2 -10
- package/Components/withWidth.js.map +1 -1
- package/Connection.d.ts +1 -0
- package/Connection.js +156 -527
- package/Connection.js.map +1 -1
- package/Dialogs/ComplexCron.js +0 -34
- package/Dialogs/ComplexCron.js.map +1 -1
- package/Dialogs/Confirm.js +1 -39
- package/Dialogs/Confirm.js.map +1 -1
- package/Dialogs/Cron.js +1 -37
- package/Dialogs/Cron.js.map +1 -1
- package/Dialogs/Error.d.ts +1 -1
- package/Dialogs/Error.js +2 -29
- package/Dialogs/Error.js.map +1 -1
- package/Dialogs/FileSelect.js +2 -36
- package/Dialogs/FileSelect.js.map +1 -1
- package/Dialogs/Message.js +2 -27
- package/Dialogs/Message.js.map +1 -1
- package/Dialogs/SelectID.d.ts +1 -1
- package/Dialogs/SelectID.js +3 -40
- package/Dialogs/SelectID.js.map +1 -1
- package/Dialogs/SimpleCron.js +1 -33
- package/Dialogs/SimpleCron.js.map +1 -1
- package/Dialogs/TextInput.js +2 -34
- package/Dialogs/TextInput.js.map +1 -1
- package/GenericApp.js +54 -150
- package/GenericApp.js.map +1 -1
- package/Prompt.js +0 -2
- package/Prompt.js.map +1 -1
- package/README.md +8 -4
- package/Theme.js +7 -22
- package/Theme.js.map +1 -1
- package/i18n.d.ts +2 -0
- package/i18n.js +9 -29
- package/i18n.js.map +1 -1
- package/icons/IconAdapter.d.ts +2 -2
- package/icons/IconAdapter.js +2 -6
- package/icons/IconAdapter.js.map +1 -1
- package/icons/IconAlias.d.ts +2 -2
- package/icons/IconAlias.js +2 -6
- package/icons/IconAlias.js.map +1 -1
- package/icons/IconChannel.d.ts +2 -2
- package/icons/IconChannel.js +2 -6
- package/icons/IconChannel.js.map +1 -1
- package/icons/IconClearFilter.d.ts +2 -2
- package/icons/IconClearFilter.js +0 -5
- package/icons/IconClearFilter.js.map +1 -1
- package/icons/IconClosed.d.ts +2 -2
- package/icons/IconClosed.js +0 -5
- package/icons/IconClosed.js.map +1 -1
- package/icons/IconCopy.d.ts +2 -2
- package/icons/IconCopy.js +0 -5
- package/icons/IconCopy.js.map +1 -1
- package/icons/IconDevice.d.ts +2 -2
- package/icons/IconDevice.js +0 -5
- package/icons/IconDevice.js.map +1 -1
- package/icons/IconDocument.d.ts +2 -2
- package/icons/IconDocument.js +0 -5
- package/icons/IconDocument.js.map +1 -1
- package/icons/IconDocumentReadOnly.d.ts +2 -2
- package/icons/IconDocumentReadOnly.js +0 -5
- package/icons/IconDocumentReadOnly.js.map +1 -1
- package/icons/IconExpert.d.ts +2 -2
- package/icons/IconExpert.js +0 -5
- package/icons/IconExpert.js.map +1 -1
- package/icons/IconFx.d.ts +2 -2
- package/icons/IconFx.js +0 -5
- package/icons/IconFx.js.map +1 -1
- package/icons/IconInstance.d.ts +2 -2
- package/icons/IconInstance.js +0 -5
- package/icons/IconInstance.js.map +1 -1
- package/icons/IconLogout.d.ts +2 -2
- package/icons/IconLogout.js +0 -5
- package/icons/IconLogout.js.map +1 -1
- package/icons/IconNoIcon.d.ts +2 -2
- package/icons/IconNoIcon.js +0 -5
- package/icons/IconNoIcon.js.map +1 -1
- package/icons/IconOpen.d.ts +2 -2
- package/icons/IconOpen.js +0 -5
- package/icons/IconOpen.js.map +1 -1
- package/icons/IconState.d.ts +2 -2
- package/icons/IconState.js +0 -6
- package/icons/IconState.js.map +1 -1
- package/package.json +15 -15
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Given a cronspec, return the human-readable string.
|
|
10
9
|
* @param {string} cronspec
|
|
@@ -33,8 +32,9 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
33
32
|
THU: 5,
|
|
34
33
|
FRI: 6,
|
|
35
34
|
SAT: 7
|
|
36
|
-
};
|
|
35
|
+
};
|
|
37
36
|
|
|
37
|
+
// Parsable replacements for common expressions
|
|
38
38
|
var REPLACEMENTS = {
|
|
39
39
|
'* * * * * *': '0/1 * * * * *',
|
|
40
40
|
'@YEARLY': '0 0 1 1 *',
|
|
@@ -43,8 +43,9 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
43
43
|
'@WEEKLY': '0 0 * * 0',
|
|
44
44
|
'@DAILY': '0 0 * * *',
|
|
45
45
|
'@HOURLY': '0 * * * *'
|
|
46
|
-
};
|
|
46
|
+
};
|
|
47
47
|
|
|
48
|
+
// Contains the index, min, and max for each of the constraints
|
|
48
49
|
var FIELDS = {
|
|
49
50
|
s: [0, 0, 59],
|
|
50
51
|
// seconds
|
|
@@ -59,8 +60,8 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
59
60
|
Y: [6, 1970, 2099],
|
|
60
61
|
// year
|
|
61
62
|
d: [5, 1, 7, 1] // day of week
|
|
62
|
-
|
|
63
63
|
};
|
|
64
|
+
|
|
64
65
|
/**
|
|
65
66
|
* Returns the value + offset if value is a number, otherwise it
|
|
66
67
|
* attempts to look up the value in the NAMES table and returns
|
|
@@ -71,12 +72,12 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
71
72
|
* @param {Number=} max
|
|
72
73
|
* @returns {Number|null}
|
|
73
74
|
*/
|
|
74
|
-
|
|
75
75
|
function getValue(value) {
|
|
76
76
|
var offset = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
|
|
77
77
|
var max = arguments.length <= 2 || arguments[2] === undefined ? 9999 : arguments[2];
|
|
78
78
|
return isNaN(value) ? NAMES[value] || null : Math.min(+value + offset, max);
|
|
79
79
|
}
|
|
80
|
+
|
|
80
81
|
/**
|
|
81
82
|
* Returns a deep clone of a schedule skipping any day of week
|
|
82
83
|
* constraints.
|
|
@@ -84,20 +85,17 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
84
85
|
* @param {Object} sched: The schedule that will be cloned
|
|
85
86
|
* @returns {Object}
|
|
86
87
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
88
|
function cloneSchedule(sched) {
|
|
90
89
|
var clone = {};
|
|
91
90
|
var field;
|
|
92
|
-
|
|
93
91
|
for (field in sched) {
|
|
94
92
|
if (field !== 'dc' && field !== 'd') {
|
|
95
93
|
clone[field] = sched[field].slice(0);
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
|
-
|
|
99
96
|
return clone;
|
|
100
97
|
}
|
|
98
|
+
|
|
101
99
|
/**
|
|
102
100
|
* Adds values to the specified constraint in the current schedule.
|
|
103
101
|
*
|
|
@@ -106,28 +104,23 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
106
104
|
* @param {Number} min: Minimum value for this constraint
|
|
107
105
|
* @param {Number} max: Maximum value for this constraint
|
|
108
106
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
107
|
function add(sched, name, min, max) {
|
|
112
108
|
var inc = arguments.length <= 4 || arguments[4] === undefined ? 0 : arguments[4];
|
|
113
109
|
var i = min;
|
|
114
|
-
|
|
115
110
|
if (!sched[name]) {
|
|
116
111
|
sched[name] = [];
|
|
117
112
|
}
|
|
118
|
-
|
|
119
113
|
while (i <= max) {
|
|
120
114
|
if (sched[name].indexOf(i) < 0) {
|
|
121
115
|
sched[name].push(i);
|
|
122
116
|
}
|
|
123
|
-
|
|
124
117
|
i += inc || 1;
|
|
125
118
|
}
|
|
126
|
-
|
|
127
119
|
sched[name].sort(function (a, b) {
|
|
128
120
|
return a - b;
|
|
129
121
|
});
|
|
130
122
|
}
|
|
123
|
+
|
|
131
124
|
/**
|
|
132
125
|
* Adds a hash item (of the form x#y or xL) to the schedule.
|
|
133
126
|
*
|
|
@@ -136,8 +129,6 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
136
129
|
* @param {Number} value: The value to add (x of x#y or xL)
|
|
137
130
|
* @param {Number} hash: The hash value to add (y of x#y)
|
|
138
131
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
132
|
function addHash(schedules, curSched, value, hash) {
|
|
142
133
|
// if there are any existing day of week constraints that
|
|
143
134
|
// aren't equal to the one we're adding, create a new
|
|
@@ -146,22 +137,19 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
146
137
|
schedules.push(cloneSchedule(curSched));
|
|
147
138
|
curSched = schedules[schedules.length - 1];
|
|
148
139
|
}
|
|
149
|
-
|
|
150
140
|
add(curSched, 'd', value, value);
|
|
151
141
|
add(curSched, 'dc', hash, hash);
|
|
152
142
|
}
|
|
143
|
+
|
|
153
144
|
/**
|
|
154
145
|
*
|
|
155
146
|
* @param {Object} s: The existing set of schedules
|
|
156
147
|
* @param {Object} curSched: The current schedule to add to
|
|
157
148
|
* @param {Number} value
|
|
158
149
|
*/
|
|
159
|
-
|
|
160
|
-
|
|
161
150
|
function addWeekday(s, curSched, value) {
|
|
162
151
|
var except1 = {},
|
|
163
|
-
|
|
164
|
-
|
|
152
|
+
except2 = {};
|
|
165
153
|
if (value === 1) {
|
|
166
154
|
// cron doesn't pass month boundaries, so if 1st is a
|
|
167
155
|
// weekend then we need to use 2nd or 3rd instead
|
|
@@ -182,10 +170,10 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
182
170
|
add(except2, 'D', value + 1, value + 1);
|
|
183
171
|
add(except2, 'd', NAMES.TUE, NAMES.FRI);
|
|
184
172
|
}
|
|
185
|
-
|
|
186
173
|
s.exceptions.push(except1);
|
|
187
174
|
s.exceptions.push(except2);
|
|
188
175
|
}
|
|
176
|
+
|
|
189
177
|
/**
|
|
190
178
|
* Adds a range item (of the form x-y/z) to the schedule.
|
|
191
179
|
*
|
|
@@ -196,23 +184,23 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
196
184
|
* @param {Number} max: The max value for the constraint
|
|
197
185
|
* @param {Number} offset: The offset to apply to the cron value
|
|
198
186
|
*/
|
|
199
|
-
|
|
200
|
-
|
|
201
187
|
function addRange(item, curSched, name, min, max, offset) {
|
|
202
188
|
// parse range/x
|
|
203
189
|
var incSplit = item.split('/'),
|
|
204
|
-
|
|
205
|
-
|
|
190
|
+
inc = +incSplit[1],
|
|
191
|
+
range = incSplit[0];
|
|
206
192
|
|
|
193
|
+
// parse x-y or * or 0
|
|
207
194
|
if (range !== '*' && range !== '0') {
|
|
208
195
|
var rangeSplit = range.split('-');
|
|
209
|
-
min = getValue(rangeSplit[0], offset, max);
|
|
196
|
+
min = getValue(rangeSplit[0], offset, max);
|
|
210
197
|
|
|
198
|
+
// fix for issue #13, range may be single digit
|
|
211
199
|
max = getValue(rangeSplit[1], offset, max) || max;
|
|
212
200
|
}
|
|
213
|
-
|
|
214
201
|
add(curSched, name, min, max, inc);
|
|
215
202
|
}
|
|
203
|
+
|
|
216
204
|
/**
|
|
217
205
|
* Parses a particular item within a cron expression.
|
|
218
206
|
*
|
|
@@ -223,58 +211,58 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
223
211
|
* @param {Number} max: The max value for the constraint
|
|
224
212
|
* @param {Number} offset: The offset to apply to the cron value
|
|
225
213
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
228
214
|
function parse(item, s, name, min, max, offset) {
|
|
229
215
|
var value,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
216
|
+
split,
|
|
217
|
+
schedules = s.schedules,
|
|
218
|
+
curSched = schedules[schedules.length - 1];
|
|
233
219
|
|
|
220
|
+
// L just means min - 1 (this also makes it work for any field)
|
|
234
221
|
if (item === 'L') {
|
|
235
222
|
item = (min - 1).toString(10);
|
|
236
|
-
}
|
|
237
|
-
|
|
223
|
+
}
|
|
238
224
|
|
|
225
|
+
// parse x
|
|
239
226
|
if ((value = getValue(item, offset, max)) !== null) {
|
|
240
227
|
add(curSched, name, value, value);
|
|
241
|
-
}
|
|
228
|
+
}
|
|
229
|
+
// parse xW
|
|
242
230
|
else if ((value = getValue(item.replace('W', ''), offset, max)) !== null) {
|
|
243
231
|
addWeekday(s, curSched, value);
|
|
244
|
-
}
|
|
232
|
+
}
|
|
233
|
+
// parse xL
|
|
245
234
|
else if ((value = getValue(item.replace('L', ''), offset, max)) !== null) {
|
|
246
235
|
addHash(schedules, curSched, value, min - 1);
|
|
247
|
-
}
|
|
236
|
+
}
|
|
237
|
+
// parse x#y
|
|
248
238
|
else if ((split = item.split('#')).length === 2) {
|
|
249
239
|
value = getValue(split[0], offset, max);
|
|
250
240
|
addHash(schedules, curSched, value, getValue(split[1]));
|
|
251
|
-
}
|
|
241
|
+
}
|
|
242
|
+
// parse x-y or x-y/z or */z or 0/z
|
|
252
243
|
else {
|
|
253
244
|
addRange(item, curSched, name, min, max, offset);
|
|
254
245
|
}
|
|
255
246
|
}
|
|
247
|
+
|
|
256
248
|
/**
|
|
257
249
|
* Returns true if the item is either of the form x#y or xL.
|
|
258
250
|
*
|
|
259
251
|
* @param {String} item: The expression item to check
|
|
260
252
|
*/
|
|
261
|
-
|
|
262
|
-
|
|
263
253
|
function isHash(item) {
|
|
264
254
|
return item.indexOf('#') > -1 || item.indexOf('L') > 0;
|
|
265
255
|
}
|
|
266
|
-
|
|
267
256
|
function itemSorter(a, b) {
|
|
268
257
|
return isHash(a) && !isHash(b) ? 1 : a - b;
|
|
269
258
|
}
|
|
259
|
+
|
|
270
260
|
/**
|
|
271
261
|
* Parses each of the fields in a cron expression. The expression must
|
|
272
262
|
* include the seconds field, the year field is optional.
|
|
273
263
|
*
|
|
274
264
|
* @param {String} expr: The cron expression to parse
|
|
275
265
|
*/
|
|
276
|
-
|
|
277
|
-
|
|
278
266
|
function parseExpr(expr) {
|
|
279
267
|
var schedule = {
|
|
280
268
|
schedules: [{}],
|
|
@@ -285,11 +273,9 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
285
273
|
var f;
|
|
286
274
|
var component;
|
|
287
275
|
var items;
|
|
288
|
-
|
|
289
276
|
for (field in FIELDS) {
|
|
290
277
|
f = FIELDS[field];
|
|
291
278
|
component = components[f[0]];
|
|
292
|
-
|
|
293
279
|
if (component && component !== '*' && component !== '?') {
|
|
294
280
|
// need to sort so that any #'s come last, otherwise
|
|
295
281
|
// schedule clones to handle # won't contain all of the
|
|
@@ -297,34 +283,28 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
297
283
|
items = component.split(',').sort(itemSorter);
|
|
298
284
|
var i = void 0;
|
|
299
285
|
var length = items.length;
|
|
300
|
-
|
|
301
286
|
for (i = 0; i < length; i++) {
|
|
302
287
|
parse(items[i], schedule, field, f[1], f[2], f[3]);
|
|
303
288
|
}
|
|
304
289
|
}
|
|
305
290
|
}
|
|
306
|
-
|
|
307
291
|
return schedule;
|
|
308
292
|
}
|
|
293
|
+
|
|
309
294
|
/**
|
|
310
295
|
* Make cron expression parsable.
|
|
311
296
|
*
|
|
312
297
|
* @param {String} expr: The cron expression to prepare
|
|
313
298
|
*/
|
|
314
|
-
|
|
315
|
-
|
|
316
299
|
function prepareExpr(expr) {
|
|
317
300
|
var prepared = expr.toUpperCase();
|
|
318
301
|
return REPLACEMENTS[prepared] || prepared;
|
|
319
302
|
}
|
|
320
|
-
|
|
321
303
|
function parseCron(expr, hasSeconds) {
|
|
322
304
|
var e = prepareExpr(expr);
|
|
323
305
|
return parseExpr(hasSeconds ? e : '0 ' + e);
|
|
324
306
|
}
|
|
325
|
-
|
|
326
307
|
var schedule = parseCron(cronspec, withSeconds);
|
|
327
|
-
|
|
328
308
|
function absFloor(number) {
|
|
329
309
|
if (number < 0) {
|
|
330
310
|
return Math.ceil(number);
|
|
@@ -332,23 +312,20 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
332
312
|
return Math.floor(number);
|
|
333
313
|
}
|
|
334
314
|
}
|
|
335
|
-
|
|
336
315
|
function toInt(argumentForCoercion) {
|
|
337
316
|
var coercedNumber = +argumentForCoercion;
|
|
338
317
|
var value = 0;
|
|
339
|
-
|
|
340
318
|
if (coercedNumber !== 0 && isFinite(coercedNumber)) {
|
|
341
319
|
value = absFloor(coercedNumber);
|
|
342
320
|
}
|
|
343
|
-
|
|
344
321
|
return value;
|
|
345
322
|
}
|
|
346
|
-
|
|
347
323
|
function ordinal(number) {
|
|
348
324
|
var b = number % 10,
|
|
349
|
-
|
|
325
|
+
output = toInt(number % 100 / 10) === 1 ? locale.ORDINALS.th : b === 1 ? locale.ORDINALS.st : b === 2 ? locale.ORDINALS.nd : b === 3 ? locale.ORDINALS.rd : locale.ORDINALS.th;
|
|
350
326
|
return number + output;
|
|
351
327
|
}
|
|
328
|
+
|
|
352
329
|
/**
|
|
353
330
|
* For an array of numbers, e.g. a list of hours in a schedule,
|
|
354
331
|
* return a string listing out all of the values (complete with
|
|
@@ -356,16 +333,14 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
356
333
|
* @param {Number[]} numbers
|
|
357
334
|
* @returns {string}
|
|
358
335
|
*/
|
|
359
|
-
|
|
360
|
-
|
|
361
336
|
function numberList(numbers) {
|
|
362
337
|
if (numbers.length < 2) {
|
|
363
338
|
return ordinal(numbers);
|
|
364
339
|
}
|
|
365
|
-
|
|
366
340
|
var lastVal = numbers.pop();
|
|
367
341
|
return numbers.join(', ') + ' ' + locale['and'] + ' ' + ordinal(lastVal);
|
|
368
342
|
}
|
|
343
|
+
|
|
369
344
|
/**
|
|
370
345
|
* Parse a number into day of week, or a month name;
|
|
371
346
|
* used in dateList below.
|
|
@@ -373,8 +348,6 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
373
348
|
* @param {String} type
|
|
374
349
|
* @returns {String}
|
|
375
350
|
*/
|
|
376
|
-
|
|
377
|
-
|
|
378
351
|
function numberToDateName(value, type) {
|
|
379
352
|
if (type === 'dow') {
|
|
380
353
|
return locale.DOW[value - 1];
|
|
@@ -382,6 +355,7 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
382
355
|
return locale.MONTH[value - 1];
|
|
383
356
|
}
|
|
384
357
|
}
|
|
358
|
+
|
|
385
359
|
/**
|
|
386
360
|
* From an array of numbers corresponding to dates (given in type: either
|
|
387
361
|
* days of the week, or months), return a string listing all the values.
|
|
@@ -389,36 +363,31 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
389
363
|
* @param {String} type
|
|
390
364
|
* @returns {String}
|
|
391
365
|
*/
|
|
392
|
-
|
|
393
|
-
|
|
394
366
|
function dateList(numbers, type) {
|
|
395
367
|
if (numbers.length < 2) {
|
|
396
368
|
return numberToDateName('' + numbers[0], type);
|
|
397
369
|
}
|
|
398
|
-
|
|
399
370
|
var lastVal = '' + numbers.pop();
|
|
400
371
|
var outputText = '';
|
|
401
|
-
|
|
402
372
|
for (var i = 0, value; value = numbers[i]; i++) {
|
|
403
373
|
if (outputText.length > 0) {
|
|
404
374
|
outputText += ', ';
|
|
405
375
|
}
|
|
406
|
-
|
|
407
376
|
outputText += numberToDateName(value, type);
|
|
408
377
|
}
|
|
409
|
-
|
|
410
378
|
return outputText + ' ' + locale['and'] + ' ' + numberToDateName(lastVal, type);
|
|
411
379
|
}
|
|
380
|
+
|
|
412
381
|
/**
|
|
413
382
|
* Pad to equivalent of sprintf('%02d').
|
|
414
383
|
* @param {Number} x
|
|
415
384
|
* @returns {string}
|
|
416
385
|
*/
|
|
417
|
-
|
|
418
|
-
|
|
419
386
|
function zeroPad(x) {
|
|
420
387
|
return x < 10 ? '0' + x : x;
|
|
421
|
-
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
//----------------
|
|
422
391
|
|
|
423
392
|
/**
|
|
424
393
|
* Given a schedule, generate a friendly sentence description.
|
|
@@ -426,16 +395,13 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
426
395
|
* @param {boolean} withSeconds
|
|
427
396
|
* @returns {string}
|
|
428
397
|
*/
|
|
429
|
-
|
|
430
|
-
|
|
431
398
|
function scheduleToSentence(schedule, withSeconds) {
|
|
432
399
|
var outputText = locale.Every + ' ';
|
|
433
|
-
|
|
434
400
|
if (schedule['h'] && schedule['m'] && schedule['h'].length <= 2 && schedule['m'].length <= 2 && withSeconds && schedule['s'] && schedule['s'].length <= 2) {
|
|
435
401
|
// If there are only one or two specified values for
|
|
436
402
|
// hour or minute, print them in HH:MM:SS format
|
|
437
|
-
var hm = [];
|
|
438
403
|
|
|
404
|
+
var hm = [];
|
|
439
405
|
for (var i = 0; i < schedule['h'].length; i++) {
|
|
440
406
|
for (var j = 0; j < schedule['m'].length; j++) {
|
|
441
407
|
for (var k = 0; k < schedule['s'].length; k++) {
|
|
@@ -443,41 +409,37 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
443
409
|
}
|
|
444
410
|
}
|
|
445
411
|
}
|
|
446
|
-
|
|
447
412
|
if (hm.length < 2) {
|
|
448
413
|
outputText = locale['At'] + ' ' + hm[0];
|
|
449
414
|
} else {
|
|
450
415
|
var lastVal = hm.pop();
|
|
451
416
|
outputText = locale['At'] + ' ' + hm.join(', ') + ' ' + locale.and + ' ' + lastVal;
|
|
452
417
|
}
|
|
453
|
-
|
|
454
418
|
if (!schedule['d'] && !schedule['D']) {
|
|
455
419
|
outputText += ' ' + locale['every day'] + ' ';
|
|
456
420
|
}
|
|
457
421
|
} else if (schedule['h'] && schedule['m'] && schedule['h'].length <= 2 && schedule['m'].length <= 2) {
|
|
458
422
|
// If there are only one or two specified values for
|
|
459
423
|
// hour or minute, print them in HH:MM format
|
|
460
|
-
var _hm = [];
|
|
461
424
|
|
|
425
|
+
var _hm = [];
|
|
462
426
|
for (var _i = 0; _i < schedule['h'].length; _i++) {
|
|
463
427
|
for (var _j = 0; _j < schedule['m'].length; _j++) {
|
|
464
428
|
_hm.push(zeroPad(schedule['h'][_i]) + ':' + zeroPad(schedule['m'][_j]));
|
|
465
429
|
}
|
|
466
430
|
}
|
|
467
|
-
|
|
468
431
|
if (_hm.length < 2) {
|
|
469
432
|
outputText = locale['At'] + ' ' + _hm[0];
|
|
470
433
|
} else {
|
|
471
434
|
var _lastVal = _hm.pop();
|
|
472
|
-
|
|
473
435
|
outputText = locale['At'] + ' ' + _hm.join(', ') + ' ' + locale.and + ' ' + _lastVal;
|
|
474
436
|
}
|
|
475
|
-
|
|
476
437
|
if (!schedule['d'] && !schedule['D']) {
|
|
477
438
|
outputText += ' ' + locale['every day'] + ' ';
|
|
478
439
|
}
|
|
479
440
|
} else {
|
|
480
441
|
// Otherwise, list out every specified hour/minute value.
|
|
442
|
+
|
|
481
443
|
if (schedule['h']) {
|
|
482
444
|
// runs only at specific hours
|
|
483
445
|
if (schedule['m']) {
|
|
@@ -525,16 +487,13 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
525
487
|
outputText += locale['minute'];
|
|
526
488
|
}
|
|
527
489
|
}
|
|
528
|
-
|
|
529
490
|
if (schedule['D']) {
|
|
530
491
|
// runs only on specific day(s) of month
|
|
531
492
|
outputText += (locale['on the'] ? ' ' + locale['on the'] + ' ' : ' ') + numberList(schedule['D']);
|
|
532
|
-
|
|
533
493
|
if (!schedule['M']) {
|
|
534
494
|
outputText += ' ' + locale['of every month'];
|
|
535
495
|
}
|
|
536
496
|
}
|
|
537
|
-
|
|
538
497
|
if (schedule['d']) {
|
|
539
498
|
// runs only on specific day(s) of week
|
|
540
499
|
if (schedule['D']) {
|
|
@@ -543,21 +502,16 @@ function cronToText(cronspec, withSeconds, locale) {
|
|
|
543
502
|
} else {
|
|
544
503
|
outputText += ' ' + locale['on'] + ' ';
|
|
545
504
|
}
|
|
546
|
-
|
|
547
505
|
outputText += dateList(schedule['d'], 'dow');
|
|
548
506
|
}
|
|
549
|
-
|
|
550
507
|
if (schedule['M']) {
|
|
551
508
|
// runs only in specific months; put this output last
|
|
552
509
|
outputText += ' ' + locale['in'] + ' ' + dateList(schedule['M'], 'mon');
|
|
553
510
|
}
|
|
554
|
-
|
|
555
511
|
return outputText;
|
|
556
512
|
}
|
|
557
|
-
|
|
558
513
|
return scheduleToSentence(schedule.schedules[0], withSeconds);
|
|
559
514
|
}
|
|
560
|
-
|
|
561
515
|
var _default = cronToText;
|
|
562
516
|
exports["default"] = _default;
|
|
563
517
|
//# sourceMappingURL=cron2text.js.map
|