dphelper 0.2.30 → 0.2.34

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 (82) hide show
  1. package/data/list.json +19 -39
  2. package/init.js +19 -5
  3. package/package.json +5 -7
  4. package/scripts/anchorToOnClick.js +15 -3
  5. package/scripts/array.js +29 -3
  6. package/scripts/console.js +86 -0
  7. package/scripts/cookie.js +97 -71
  8. package/scripts/currency.js +31 -11
  9. package/scripts/date.js +101 -0
  10. package/scripts/disable.js +90 -0
  11. package/scripts/event.js +39 -0
  12. package/scripts/font.js +52 -0
  13. package/scripts/form.js +113 -0
  14. package/scripts/indexedDB.js +47 -10
  15. package/scripts/json.js +42 -0
  16. package/scripts/load.js +70 -0
  17. package/scripts/noCache.js +26 -14
  18. package/scripts/number.js +42 -0
  19. package/scripts/obj.js +81 -0
  20. package/scripts/onBeforeUnLoad.js +120 -108
  21. package/scripts/parseBool.js +27 -15
  22. package/scripts/path.js +94 -0
  23. package/scripts/promise.js +35 -0
  24. package/scripts/purge.js +53 -41
  25. package/scripts/pushState.js +33 -14
  26. package/scripts/screen.js +64 -0
  27. package/scripts/scrollbar.js +226 -0
  28. package/scripts/{handleEvent.js → shortcut.js} +70 -59
  29. package/scripts/storage.js +29 -3
  30. package/scripts/svg.js +372 -0
  31. package/scripts/text.js +78 -0
  32. package/scripts/time.js +41 -0
  33. package/scripts/timer.js +35 -0
  34. package/scripts/trigger.js +37 -0
  35. package/scripts/uuid.js +33 -14
  36. package/scripts/window.js +50 -38
  37. package/#cmd.exe.lnk +0 -0
  38. package/.github/workflows/codeql-analysis.yml +0 -70
  39. package/scripts/.OLD/arrayDeleteItem.js +0 -35
  40. package/scripts/.OLD/arrayItemFinder.js +0 -22
  41. package/scripts/.OLD/arrayMerge.js +0 -20
  42. package/scripts/.OLD/arrayUnique.js +0 -15
  43. package/scripts/.OLD/loadAsset.js +0 -26
  44. package/scripts/addListenerMulti.js +0 -10
  45. package/scripts/camelCase.js +0 -29
  46. package/scripts/date2Iso.js +0 -20
  47. package/scripts/date2MMDDYYYY.js +0 -16
  48. package/scripts/dateConvert.js +0 -20
  49. package/scripts/dateIso2Epoch.js +0 -17
  50. package/scripts/dateLocal-ISOTime.js +0 -17
  51. package/scripts/dateUTC.js +0 -14
  52. package/scripts/disableSelect.js +0 -46
  53. package/scripts/disableSpellCheck.js +0 -21
  54. package/scripts/epoch.js +0 -14
  55. package/scripts/fontFit.js +0 -24
  56. package/scripts/fullScreen.js +0 -40
  57. package/scripts/isPromise.js +0 -14
  58. package/scripts/jsonCounter.js +0 -21
  59. package/scripts/loadFile.js +0 -17
  60. package/scripts/loadJson.js +0 -15
  61. package/scripts/loadJsonExternal.js +0 -32
  62. package/scripts/nl2br.js +0 -14
  63. package/scripts/object2array.js +0 -16
  64. package/scripts/parseDate.js +0 -19
  65. package/scripts/pathHash.js +0 -19
  66. package/scripts/pathQuery.js +0 -24
  67. package/scripts/pathRail.js +0 -25
  68. package/scripts/printInfo.js +0 -16
  69. package/scripts/randomNum.js +0 -14
  70. package/scripts/randomNumTmr.js +0 -14
  71. package/scripts/scrollCustom.js +0 -41
  72. package/scripts/scrollIndicator.js +0 -67
  73. package/scripts/scrollMemory.js +0 -26
  74. package/scripts/scrollSmooth.js +0 -74
  75. package/scripts/scrollToElement.js +0 -25
  76. package/scripts/serializeForm.js +0 -94
  77. package/scripts/serializeObj.js +0 -47
  78. package/scripts/sleep.js +0 -14
  79. package/scripts/stopConsole.js +0 -49
  80. package/scripts/svgSupport.js +0 -346
  81. package/scripts/textChanger.js +0 -24
  82. package/scripts/triggerClick.js +0 -16
@@ -0,0 +1,90 @@
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",
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
+ /***********************************************************************/
39
+
40
+ window.dphelper.disable = {
41
+
42
+ select: function( el = 'body' ){
43
+
44
+ var $ = require( "jquery" );
45
+ var e = e || event;
46
+
47
+ const disabling = ( el ) => {
48
+ const $ = require( "jquery" );
49
+
50
+ $( el ).each( function( e ){
51
+
52
+ $( this )
53
+ .prop( "unselectable" , "on" )
54
+ .css( "MozUserSelect" , "none" )
55
+ .css( "WebKitUserSelect" , "none" )
56
+ .on( "select" , function(){ return false; })
57
+ .on( "selectstart" , function(){ return false; });
58
+
59
+ //this.onselectstart = function() { return false }
60
+ //this.oncontextmenu = function() { return false }
61
+
62
+ $( 'img, a, input, button' ).on( 'dragstart' , function( e ) {
63
+ e.preventDefault();
64
+ return false;
65
+ });
66
+
67
+ });
68
+
69
+ };
70
+
71
+ document.querySelector( el ).addEventListener( 'mousedown' , function( e ){ disabling( el ); }, false );
72
+ document.querySelector( el ).onmousedown = function( e ){ disabling( el ); };
73
+ console.debug("%cSelection Disabled:%c true", "color:gray", "");
74
+
75
+ },
76
+
77
+ spellCheck: ( tmr = 5000 ) => {
78
+
79
+ setInterval( () => {
80
+ let inputs = document.querySelectorAll("input[type=text], textarea");
81
+ for(let i = 0; i < inputs.length; i++){
82
+ if( !inputs[i].getAttribute("spellcheck") ){
83
+ inputs[i].setAttribute("spellcheck", "false");
84
+ }
85
+ }
86
+ }, tmr );
87
+
88
+ }
89
+
90
+ };
@@ -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" : "Events",
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" : "Fonts",
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" : "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" : "IndexedDB Manager",
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" );
@@ -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",
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 Files",
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",
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" : "Numbers",
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
+ };
package/scripts/obj.js ADDED
@@ -0,0 +1,81 @@
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" : "Objects",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "form",
14
+ "subCommand" : [
15
+ {
16
+ "name":"toArray",
17
+ "description":"test"
18
+ },{
19
+ "name":"serialize",
20
+ "description":"test"
21
+ },{
22
+ "name":"deSerialize",
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.obj = {
36
+
37
+ toArray: ( object ) => {
38
+ return Object
39
+ .entries( object )
40
+ .map( ( [ key, value ] ) => Object.assign( { key } , value && typeof value === 'object' ? { forms: ObjToArray( value ) } : { value, forms: [] } ) );
41
+ },
42
+
43
+ serialize: (value) => {
44
+
45
+ if (typeof value === 'function') {
46
+ return value.toString();
47
+ }
48
+
49
+ if (typeof value === 'object') {
50
+ let serializeObject = {};
51
+ for (const [objectKey, objectValue] of Object.entries(value)) {
52
+ console.info( `objectKey=${objectKey} value=${objectValue}` );
53
+ serializeObject[objectKey] = window.dphelper.objSerialize(objectValue);
54
+ }
55
+ return serializeObject;
56
+ }
57
+
58
+ return value;
59
+
60
+ },
61
+
62
+ deSerialize: (valueNew) => {
63
+
64
+ if (valueNew.toLowerCase().startsWith( 'function(' ) ) {
65
+ return Function('"use strict";return ' + valueNew);
66
+ }
67
+
68
+ if (typeof valueNew === 'object') {
69
+ let deserializeObject = {};
70
+ for (const [objectKey, objectValue] of Object.entries(valueNew)) {
71
+ console.info( `objectKey=${objectKey} value=${objectValue}` );
72
+ deserializeObject[objectKey] = window.dphelper.objDeSerialize(objectValue);
73
+ }
74
+ return deserializeObject;
75
+ }
76
+
77
+ return value;
78
+ }
79
+
80
+ };
81
+