dphelper 0.2.42 → 0.2.46
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 +2 -12
- package/index.js.LICENSE.txt +24 -0
- package/package.json +2 -5
- package/.editorconfig +0 -14
- package/.eslintrc.json +0 -36
- package/.gitattributes +0 -2
- package/.jshintrc +0 -13
- package/.prettierignore +0 -2
- package/.prettierrc +0 -7
- package/.vscode/settings.json +0 -19
- package/3party/shortcut.js +0 -224
- package/data/list.json +0 -19
- package/index.d.ts +0 -9
- package/init.js +0 -51
- package/scripts/anchorToOnClick.js +0 -47
- package/scripts/array.js +0 -142
- package/scripts/browser.js +0 -65
- package/scripts/console.js +0 -86
- package/scripts/coodinates.js +0 -41
- package/scripts/cookie.js +0 -97
- package/scripts/currency.js +0 -41
- package/scripts/date.js +0 -101
- package/scripts/disable.js +0 -90
- package/scripts/event.js +0 -39
- package/scripts/font.js +0 -52
- package/scripts/form.js +0 -113
- package/scripts/function.js +0 -47
- package/scripts/indexedDB.js +0 -222
- package/scripts/json.js +0 -42
- package/scripts/load.js +0 -85
- package/scripts/noCache.js +0 -26
- package/scripts/number.js +0 -66
- package/scripts/obj.js +0 -81
- package/scripts/onBeforeUnLoad.js +0 -120
- package/scripts/parseBool.js +0 -27
- package/scripts/path.js +0 -94
- package/scripts/promise.js +0 -35
- package/scripts/purge.js +0 -53
- package/scripts/screen.js +0 -64
- package/scripts/scrollbar.js +0 -226
- package/scripts/shortcut.js +0 -70
- package/scripts/storage.js +0 -62
- package/scripts/svg.js +0 -372
- package/scripts/text.js +0 -78
- package/scripts/time.js +0 -41
- package/scripts/timer.js +0 -35
- package/scripts/trigger.js +0 -46
- package/scripts/type.js +0 -56
- package/scripts/uuid.js +0 -33
- package/scripts/window.js +0 -50
- package/ws.code-workspace +0 -73
package/3party/shortcut.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
|
3
|
-
* Version : 2.01.B
|
|
4
|
-
* By Binny V A
|
|
5
|
-
* License : BSD
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
shortcut = {
|
|
9
|
-
'all_shortcuts':{},//All the shortcuts are stored in this array
|
|
10
|
-
'add': function(shortcut_combination,callback,opt) {
|
|
11
|
-
//Provide a set of default options
|
|
12
|
-
let default_options = {
|
|
13
|
-
'type':'keydown',
|
|
14
|
-
'propagate':false,
|
|
15
|
-
'disable_in_input':false,
|
|
16
|
-
'target':document,
|
|
17
|
-
'keycode':false
|
|
18
|
-
}
|
|
19
|
-
if(!opt) opt = default_options;
|
|
20
|
-
else {
|
|
21
|
-
for(let dfo in default_options) {
|
|
22
|
-
if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let ele = opt.target;
|
|
27
|
-
if(typeof opt.target == 'string') ele = document.getElementById(opt.target);
|
|
28
|
-
let ths = this;
|
|
29
|
-
shortcut_combination = shortcut_combination.toLowerCase();
|
|
30
|
-
|
|
31
|
-
//The function to be called at keypress
|
|
32
|
-
let func = function( e ) {
|
|
33
|
-
e = e || window.event;
|
|
34
|
-
|
|
35
|
-
if(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields
|
|
36
|
-
let element;
|
|
37
|
-
if(e.target) element=e.target;
|
|
38
|
-
else if(e.srcElement) element=e.srcElement;
|
|
39
|
-
if(element.nodeType==3) element=element.parentNode;
|
|
40
|
-
|
|
41
|
-
if(element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//Find Which key is pressed
|
|
45
|
-
if (e.keyCode) code = e.keyCode;
|
|
46
|
-
else if (e.which) code = e.which;
|
|
47
|
-
let character = String.fromCharCode(code).toLowerCase();
|
|
48
|
-
|
|
49
|
-
if(code == 188) character=","; //If the user presses , when the type is onkeydown
|
|
50
|
-
if(code == 190) character="."; //If the user presses , when the type is onkeydown
|
|
51
|
-
|
|
52
|
-
let keys = shortcut_combination.split("+");
|
|
53
|
-
//Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked
|
|
54
|
-
let kp = 0;
|
|
55
|
-
|
|
56
|
-
//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
|
|
57
|
-
let shift_nums = {
|
|
58
|
-
"`":"~",
|
|
59
|
-
"1":"!",
|
|
60
|
-
"2":"@",
|
|
61
|
-
"3":"#",
|
|
62
|
-
"4":"$",
|
|
63
|
-
"5":"%",
|
|
64
|
-
"6":"^",
|
|
65
|
-
"7":"&",
|
|
66
|
-
"8":"*",
|
|
67
|
-
"9":"(",
|
|
68
|
-
"0":")",
|
|
69
|
-
"-":"_",
|
|
70
|
-
"=":"+",
|
|
71
|
-
";":":",
|
|
72
|
-
"'":"\"",
|
|
73
|
-
",":"<",
|
|
74
|
-
".":">",
|
|
75
|
-
"/":"?",
|
|
76
|
-
"\\":"|"
|
|
77
|
-
}
|
|
78
|
-
//Special Keys - and their codes
|
|
79
|
-
let special_keys = {
|
|
80
|
-
'esc':27,
|
|
81
|
-
'escape':27,
|
|
82
|
-
'tab':9,
|
|
83
|
-
'space':32,
|
|
84
|
-
'return':13,
|
|
85
|
-
'enter':13,
|
|
86
|
-
'backspace':8,
|
|
87
|
-
|
|
88
|
-
'scrolllock':145,
|
|
89
|
-
'scroll_lock':145,
|
|
90
|
-
'scroll':145,
|
|
91
|
-
'capslock':20,
|
|
92
|
-
'caps_lock':20,
|
|
93
|
-
'caps':20,
|
|
94
|
-
'numlock':144,
|
|
95
|
-
'num_lock':144,
|
|
96
|
-
'num':144,
|
|
97
|
-
|
|
98
|
-
'pause':19,
|
|
99
|
-
'break':19,
|
|
100
|
-
|
|
101
|
-
'insert':45,
|
|
102
|
-
'home':36,
|
|
103
|
-
'delete':46,
|
|
104
|
-
'end':35,
|
|
105
|
-
|
|
106
|
-
'pageup':33,
|
|
107
|
-
'page_up':33,
|
|
108
|
-
'pu':33,
|
|
109
|
-
|
|
110
|
-
'pagedown':34,
|
|
111
|
-
'page_down':34,
|
|
112
|
-
'pd':34,
|
|
113
|
-
|
|
114
|
-
'left':37,
|
|
115
|
-
'up':38,
|
|
116
|
-
'right':39,
|
|
117
|
-
'down':40,
|
|
118
|
-
|
|
119
|
-
'f1':112,
|
|
120
|
-
'f2':113,
|
|
121
|
-
'f3':114,
|
|
122
|
-
'f4':115,
|
|
123
|
-
'f5':116,
|
|
124
|
-
'f6':117,
|
|
125
|
-
'f7':118,
|
|
126
|
-
'f8':119,
|
|
127
|
-
'f9':120,
|
|
128
|
-
'f10':121,
|
|
129
|
-
'f11':122,
|
|
130
|
-
'f12':123
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
let modifiers = {
|
|
134
|
-
shift: { wanted:false, pressed:false},
|
|
135
|
-
ctrl : { wanted:false, pressed:false},
|
|
136
|
-
alt : { wanted:false, pressed:false},
|
|
137
|
-
meta : { wanted:false, pressed:false} //Meta is Mac specific
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
if(e.ctrlKey) modifiers.ctrl.pressed = true;
|
|
141
|
-
if(e.shiftKey) modifiers.shift.pressed = true;
|
|
142
|
-
if(e.altKey) modifiers.alt.pressed = true;
|
|
143
|
-
if(e.metaKey) modifiers.meta.pressed = true;
|
|
144
|
-
|
|
145
|
-
for(let i=0; k=keys[i],i<keys.length; i++) {
|
|
146
|
-
//Modifiers
|
|
147
|
-
if(k == 'ctrl' || k == 'control') {
|
|
148
|
-
kp++;
|
|
149
|
-
modifiers.ctrl.wanted = true;
|
|
150
|
-
|
|
151
|
-
} else if(k == 'shift') {
|
|
152
|
-
kp++;
|
|
153
|
-
modifiers.shift.wanted = true;
|
|
154
|
-
|
|
155
|
-
} else if(k == 'alt') {
|
|
156
|
-
kp++;
|
|
157
|
-
modifiers.alt.wanted = true;
|
|
158
|
-
} else if(k == 'meta') {
|
|
159
|
-
kp++;
|
|
160
|
-
modifiers.meta.wanted = true;
|
|
161
|
-
} else if(k.length > 1) { //If it is a special key
|
|
162
|
-
if(special_keys[k] == code) kp++;
|
|
163
|
-
|
|
164
|
-
} else if(opt['keycode']) {
|
|
165
|
-
if(opt['keycode'] == code) kp++;
|
|
166
|
-
|
|
167
|
-
} else { //The special keys did not match
|
|
168
|
-
if(character == k) kp++;
|
|
169
|
-
else {
|
|
170
|
-
if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase
|
|
171
|
-
character = shift_nums[character];
|
|
172
|
-
if(character == k) kp++;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if(kp == keys.length &&
|
|
179
|
-
modifiers.ctrl.pressed == modifiers.ctrl.wanted &&
|
|
180
|
-
modifiers.shift.pressed == modifiers.shift.wanted &&
|
|
181
|
-
modifiers.alt.pressed == modifiers.alt.wanted &&
|
|
182
|
-
modifiers.meta.pressed == modifiers.meta.wanted) {
|
|
183
|
-
callback( e );
|
|
184
|
-
|
|
185
|
-
if(!opt['propagate']) { //Stop the event
|
|
186
|
-
//e.cancelBubble is supported by IE - this will kill the bubbling process.
|
|
187
|
-
e.cancelBubble = true;
|
|
188
|
-
e.returnValue = false;
|
|
189
|
-
|
|
190
|
-
//e.stopPropagation works in Firefox.
|
|
191
|
-
if (e.stopPropagation) {
|
|
192
|
-
e.stopPropagation();
|
|
193
|
-
e.preventDefault();
|
|
194
|
-
}
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
this.all_shortcuts[shortcut_combination] = {
|
|
200
|
-
'callback':func,
|
|
201
|
-
'target':ele,
|
|
202
|
-
'event': opt['type']
|
|
203
|
-
};
|
|
204
|
-
//Attach the function with the event
|
|
205
|
-
if(ele.addEventListener) ele.addEventListener(opt['type'], func, false);
|
|
206
|
-
else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);
|
|
207
|
-
else ele['on'+opt['type']] = func;
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
//Remove the shortcut - just specify the shortcut and I will remove the binding
|
|
211
|
-
'remove':function(shortcut_combination) {
|
|
212
|
-
shortcut_combination = shortcut_combination.toLowerCase();
|
|
213
|
-
let binding = this.all_shortcuts[shortcut_combination];
|
|
214
|
-
delete(this.all_shortcuts[shortcut_combination])
|
|
215
|
-
if(!binding) return;
|
|
216
|
-
let type = binding['event'];
|
|
217
|
-
let ele = binding['target'];
|
|
218
|
-
let callback = binding['callback'];
|
|
219
|
-
|
|
220
|
-
if(ele.detachEvent) ele.detachEvent('on'+type, callback);
|
|
221
|
-
else if(ele.removeEventListener) ele.removeEventListener(type, callback, false);
|
|
222
|
-
else ele['on'+type] = false;
|
|
223
|
-
}
|
|
224
|
-
}
|
package/data/list.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"info" : {
|
|
3
|
-
"title" : "List",
|
|
4
|
-
"description" : "Complete list of tools"
|
|
5
|
-
},
|
|
6
|
-
"categories" : [
|
|
7
|
-
"3dparty",
|
|
8
|
-
"system",
|
|
9
|
-
"financial",
|
|
10
|
-
"memory",
|
|
11
|
-
"numbers",
|
|
12
|
-
"time",
|
|
13
|
-
"path",
|
|
14
|
-
"file",
|
|
15
|
-
"forms",
|
|
16
|
-
"ui",
|
|
17
|
-
"other"
|
|
18
|
-
]
|
|
19
|
-
}
|
package/index.d.ts
DELETED
package/init.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
5
|
-
* Licensed under the Apache-2.0 License.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/***********************************************************************/
|
|
9
|
-
|
|
10
|
-
( () => {
|
|
11
|
-
|
|
12
|
-
if (typeof window === 'undefined') {
|
|
13
|
-
global.window = {};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const pjson = require('./package.json');
|
|
17
|
-
|
|
18
|
-
// CREATE ROOT STORE
|
|
19
|
-
const dphelper = window.dphelper = {};
|
|
20
|
-
|
|
21
|
-
window.dphelper._list = require('./data/list.json');
|
|
22
|
-
window.dphelper._list.scripts = [];
|
|
23
|
-
window.dphelper._list.version = pjson.version;
|
|
24
|
-
|
|
25
|
-
const cache = {};
|
|
26
|
-
|
|
27
|
-
const importAll = ( cntx ) => {
|
|
28
|
-
cntx.keys().forEach(
|
|
29
|
-
( key ) => (
|
|
30
|
-
cache[ key ] = cntx( key )
|
|
31
|
-
)
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
var cntx = require.context( __dirname + '/scripts/', false , /\.js$/ );
|
|
35
|
-
importAll( cntx );
|
|
36
|
-
|
|
37
|
-
// FIRST MESSAGE
|
|
38
|
-
console.groupCollapsed( `%c${pjson.name} v${pjson.version}%c`,"color:orange","" );
|
|
39
|
-
console.debug( `%c${pjson.name} v${pjson.version}%c by Dario Passariello started`,"color:orange","" );
|
|
40
|
-
console.debug( `%cType ${pjson.name} in this console to see it`, "color:gray","" );
|
|
41
|
-
console.debug( "%cFor help visit: " + pjson.repository.help, "color:gray","" );
|
|
42
|
-
console.debug( 'name: %c' + pjson.name,"color:orange","" );
|
|
43
|
-
console.debug( 'version: %c' + pjson.version,"color:orange","" );
|
|
44
|
-
console.debug( 'description: %c' + pjson.description,"color:orange","" );
|
|
45
|
-
console.debug( 'license: %c' + pjson.license,"color:orange","" );
|
|
46
|
-
console.debug( 'repository: %c' + pjson.repository.url,"color:orange","" );
|
|
47
|
-
console.debug( 'author: %c' + pjson.author.name,"color:orange","" );
|
|
48
|
-
console.debug( 'email: %c' + pjson.author.email,"color:orange","" );
|
|
49
|
-
console.groupEnd();
|
|
50
|
-
|
|
51
|
-
})();
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
4
|
-
* Licensed under the Apache-2.0 License.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/***********************************************************************/
|
|
8
|
-
|
|
9
|
-
var description = {
|
|
10
|
-
"name" : "Anchor To OnClick",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "anchorToOnClick",
|
|
14
|
-
"subCommand" : [],
|
|
15
|
-
"example" : "",
|
|
16
|
-
"author" : "Dario Passariello",
|
|
17
|
-
"active" : true
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
window.dphelper._list.scripts.push( description );
|
|
21
|
-
|
|
22
|
-
/***********************************************************************/
|
|
23
|
-
|
|
24
|
-
window.dphelper.anchorToOnClick = function( el ){
|
|
25
|
-
|
|
26
|
-
$( el + ' a' ).each( function( index ) {
|
|
27
|
-
|
|
28
|
-
let elem = $( this );
|
|
29
|
-
let href = elem.attr( 'href' );
|
|
30
|
-
|
|
31
|
-
if( href ){
|
|
32
|
-
elem
|
|
33
|
-
.on( 'mouseup', function(){
|
|
34
|
-
Loader( 'body' , null );
|
|
35
|
-
})
|
|
36
|
-
.css('cursor','pointer')
|
|
37
|
-
.addClass( dphelper.pathRail()[3].replace(/\//g, '') )
|
|
38
|
-
.removeAttr( 'href' )
|
|
39
|
-
.on( 'click', function(){
|
|
40
|
-
dphelper.browser.href( href );
|
|
41
|
-
dphelper.browser.push( '', '', href );
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
};
|
package/scripts/array.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
4
|
-
* Licensed under the Apache-2.0 License.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/***********************************************************************/
|
|
8
|
-
|
|
9
|
-
var description = {
|
|
10
|
-
"name" : "Arrays",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "array",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"find",
|
|
17
|
-
"description":"test"
|
|
18
|
-
},{
|
|
19
|
-
"name":"unique",
|
|
20
|
-
"description":"test"
|
|
21
|
-
},{
|
|
22
|
-
"name":"delete",
|
|
23
|
-
"description":"test"
|
|
24
|
-
},{
|
|
25
|
-
"name":"merge",
|
|
26
|
-
"description":"test"
|
|
27
|
-
},{
|
|
28
|
-
"name":"asc",
|
|
29
|
-
"description":"test"
|
|
30
|
-
},{
|
|
31
|
-
"name":"desc",
|
|
32
|
-
"description":"test"
|
|
33
|
-
},{
|
|
34
|
-
"name":"duplicates",
|
|
35
|
-
"description":"test"
|
|
36
|
-
},{
|
|
37
|
-
"name":"even",
|
|
38
|
-
"description":"test"
|
|
39
|
-
},{
|
|
40
|
-
"name":"odd",
|
|
41
|
-
"description":"test"
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
"example" : "",
|
|
45
|
-
"author" : "Dario Passariello",
|
|
46
|
-
"active" : true
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
window.dphelper._list.scripts.push( description );
|
|
50
|
-
|
|
51
|
-
/***********************************************************************/
|
|
52
|
-
|
|
53
|
-
window.dphelper.array = {
|
|
54
|
-
|
|
55
|
-
// FIND
|
|
56
|
-
find: ( id, array )=>{
|
|
57
|
-
for (let node of array) {
|
|
58
|
-
if (node.id === id) return node;
|
|
59
|
-
|
|
60
|
-
if (node.children) {
|
|
61
|
-
let finalNode = window.dphelper.array.find(id, node.children);
|
|
62
|
-
if (finalNode) return finalNode;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
// UNIQUE
|
|
69
|
-
unique: ( array ) => {
|
|
70
|
-
let unique = [...new Set( array )];
|
|
71
|
-
return unique;
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
// DELETE
|
|
75
|
-
delete: ( id, array ) => {
|
|
76
|
-
array.some(function iter (o,i,a) {
|
|
77
|
-
|
|
78
|
-
if (o.Id === id) {
|
|
79
|
-
a.splice(i, 1);
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
for (let key of Object.keys(o)) {
|
|
84
|
-
let value = o[key];
|
|
85
|
-
if(value.length && typeof value === 'object') return value && value.map(iter);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// OLD SCHOOL WAY
|
|
89
|
-
//var key = Object.keys(o);
|
|
90
|
-
// for (var p=0; p < key.length; ++p){
|
|
91
|
-
// if( o[key[p]]?.length && typeof o[key[p]] === 'object') return o[key[p]] && o[key[p]].some(iter);
|
|
92
|
-
// }
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
// MERGE
|
|
99
|
-
merge: ( arrayA, arrayB ) => {
|
|
100
|
-
for (const key of Object.keys(arrayA)) {
|
|
101
|
-
if (arrayA[key] instanceof Object && arrayB[key]) Object.assign(arrayA[key], window.dphelper.mergeArrays(arrayB[key], arrayA[key]));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
Object.assign(arrayB || {}, arrayA);
|
|
105
|
-
return arrayB;
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
// ASCENDING
|
|
109
|
-
asc: ( array ) => {
|
|
110
|
-
array.sort((a, b) => a - b);
|
|
111
|
-
return array;
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
// ASCENDING
|
|
115
|
-
desc: ( array ) => {
|
|
116
|
-
array.sort(function(a, b){ return b-a; });
|
|
117
|
-
return array;
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
// FIND DUPLICATES
|
|
121
|
-
duplicates: ( array ) => {
|
|
122
|
-
const toFindDuplicates = arr => arr.filter( (item, index) => arr.indexOf( item ) !== index);
|
|
123
|
-
const duplicateElements = toFindDuplicates( array );
|
|
124
|
-
return duplicateElements;
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
even: ( array ) => {
|
|
128
|
-
var cur = [];
|
|
129
|
-
for (var i = 0; i < array.length; i++) {
|
|
130
|
-
if (array[i] % 2 === 0 ) cur.push(array[i]);
|
|
131
|
-
} return cur;
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
odd: ( array ) => {
|
|
135
|
-
var cur = [];
|
|
136
|
-
for (var i = 0; i < array.length; i++) {
|
|
137
|
-
if (array[i] % 2) cur.push(array[i]);
|
|
138
|
-
} return cur;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
|
package/scripts/browser.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
4
|
-
* Licensed under the Apache-2.0 License.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/***********************************************************************/
|
|
8
|
-
|
|
9
|
-
var description = {
|
|
10
|
-
"name" : "Browser",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "browser",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"state",
|
|
17
|
-
"description":"test"
|
|
18
|
-
},{
|
|
19
|
-
"name":"forw",
|
|
20
|
-
"description":"test"
|
|
21
|
-
},{
|
|
22
|
-
"name":"back",
|
|
23
|
-
"description":"test"
|
|
24
|
-
},{
|
|
25
|
-
"name":"reload",
|
|
26
|
-
"description":"test"
|
|
27
|
-
},{
|
|
28
|
-
"name":"href",
|
|
29
|
-
"description":"test"
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
"example" : "",
|
|
33
|
-
"author" : "Dario Passariello",
|
|
34
|
-
"active" : true
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
window.dphelper._list.scripts.push( description );
|
|
38
|
-
|
|
39
|
-
/***********************************************************************/
|
|
40
|
-
|
|
41
|
-
window.dphelper.browser = {
|
|
42
|
-
|
|
43
|
-
state: (state, title, url) => {
|
|
44
|
-
return history.pushState( state, title, url );
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
forw: ( times ) => {
|
|
48
|
-
return history.go( times );
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
back: ( times ) => {
|
|
52
|
-
return history.go( -Math.abs( times ) );
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
reload: () => {
|
|
56
|
-
// DISCARD POST
|
|
57
|
-
return window.location.href = window.location.href;
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
href: ( url ) => {
|
|
61
|
-
// DISCARD POST
|
|
62
|
-
return window.location.href = url;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
};
|
package/scripts/console.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
4
|
-
* Licensed under the Apache-2.0 License.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/***********************************************************************/
|
|
8
|
-
|
|
9
|
-
var description = {
|
|
10
|
-
"name" : "Console",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "console",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"info",
|
|
17
|
-
"description":"test"
|
|
18
|
-
},{
|
|
19
|
-
"name":"stop",
|
|
20
|
-
"description":"test"
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
"example" : "",
|
|
24
|
-
"author" : "Dario Passariello",
|
|
25
|
-
"active" : true
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
window.dphelper._list.scripts.push( description );
|
|
29
|
-
|
|
30
|
-
/***********************************************************************/
|
|
31
|
-
|
|
32
|
-
window.dphelper.printInfo = () => {
|
|
33
|
-
console.debug( 'dpHelper: Please use "dphelper.path.rail()"' );
|
|
34
|
-
return window.dphelper.console.info();
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/***********************************************************************/
|
|
38
|
-
|
|
39
|
-
window.dphelper.console = {
|
|
40
|
-
|
|
41
|
-
info: () => {
|
|
42
|
-
console.groupCollapsed('%cApi:%c', "color:orange", "");
|
|
43
|
-
console.debug(dphelper.api);
|
|
44
|
-
console.groupEnd();
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
stop: () => {
|
|
48
|
-
|
|
49
|
-
let console = {};
|
|
50
|
-
console.log = function(){};
|
|
51
|
-
window.console = console;
|
|
52
|
-
if(!window.console) window.console = {};
|
|
53
|
-
|
|
54
|
-
const noop = () => {}
|
|
55
|
-
[
|
|
56
|
-
'assert',
|
|
57
|
-
'clear',
|
|
58
|
-
'count',
|
|
59
|
-
'debug',
|
|
60
|
-
'dir',
|
|
61
|
-
'dirxml',
|
|
62
|
-
'error',
|
|
63
|
-
'exception',
|
|
64
|
-
'group',
|
|
65
|
-
'groupCollapsed',
|
|
66
|
-
'groupEnd',
|
|
67
|
-
'info',
|
|
68
|
-
'log',
|
|
69
|
-
'markTimeline',
|
|
70
|
-
'profile',
|
|
71
|
-
'profileEnd',
|
|
72
|
-
'table',
|
|
73
|
-
'time',
|
|
74
|
-
'timeEnd',
|
|
75
|
-
'timeline',
|
|
76
|
-
'timelineEnd',
|
|
77
|
-
'timeStamp',
|
|
78
|
-
'trace',
|
|
79
|
-
'warn'
|
|
80
|
-
].forEach((method) => {
|
|
81
|
-
window.console[method] = noop;
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
};
|
package/scripts/coodinates.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
4
|
-
* Licensed under the Apache-2.0 License.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/***********************************************************************/
|
|
8
|
-
|
|
9
|
-
var description = {
|
|
10
|
-
"name" : "Coordinates Tools",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "coords",
|
|
14
|
-
"subCommand" : [],
|
|
15
|
-
"example" : "",
|
|
16
|
-
"author" : "Dario Passariello",
|
|
17
|
-
"active" : true
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
window.dphelper._list.scripts.push( description );
|
|
21
|
-
|
|
22
|
-
/***********************************************************************/
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
let R = 6378.1;
|
|
26
|
-
window.dphelper.coords = {
|
|
27
|
-
|
|
28
|
-
degreesToRadians: ( degrees ) => {
|
|
29
|
-
var pi = Math.PI;
|
|
30
|
-
return degrees * (pi/180);
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
latToMeters: ( latitude , longitude ) => {
|
|
34
|
-
return R * Math.cos(latitude) * Math.cos(longitude);
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
lngToMeters: ( latitude , longitude ) => {
|
|
38
|
-
return R * Math.cos(latitude) * Math.sin(longitude);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
};
|