@jamesrock/rockjs 1.34.0 → 1.35.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.js +35 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -33,10 +33,6 @@ export const roundTo = (number, to = 1) => (Math.round(number*to)/to);
|
|
|
33
33
|
export const ceilTo = (number, to = 1) => (Math.ceil(number*to)/to);
|
|
34
34
|
export const getXPercentOfY = (x, y) => (y*(x/100));
|
|
35
35
|
export const getXAsPercentOfY = (x, y) => ((x/y)*100);
|
|
36
|
-
// to be removed
|
|
37
|
-
export const formatMinutes = (ms) => pad(Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60)));
|
|
38
|
-
export const formatSeconds = (ms) => pad(Math.floor((ms % (1000 * 60)) / 1000));
|
|
39
|
-
export const formatTime = (ms) => `${formatMinutes(ms)}:${formatSeconds(ms)}`;
|
|
40
36
|
|
|
41
37
|
const sortingMethods = {
|
|
42
38
|
'0-9': (prop) => (a, b) => prop(a)-prop(b),
|
|
@@ -113,6 +109,23 @@ export const makeInput = (value = 0, type = 'number') => {
|
|
|
113
109
|
return input;
|
|
114
110
|
};
|
|
115
111
|
|
|
112
|
+
export const makeRadio = (value = 0, name = '{name}', id = '{id}', checked = false) => {
|
|
113
|
+
const node = makeInput(value, 'radio');
|
|
114
|
+
node.name = name;
|
|
115
|
+
node.id = id;
|
|
116
|
+
node.checked = checked;
|
|
117
|
+
return node;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const makeSlider = (value, min, max, step = 1) => {
|
|
121
|
+
const node = makeInput(0, 'range');
|
|
122
|
+
node.min = min;
|
|
123
|
+
node.max = max;
|
|
124
|
+
node.step = step;
|
|
125
|
+
node.value = value;
|
|
126
|
+
return node;
|
|
127
|
+
};
|
|
128
|
+
|
|
116
129
|
export const makeOutput = (rows = 7) => {
|
|
117
130
|
const node = makeNode('textarea');
|
|
118
131
|
node.rows = rows;
|
|
@@ -151,14 +164,6 @@ export const makeLink = (href = '{href}', label = '{label}', className) => {
|
|
|
151
164
|
return node;
|
|
152
165
|
};
|
|
153
166
|
|
|
154
|
-
export const makeRadio = (value = 0, name = '{name}', id = '{id}', checked = false) => {
|
|
155
|
-
const node = makeInput(value, 'radio');
|
|
156
|
-
node.name = name;
|
|
157
|
-
node.id = id;
|
|
158
|
-
node.checked = checked;
|
|
159
|
-
return node;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
167
|
export const makeLabel = (label = '{label}', id = '{id}', className) => {
|
|
163
168
|
const node = makeNode('label', className);
|
|
164
169
|
node.innerHTML = label;
|
|
@@ -262,6 +267,22 @@ export const addDragListeners = (target, tolerance) => {
|
|
|
262
267
|
|
|
263
268
|
};
|
|
264
269
|
|
|
270
|
+
export const append = (target) => {
|
|
271
|
+
const fn = (node) => {
|
|
272
|
+
target.appendChild(node);
|
|
273
|
+
return fn;
|
|
274
|
+
};
|
|
275
|
+
return fn;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
export const appendTo = (target) => {
|
|
279
|
+
const fn = (node) => {
|
|
280
|
+
node.appendTo(target);
|
|
281
|
+
return fn;
|
|
282
|
+
};
|
|
283
|
+
return fn;
|
|
284
|
+
};
|
|
285
|
+
|
|
265
286
|
export class Storage {
|
|
266
287
|
constructor(namespace) {
|
|
267
288
|
|
|
@@ -667,10 +688,7 @@ export class Time {
|
|
|
667
688
|
getDaysInYear = (ms) => this.getDays(this.getMillisecondsInYear(ms));
|
|
668
689
|
getMinutesInHour = (ms) => this.getMinutes(this.getMillisecondsInHour(ms));
|
|
669
690
|
getSecondsInMinute = (ms) => this.getSeconds(this.getMillisecondsInMinute(ms));
|
|
670
|
-
|
|
671
|
-
formatMinutes = (ms) => pad(this.getMinutesInHour(ms));
|
|
672
|
-
formatHours = (ms) => pad(this.getHoursInDay(ms));
|
|
673
|
-
format = (ms) => `${this.formatMinutes(ms)}:${this.formatSeconds(ms)}`;
|
|
691
|
+
format = (ms) => `${pad(this.getMinutesInHour(ms))}:${pad(this.getSecondsInMinute(ms))}`;
|
|
674
692
|
};
|
|
675
693
|
|
|
676
694
|
export class PlayingCard extends DisplayObject {
|
|
@@ -892,3 +910,4 @@ export const createOption = makeOption;
|
|
|
892
910
|
export const createHeading = makeHeading;
|
|
893
911
|
export const createRadio = makeRadio;
|
|
894
912
|
export const createLabel = makeLabel;
|
|
913
|
+
export const formatTime = (ms) => new Time().format(ms);
|