dphelper 0.2.38 → 0.2.43

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 (52) hide show
  1. package/.github/FUNDING.yml +12 -0
  2. package/.github/dependabot.yml +12 -0
  3. package/index.js +2 -12
  4. package/index.js.LICENSE.txt +24 -0
  5. package/package.json +3 -5
  6. package/.editorconfig +0 -14
  7. package/.eslintrc.json +0 -36
  8. package/.gitattributes +0 -2
  9. package/.jshintrc +0 -13
  10. package/.prettierignore +0 -2
  11. package/.prettierrc +0 -7
  12. package/.vscode/settings.json +0 -19
  13. package/3party/shortcut.js +0 -224
  14. package/data/list.json +0 -19
  15. package/index.d.ts +0 -9
  16. package/init.js +0 -136
  17. package/scripts/anchorToOnClick.js +0 -47
  18. package/scripts/array.js +0 -95
  19. package/scripts/browser.js +0 -69
  20. package/scripts/console.js +0 -86
  21. package/scripts/cookie.js +0 -97
  22. package/scripts/currency.js +0 -41
  23. package/scripts/date.js +0 -101
  24. package/scripts/disable.js +0 -90
  25. package/scripts/event.js +0 -39
  26. package/scripts/font.js +0 -52
  27. package/scripts/form.js +0 -113
  28. package/scripts/function.js +0 -47
  29. package/scripts/indexedDB.js +0 -222
  30. package/scripts/json.js +0 -42
  31. package/scripts/load.js +0 -70
  32. package/scripts/noCache.js +0 -26
  33. package/scripts/number.js +0 -66
  34. package/scripts/obj.js +0 -81
  35. package/scripts/onBeforeUnLoad.js +0 -120
  36. package/scripts/parseBool.js +0 -27
  37. package/scripts/path.js +0 -94
  38. package/scripts/promise.js +0 -35
  39. package/scripts/purge.js +0 -53
  40. package/scripts/screen.js +0 -64
  41. package/scripts/scrollbar.js +0 -226
  42. package/scripts/shortcut.js +0 -70
  43. package/scripts/storage.js +0 -62
  44. package/scripts/svg.js +0 -372
  45. package/scripts/text.js +0 -78
  46. package/scripts/time.js +0 -41
  47. package/scripts/timer.js +0 -35
  48. package/scripts/trigger.js +0 -46
  49. package/scripts/type.js +0 -56
  50. package/scripts/uuid.js +0 -33
  51. package/scripts/window.js +0 -50
  52. package/ws.code-workspace +0 -73
@@ -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
@@ -1,9 +0,0 @@
1
- declare module 'dphelper';
2
-
3
- declare global {
4
- interface Window {
5
- dphelper:any;
6
- }
7
- }
8
-
9
- let dphelper = window.dphelper;
package/init.js DELETED
@@ -1,136 +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
- function importAll(r){
28
- r.keys().forEach(
29
- (key) => (
30
- cache[key] = r(key)
31
- )
32
- );
33
- }
34
-
35
- importAll( require.context( __dirname + '/scripts/', false, /\.js$/) );
36
-
37
-
38
- // FIRST MESSAGE
39
- console.groupCollapsed( `%c${pjson.name} v${pjson.version}%c`,"color:orange","" );
40
- console.debug( `%c${pjson.name} v${pjson.version}%c by Dario Passariello started`,"color:orange","" );
41
- console.debug( `%cType ${pjson.name} in this console to see it`, "color:gray","" );
42
- console.debug( "%cFor help visit: " + pjson.repository.help, "color:gray","" );
43
- console.debug( 'name: %c' + pjson.name,"color:orange","" );
44
- console.debug( 'version: %c' + pjson.version,"color:orange","" );
45
- console.debug( 'description: %c' + pjson.description,"color:orange","" );
46
- console.debug( 'license: %c' + pjson.license,"color:orange","" );
47
- console.debug( 'repository: %c' + pjson.repository.url,"color:orange","" );
48
- console.debug( 'author: %c' + pjson.author.name,"color:orange","" );
49
- console.debug( 'email: %c' + pjson.author.email,"color:orange","" );
50
- console.groupEnd();
51
-
52
- /*
53
- // SYSTEM
54
- require('./scripts/addListenerMulti.js');
55
-
56
- // 3party
57
- require('./3party/shortcut.js');
58
-
59
- // CURRENCY
60
- require('./scripts/currency.js');
61
-
62
- // MEMORY
63
- require('./scripts/storage.js');
64
- require('./scripts/cookie.js');
65
- require('./scripts/indexedDB.js');
66
-
67
- // NUMBERS
68
- require('./scripts/randomNum.js');
69
- require('./scripts/randomNumTmr.js');
70
-
71
- // TIME
72
- require('./scripts/epoch.js');
73
- require('./scripts/parseDate.js');
74
- require('./scripts/dateUTC.js');
75
- require('./scripts/dateIso2Epoch.js');
76
- require('./scripts/dateConvert.js');
77
- require('./scripts/date2MMDDYYYY.js');
78
- require('./scripts/date2Iso.js');
79
- require('./scripts/dateLocal-ISOTime.js');
80
-
81
- // PATH
82
- require('./scripts/pathRail.js');
83
- require('./scripts/pathQuery.js');
84
- require('./scripts/pathHash.js');
85
- require('./scripts/pushState.js');
86
- require('./scripts/anchorToOnClick.js');
87
-
88
- // FILE
89
- require('./scripts/loadFile.js');
90
- //require('./scripts/loadAsset.js');
91
- require('./scripts/loadJson.js');
92
- require('./scripts/loadJsonExternal.js');
93
-
94
- // FORMS
95
- require('./scripts/serializeForm.js');
96
- require('./scripts/serializeObj.js');
97
-
98
- // ARRAY
99
- // require('./scripts/arrayItemFinder.js');
100
- // require('./scripts/arrayDeleteItem.js');
101
- // require('./scripts/arrayMerge.js');
102
- // require('./scripts/arrayUnique.js');
103
- require('./scripts/array.js');
104
- require('./scripts/object2array.js');
105
-
106
- // SCROLL
107
- require('./scripts/scrollToElement.js');
108
- require('./scripts/scrollSmooth.js');
109
- require('./scripts/scrollIndicator.js');
110
- require('./scripts/scrollMemory.js');
111
- require('./scripts/scrollCustom.js');
112
-
113
- // OTHER
114
- require('./scripts/camelCase.js');
115
- require('./scripts/fontFit.js');
116
- require('./scripts/uuid.js');
117
- require('./scripts/noCache.js');
118
- require('./scripts/parseBool.js');
119
- require('./scripts/isPromise.js');
120
- require('./scripts/textChanger.js');
121
- require('./scripts/nl2br.js');
122
- require('./scripts/sleep.js');
123
- require('./scripts/printInfo.js');
124
- require('./scripts/disableSelect.js');
125
- require('./scripts/fullScreen.js');
126
- require('./scripts/disableSpellCheck.js');
127
- require('./scripts/triggerClick.js');
128
- require('./scripts/handleEvent.js');
129
- require('./scripts/window.js');
130
- require('./scripts/purge.js');
131
- require('./scripts/svgSupport.js');
132
- require('./scripts/stopConsole.js');
133
- require('./scripts/onBeforeUnLoad.js');
134
- */
135
-
136
- })();
@@ -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,95 +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
- ],
29
- "example" : "",
30
- "author" : "Dario Passariello",
31
- "active" : true
32
- };
33
-
34
- window.dphelper._list.scripts.push( description );
35
-
36
- /***********************************************************************/
37
-
38
- window.dphelper.array = {
39
-
40
- // FIND
41
- find: ( id, array )=>{
42
- for (let node of array) {
43
- if (node.id === id) return node;
44
-
45
- if (node.children) {
46
- let finalNode = window.dphelper.arrayFindItem(id, node.children);
47
- if (finalNode) return finalNode;
48
- }
49
- }
50
- return false;
51
- },
52
-
53
- // UNIQUE
54
- unique: ( array ) => {
55
- let unique = [...new Set( array )];
56
- return unique;
57
- },
58
-
59
- // DELETE
60
- delete: ( id, array ) => {
61
- array.some(function iter (o,i,a) {
62
-
63
- if (o.Id === id) {
64
- a.splice(i, 1);
65
- return true;
66
- }
67
-
68
- var key = Object.keys(o);
69
-
70
- for (let key of Object.keys(o)) {
71
- let value = o[key];
72
- if(value.length && typeof value === 'object') return value && value.map(iter);
73
- }
74
-
75
- // OLD SCHOOL WAY
76
- // for (var p=0; p < key.length; ++p){
77
- // if( o[key[p]]?.length && typeof o[key[p]] === 'object') return o[key[p]] && o[key[p]].some(iter);
78
- // }
79
-
80
- });
81
-
82
- },
83
-
84
- // MERGE
85
- merge: ( arrayA, arrayB ) => {
86
- for (const key of Object.keys(source)) {
87
- if (source[key] instanceof Object && target[key]) Object.assign(source[key], window.dphelper.mergeArrays(target[key], source[key]));
88
- }
89
-
90
- Object.assign(target || {}, source);
91
- return target;
92
- }
93
-
94
- };
95
-
@@ -1,69 +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
- state: (state, title, url) => {
48
- return history.pushState( state, title, url );
49
- },
50
-
51
- forw: ( times ) => {
52
- return history.go( times );
53
- },
54
-
55
- back: ( times ) => {
56
- return history.go( -Math.abs( times ) );
57
- },
58
-
59
- reload: () => {
60
- // DISCARD POST
61
- return window.location.href = window.location.href;
62
- },
63
-
64
- href: ( url ) => {
65
- // DISCARD POST
66
- return window.location.href = url;
67
- }
68
-
69
- };
@@ -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
- };