dphelper 0.2.28 → 0.2.32

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 (91) hide show
  1. package/data/.OLD/~camelCase.js +41 -0
  2. package/{scripts/date2Iso.js → data/.OLD/~date2Iso.js} +31 -20
  3. package/{scripts/date2MMDDYYYY.js → data/.OLD/~date2MMDDYYYY.js} +27 -16
  4. package/{scripts/dateConvert.js → data/.OLD/~dateConvert.js} +31 -20
  5. package/{scripts/dateIso2Epoch.js → data/.OLD/~dateIso2Epoch.js} +28 -17
  6. package/{scripts/dateLocal-ISOTime.js → data/.OLD/~dateLocal-ISOTime.js} +28 -17
  7. package/data/.OLD/~dateUTC.js +25 -0
  8. package/{scripts/disableSpellCheck.js → data/.OLD/~disableSpellCheck.js} +32 -21
  9. package/data/.OLD/~loadJson.js +27 -0
  10. package/{scripts/loadJsonExternal.js → data/.OLD/~loadJsonExternal.js} +44 -32
  11. package/data/.OLD/~nl2br.js +26 -0
  12. package/{scripts/object2array.js → data/.OLD/~object2array.js} +15 -3
  13. package/data/.OLD/~parseDate.js +30 -0
  14. package/data/.OLD/~pathHash.js +27 -0
  15. package/data/.OLD/~pathQuery.js +28 -0
  16. package/data/.OLD/~pathRail.js +27 -0
  17. package/data/.OLD/~randomNumTmr.js +26 -0
  18. package/{scripts/scrollIndicator.js → data/.OLD/~scrollIndicator.js} +0 -0
  19. package/{scripts/scrollMemory.js → data/.OLD/~scrollMemory.js} +0 -0
  20. package/{scripts/scrollSmooth.js → data/.OLD/~scrollSmooth.js} +0 -0
  21. package/{scripts/scrollToElement.js → data/.OLD/~scrollToElement.js} +0 -0
  22. package/{scripts/svgSupport.js → data/.OLD/~svgSupport.js} +0 -0
  23. package/data/list.json +19 -26
  24. package/init.js +19 -5
  25. package/package.json +7 -9
  26. package/scripts/anchorToOnClick.js +15 -3
  27. package/scripts/array.js +29 -3
  28. package/scripts/console.js +86 -0
  29. package/scripts/cookie.js +97 -71
  30. package/scripts/currency.js +31 -11
  31. package/scripts/date.js +101 -0
  32. package/scripts/disable.js +88 -0
  33. package/scripts/event.js +39 -0
  34. package/scripts/font.js +52 -0
  35. package/scripts/form.js +113 -0
  36. package/scripts/indexedDB.js +47 -10
  37. package/scripts/isPromise.js +26 -14
  38. package/scripts/json.js +42 -0
  39. package/scripts/load.js +70 -0
  40. package/scripts/noCache.js +26 -14
  41. package/scripts/number.js +42 -0
  42. package/scripts/obj.js +81 -0
  43. package/scripts/onBeforeUnLoad.js +120 -108
  44. package/scripts/parseBool.js +27 -15
  45. package/scripts/path.js +94 -0
  46. package/scripts/printInfo.js +28 -16
  47. package/scripts/purge.js +53 -41
  48. package/scripts/pushState.js +33 -14
  49. package/scripts/screen.js +64 -0
  50. package/scripts/scrollbar.js +226 -0
  51. package/scripts/{handleEvent.js → shortcut.js} +70 -59
  52. package/scripts/storage.js +29 -3
  53. package/scripts/svg.js +372 -0
  54. package/scripts/text.js +78 -0
  55. package/scripts/time.js +41 -0
  56. package/scripts/timer.js +35 -0
  57. package/scripts/trigger.js +37 -0
  58. package/scripts/uuid.js +33 -14
  59. package/scripts/window.js +50 -38
  60. package/#cmd.exe.lnk +0 -0
  61. package/.github/workflows/codeql-analysis.yml +0 -70
  62. package/README.md.bak +0 -70
  63. package/scripts/.OLD/arrayDeleteItem.js +0 -35
  64. package/scripts/.OLD/arrayItemFinder.js +0 -22
  65. package/scripts/.OLD/arrayMerge.js +0 -20
  66. package/scripts/.OLD/arrayUnique.js +0 -15
  67. package/scripts/.OLD/loadAsset.js +0 -26
  68. package/scripts/addListenerMulti.js +0 -10
  69. package/scripts/camelCase.js +0 -29
  70. package/scripts/dateUTC.js +0 -14
  71. package/scripts/disableSelect.js +0 -46
  72. package/scripts/epoch.js +0 -14
  73. package/scripts/fontFit.js +0 -24
  74. package/scripts/fullScreen.js +0 -40
  75. package/scripts/jsonCounter.js +0 -21
  76. package/scripts/loadFile.js +0 -17
  77. package/scripts/loadJson.js +0 -15
  78. package/scripts/nl2br.js +0 -14
  79. package/scripts/parseDate.js +0 -19
  80. package/scripts/pathHash.js +0 -20
  81. package/scripts/pathQuery.js +0 -24
  82. package/scripts/pathRail.js +0 -26
  83. package/scripts/randomNum.js +0 -14
  84. package/scripts/randomNumTmr.js +0 -14
  85. package/scripts/scrollCustom.js +0 -41
  86. package/scripts/serializeForm.js +0 -94
  87. package/scripts/serializeObj.js +0 -47
  88. package/scripts/sleep.js +0 -14
  89. package/scripts/stopConsole.js +0 -49
  90. package/scripts/textChanger.js +0 -24
  91. package/scripts/triggerClick.js +0 -16
@@ -0,0 +1,88 @@
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" : "Disable Select",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "disable",
14
+ "subCommand" : [
15
+ {
16
+ "name":"select",
17
+ "description":"test"
18
+ },{
19
+ "name":"spellCheck",
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
+ // ALIAS
33
+ window.dphelper.disableSelect = ( el = 'body' ) => {
34
+ console.debug( "Please, use 'dphelper.disable.select' instead dphelper.disableSelect" );
35
+ window.dphelper.disable.select( el = 'body' );
36
+ };
37
+
38
+ window.dphelper.disable = {
39
+
40
+ select: function( el = 'body' ){
41
+
42
+ var $ = require( "jquery" );
43
+ var e = e || event;
44
+
45
+ const disabling = ( el ) => {
46
+ const $ = require( "jquery" );
47
+
48
+ $( el ).each( function( e ){
49
+
50
+ $( this )
51
+ .prop( "unselectable" , "on" )
52
+ .css( "MozUserSelect" , "none" )
53
+ .css( "WebKitUserSelect" , "none" )
54
+ .on( "select" , function(){ return false; })
55
+ .on( "selectstart" , function(){ return false; });
56
+
57
+ //this.onselectstart = function() { return false }
58
+ //this.oncontextmenu = function() { return false }
59
+
60
+ $( 'img, a, input, button' ).on( 'dragstart' , function( e ) {
61
+ e.preventDefault();
62
+ return false;
63
+ });
64
+
65
+ });
66
+
67
+ };
68
+
69
+ document.querySelector( el ).addEventListener( 'mousedown' , function( e ){ disabling( el ); }, false );
70
+ document.querySelector( el ).onmousedown = function( e ){ disabling( el ); };
71
+ console.debug("%cSelection Disabled:%c true", "color:gray", "");
72
+
73
+ },
74
+
75
+ spellCheck: ( tmr = 5000 ) => {
76
+
77
+ setInterval( () => {
78
+ let inputs = document.querySelectorAll("input[type=text], textarea");
79
+ for(let i = 0; i < inputs.length; i++){
80
+ if( !inputs[i].getAttribute("spellcheck") ){
81
+ inputs[i].setAttribute("spellcheck", "false");
82
+ }
83
+ }
84
+ }, tmr );
85
+
86
+ }
87
+
88
+ };
@@ -0,0 +1,39 @@
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" : "Event Listener",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "event",
14
+ "subCommand" : [
15
+ {
16
+ "name":"multi",
17
+ "description":"test",
18
+ }
19
+ ],
20
+ "example" : "",
21
+ "author" : "Dario Passariello",
22
+ "active" : true
23
+ };
24
+
25
+ window.dphelper._list.scripts.push( description );
26
+
27
+ /***********************************************************************/
28
+
29
+ window.dphelper.event ={
30
+
31
+ multi: ( element, eventNames, listener ) => {
32
+ var events = eventNames.split(' ');
33
+ for (var i=0, iLen = events.length; i < iLen; ++i ) {
34
+ element.addEventListener( events[i], listener, false );
35
+ }
36
+
37
+ },
38
+
39
+ };
@@ -0,0 +1,52 @@
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" : "Fit Text To Container",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "font",
14
+ "subCommand" : [
15
+ {
16
+ "name":"fitContainer",
17
+ "description":""
18
+ }
19
+ ],
20
+ "example" : "",
21
+ "author" : "Dario Passariello",
22
+ "active" : true
23
+ };
24
+
25
+ window.dphelper._list.scripts.push( description );
26
+
27
+ /***********************************************************************/
28
+
29
+ window.dphelper.font = {
30
+
31
+ fitContainer: ( name ) => {
32
+ if( !name ) return;
33
+
34
+ function fitStart(){
35
+ var divs = document.querySelectorAll( name );
36
+ if( divs.length <= 0 ) return;
37
+ for(var i = 0; i < divs.length; i++) {
38
+ var fontSize = divs[i].offsetWidth * 0.05;
39
+ divs[i].style.fontSize = fontSize+'px';
40
+ }
41
+ }
42
+
43
+ window.dphelper.addListenerMulti( window , 'load resize', () => {
44
+ fitStart( name );
45
+ });
46
+
47
+ }
48
+
49
+ };
50
+
51
+
52
+
@@ -0,0 +1,113 @@
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" : "Handle Forms",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "form",
14
+ "subCommand" : [
15
+ {
16
+ "name":"serialize",
17
+ "description":"test"
18
+ }
19
+ ],
20
+ "example" : "",
21
+ "author" : "Dario Passariello",
22
+ "active" : true
23
+ };
24
+
25
+ window.dphelper._list.scripts.push( description );
26
+
27
+ /***********************************************************************/
28
+
29
+ window.dphelper.form = {
30
+
31
+ serialize: ( form ) => {
32
+
33
+ const $ = require("jquery");
34
+ const el = this;
35
+ //const el = $( form );
36
+
37
+ var self = el,
38
+
39
+ json = {},
40
+ push_counters = {},
41
+
42
+ patterns = {
43
+ //"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
44
+ "validate": /[a-zA-Z][a-zA-Z0-9-_.]/, //{1,200}
45
+ "key": /[a-zA-Z0-9_]+|(?=\[\])/g,
46
+ "push": /^$/,
47
+ "fixed": /^\d+$/,
48
+ "named": /^[a-zA-Z0-9_]+$/
49
+ };
50
+
51
+ el.build = function(base, key, value) {
52
+ base[key] = isNaN(value) || Array.isArray(value) ? value : Number(value);
53
+ return base;
54
+ };
55
+
56
+ el.push_counter = function(key) {
57
+ if (push_counters[key] === undefined) {
58
+ push_counters[key] = 0;
59
+ }
60
+ return push_counters[key]++;
61
+ };
62
+
63
+ $.each( $(el).serializeArray(), function() {
64
+
65
+ // skip invalid keys
66
+ if (!patterns.validate.test(el.name)) {
67
+ return;
68
+ }
69
+
70
+ var k,
71
+ keys = el.name.match(patterns.key),
72
+ merge = el.value,
73
+ reverse_key = el.name;
74
+
75
+ if( merge === 'false' ) merge = Boolean(false);
76
+ if( merge === 'true' ) merge = Boolean(true);
77
+ if( merge === 'off' ) merge = Boolean(false);
78
+ if( merge === 'on' ) merge = Boolean(true);
79
+ if( merge === '[]' ) merge = [];
80
+ if( merge === '{}' ) merge = {};
81
+ if( merge === 'undefined' ) merge = undefined;
82
+ if( merge === 'null' ) merge = null;
83
+ if( merge === '' ) merge = '';
84
+
85
+ while ((k = keys.pop()) !== undefined) {
86
+
87
+ // adjust reverse_key
88
+ reverse_key = reverse_key.replace(new RegExp("\\[" + k + "\\]$"), '');
89
+
90
+ // push
91
+ if (k.match(patterns.push)) {
92
+ merge = self.build([], self.push_counter(reverse_key), merge);
93
+ }
94
+
95
+ // fixed
96
+ else if (k.match(patterns.fixed)) {
97
+ merge = self.build([], k, merge);
98
+ }
99
+
100
+ // named
101
+ else if (k.match(patterns.named)) {
102
+ merge = self.build({}, k, merge);
103
+ }
104
+
105
+ }
106
+
107
+ json = $.extend(true, json, merge);
108
+ });
109
+
110
+ return json;
111
+ }
112
+
113
+ };
@@ -1,14 +1,49 @@
1
1
  /*!
2
2
  * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * indexedDB
5
- *
6
3
  * Copyright (c) 2021, Dario Passariello.
7
4
  * Licensed under the Apache-2.0 License.
8
5
  */
9
6
 
10
7
  /***********************************************************************/
11
8
 
9
+ var description = {
10
+ "name" : "Custom indexedDB Management",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "indexedDB",
14
+ "subCommand" : [
15
+ {
16
+ "name":"create",
17
+ "description" : "test",
18
+ },{
19
+ "name":"open",
20
+ "description" : "test",
21
+ },{
22
+ "name":"store",
23
+ "description" : "test",
24
+ },{
25
+ "name":"insert",
26
+ "description" : "test",
27
+ },{
28
+ "name":"update",
29
+ "description" : "test",
30
+ },{
31
+ "name":"get",
32
+ "description" : "test",
33
+ },{
34
+ "name":"list",
35
+ "description" : "test",
36
+ },
37
+ ],
38
+ "example" : "",
39
+ "author" : "Dario Passariello",
40
+ "active" : true
41
+ };
42
+
43
+ window.dphelper._list.scripts.push( description );
44
+
45
+ /***********************************************************************/
46
+
12
47
  window.dphelper.indexedDB = {
13
48
 
14
49
  //CREATE: dphelper.indexedDB.create('database','table','id')
@@ -95,7 +130,7 @@ open: ( storeName ) => {
95
130
  //INSERT: indexedDB.insert('myDB','Mytable','Mykey','MyValue')
96
131
  insert: ( storeName, table, key, value ) => {
97
132
 
98
- console.log( storeName, table, key, value );
133
+ //console.log( storeName, table, key, value );
99
134
 
100
135
  var request = window.indexedDB.open( storeName, 1 );
101
136
 
@@ -165,17 +200,19 @@ open: ( storeName ) => {
165
200
 
166
201
  },
167
202
 
203
+ list: () => {
204
+ const promise = indexedDB.databases();
205
+ promise.then(databases => {
206
+ console.info( "dpHelper: " + databases );
207
+ });
208
+ }
209
+
168
210
  };
169
211
 
170
212
  // CHECK IF INDEXEDDB EXIST
171
213
  // ***************************************************************************************************/
172
214
 
173
- window.dphelper.dbExist = () => {
174
- const promise = indexedDB.databases();
175
- promise.then(databases => {
176
- console.log(databases);
177
- });
178
- };
215
+
179
216
 
180
217
  // START DEFAULT DB
181
218
  // window.dphelper.indexedDB.open( "dpHelper" );
@@ -1,14 +1,26 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * isPromise
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.isPromise = (p) => {
13
- return p && Object.prototype.toString.call(p) === "[object Promise]";
14
- };
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" : "Check If It's a Promise",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "isPromise",
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.isPromise = (p) => {
25
+ return p && Object.prototype.toString.call(p) === "[object Promise]";
26
+ };
@@ -0,0 +1,42 @@
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" : "Json Handler",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "json",
14
+ "subCommand" : [
15
+ {
16
+ "name":"counter",
17
+ "description" : "test",
18
+ }
19
+ ],
20
+ "example" : "",
21
+ "author" : "Dario Passariello",
22
+ "active" : true
23
+ };
24
+
25
+ window.dphelper._list.scripts.push( description );
26
+
27
+ /***********************************************************************/
28
+
29
+ window.dphelper.json = {
30
+
31
+ counter: (json, key, val) => {
32
+ if (!json) return null;
33
+ let keyCount;
34
+ if (key && val) {
35
+ keyCount = Object.keys(jsonObject).length;
36
+ } else {
37
+ keyCount = json.items.filter(value => value.key === val).lengt;
38
+ }
39
+ return keyCount;
40
+ }
41
+
42
+ };
@@ -0,0 +1,70 @@
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" : "Load File Content",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "load",
14
+ "subCommand" : [
15
+ {
16
+ "name":"file",
17
+ "description":"test"
18
+ },{
19
+ "name":"json",
20
+ "description":"test"
21
+ },{
22
+ "name":"jsonRemote",
23
+ "description":"test"
24
+ }
25
+ ],
26
+ "example" : "",
27
+ "author" : "Dario Passariello",
28
+ "active" : true
29
+ };
30
+
31
+ window.dphelper._list.scripts.push( description );
32
+
33
+ /***********************************************************************/
34
+
35
+ window.dphelper.load = {
36
+
37
+ file: (element, path) => {
38
+ fetch(path).then(async function (response) {
39
+ const text = await response.text();
40
+ document.querySelector( element ).innerHTML = dphelper.nl2br( String(text) );
41
+ });
42
+ },
43
+
44
+ json: function( file ){
45
+ if ( file.match(/.(json)$/i ) ) return require( '' + file + '' );
46
+ },
47
+
48
+ jsonRemote: ( path, method='GET', type='application/json' ) => {
49
+
50
+ fetch( path ,{
51
+ method: method,
52
+ headers : {
53
+ 'Content-Type': type
54
+ }
55
+ })
56
+ .then(
57
+ function(response) {
58
+ //return response.json();
59
+ return response;
60
+ }
61
+ )
62
+ .then(
63
+ function( myFile ) {
64
+ return myFile;
65
+ }
66
+ );
67
+
68
+ }
69
+
70
+ };
@@ -1,14 +1,26 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * no cache
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.noCache = (uri) => {
13
- return uri.concat( /\?/.test(uri) ? '&' : '?', 't=', dphelper.rnd() );
14
- };
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" : "Avoid Caching JS Or Images",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "noCache",
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.noCache = (uri) => {
25
+ return uri.concat( /\?/.test(uri) ? '&' : '?', 't=', dphelper.rnd() );
26
+ };
@@ -0,0 +1,42 @@
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" : "Number Generator",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "number",
14
+ "subCommand" : [
15
+ {
16
+ "name":"rnd",
17
+ "description":"test",
18
+ },{
19
+ "name":"tmr",
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.number = {
33
+
34
+ rnd: () => {
35
+ return Math.floor( 100000 + Math.random() * dphelper.number.tmr() );
36
+ },
37
+
38
+ tmr: () => {
39
+ return Math.round( dphelper.time.epoch() / 1000 );
40
+ }
41
+
42
+ };