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
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" : "Handle Forms",
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
+
@@ -1,108 +1,120 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * onBeforeUnLoad
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.onBeforeUnLoad = () => {
13
-
14
- let is_dirty = false;
15
- let answer = null;
16
- let mex = "You have made some changes which you might want to save.";
17
- let loadOnce = false;
18
- let save_button = document.querySelector("#save_button");
19
-
20
- const beforeUnloadListener = ( event ) => {
21
- event.preventDefault();
22
- return mex;
23
- };
24
-
25
- const nameInput = document.querySelector("#name");
26
-
27
- if( nameInput ){
28
- nameInput.addEventListener( "input" , (event) => {
29
- if (event.target.value !== "") {
30
- addEventListener("beforeunload", beforeUnloadListener, { capture: true });
31
- } else {
32
- removeEventListener("beforeunload", beforeUnloadListener, { capture: true });
33
- }
34
- });
35
- }
36
-
37
- /****************************************************************************** */
38
-
39
- let handleEvent = function( event ){
40
-
41
- if( event.target.type === 'textarea' || event.target.type === 'input' ){
42
- if( is_dirty === false ){
43
- return is_dirty = true;
44
- }
45
- }
46
-
47
- };
48
-
49
- /****************************************************************************** */
50
-
51
- let TEST = function (){
52
- // CHANGE ON KEY
53
- document.body.addEventListener( "keyup" , handleEvent );
54
- }();
55
-
56
- /****************************************************************************** */
57
-
58
- // CHANGE ON ASIDE CLICK
59
- if( loadOnce === false ){
60
- document.body.addEventListener( "click" , function( event ){
61
-
62
- if( event.target.tagName === 'IMG'){
63
-
64
- if( is_dirty === true ) {
65
-
66
- // if the user navigates away from this page via an anchor link,
67
- // popup a new boxy confirmation.
68
- answer = confirm( mex );
69
- if ( answer === true ) {
70
- return is_dirty = false;
71
- }else{
72
- event.preventDefault();
73
- }
74
- }
75
- }
76
-
77
- });
78
- loadOnce = true;
79
- }
80
-
81
- /****************************************************************************** */
82
-
83
- addEventListener('popstate', function(event) {
84
-
85
- if( is_dirty === true ){
86
- answer = confirm( mex );
87
- if ( answer === true ) {
88
- return is_dirty = false;
89
- } else {
90
- event.stopImmediatePropagation();
91
- event.preventDefault();
92
- return mex;
93
- }
94
- }
95
-
96
- });
97
-
98
- /****************************************************************************** */
99
-
100
- window.onbeforeunload = function( event ) {
101
- if( ( is_dirty === true ) && ( answer === null ) ){
102
- event.preventDefault();
103
- return event.returnValue = mex;
104
- //return mex
105
- }
106
- };
107
-
108
- };
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" : "Function Message Before UnLoad",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "onBeforeUnLoad",
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.onBeforeUnLoad = () => {
25
+
26
+ let is_dirty = false;
27
+ let answer = null;
28
+ let mex = "You have made some changes which you might want to save.";
29
+ let loadOnce = false;
30
+ let save_button = document.querySelector("#save_button");
31
+
32
+ const beforeUnloadListener = ( event ) => {
33
+ event.preventDefault();
34
+ return mex;
35
+ };
36
+
37
+ const nameInput = document.querySelector("#name");
38
+
39
+ if( nameInput ){
40
+ nameInput.addEventListener( "input" , (event) => {
41
+ if (event.target.value !== "") {
42
+ addEventListener("beforeunload", beforeUnloadListener, { capture: true });
43
+ } else {
44
+ removeEventListener("beforeunload", beforeUnloadListener, { capture: true });
45
+ }
46
+ });
47
+ }
48
+
49
+ /****************************************************************************** */
50
+
51
+ let handleEvent = function( event ){
52
+
53
+ if( event.target.type === 'textarea' || event.target.type === 'input' ){
54
+ if( is_dirty === false ){
55
+ return is_dirty = true;
56
+ }
57
+ }
58
+
59
+ };
60
+
61
+ /****************************************************************************** */
62
+
63
+ let TEST = function (){
64
+ // CHANGE ON KEY
65
+ document.body.addEventListener( "keyup" , handleEvent );
66
+ }();
67
+
68
+ /****************************************************************************** */
69
+
70
+ // CHANGE ON ASIDE CLICK
71
+ if( loadOnce === false ){
72
+ document.body.addEventListener( "click" , function( event ){
73
+
74
+ if( event.target.tagName === 'IMG'){
75
+
76
+ if( is_dirty === true ) {
77
+
78
+ // if the user navigates away from this page via an anchor link,
79
+ // popup a new boxy confirmation.
80
+ answer = confirm( mex );
81
+ if ( answer === true ) {
82
+ return is_dirty = false;
83
+ }else{
84
+ event.preventDefault();
85
+ }
86
+ }
87
+ }
88
+
89
+ });
90
+ loadOnce = true;
91
+ }
92
+
93
+ /****************************************************************************** */
94
+
95
+ addEventListener('popstate', function(event) {
96
+
97
+ if( is_dirty === true ){
98
+ answer = confirm( mex );
99
+ if ( answer === true ) {
100
+ return is_dirty = false;
101
+ } else {
102
+ event.stopImmediatePropagation();
103
+ event.preventDefault();
104
+ return mex;
105
+ }
106
+ }
107
+
108
+ });
109
+
110
+ /****************************************************************************** */
111
+
112
+ window.onbeforeunload = function( event ) {
113
+ if( ( is_dirty === true ) && ( answer === null ) ){
114
+ event.preventDefault();
115
+ return event.returnValue = mex;
116
+ //return mex
117
+ }
118
+ };
119
+
120
+ };
@@ -1,15 +1,27 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * parse Bool
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.parseBool = (val) => {
13
- if (!val || val.length == null) return true;
14
- return val == '1' ? true : false;
15
- };
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" : "String To Boolean",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "parseBool",
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.parseBool = ( val ) => {
25
+ if ( !val || val.length == null ) return true;
26
+ return val == '1' ? true : false;
27
+ };
@@ -0,0 +1,94 @@
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" : "Array From Rail, Hash Or Query",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "path",
14
+ "subCommand" : [
15
+ {
16
+ "name":"rail",
17
+ "description":"test"
18
+ },{
19
+ "name":"hash",
20
+ "description":"test"
21
+ },{
22
+ "name":"query",
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
+ // ALIAS
36
+ window.dphelper.pathHash = () => {
37
+ console.debug( 'dpHelper: Please use "dphelper.path.hash()"' );
38
+ return window.dphelper.path.hash();
39
+ };
40
+
41
+ window.dphelper.pathQuery = () => {
42
+ console.debug( 'dpHelper: Please use "dphelper.path.query()"' );
43
+ return window.dphelper.path.query();
44
+ };
45
+
46
+ window.dphelper.pathRail = () => {
47
+ console.debug( 'dpHelper: Please use "dphelper.path.rail()"' );
48
+ return window.dphelper.path.rail();
49
+ };
50
+
51
+ /***********************************************************************/
52
+
53
+ window.dphelper.path = {
54
+
55
+ rail: () => {
56
+ const array = location.href
57
+ .split("?")[0]
58
+ .replace(location.protocol, '')
59
+ .replace(location.host, '')
60
+ .replace(location.hash, '')
61
+ .split('/');
62
+ if ( array.length > 0 ) {
63
+ const arrayFinal = array.filter(item => item);
64
+ return arrayFinal;
65
+ } else {
66
+ return;
67
+ }
68
+ },
69
+
70
+ hash: () => {
71
+ const array = location.hash.replace('#', '').split('/');
72
+ if (array.length) {
73
+ return array.filter(item => item);
74
+ } else {
75
+ return ["empty"];
76
+ }
77
+ },
78
+
79
+ query: () => {
80
+ let x, y, array = [], search = location.search;
81
+ if (search) {
82
+ search.replace("?", '').split('&')
83
+ .map(x => {
84
+ y = x.split('=');
85
+ array[y[0]] = y[1];
86
+ });
87
+ return array;
88
+ } else {
89
+ return ["empty"];
90
+ }
91
+ }
92
+
93
+ };
94
+
@@ -1,16 +1,28 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * printInfo
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.printInfo = () => {
13
- console.groupCollapsed('%cApi:%c', "color:orange", "");
14
- console.debug(dphelper.api);
15
- console.groupEnd();
16
- };
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" : "Print Console Info About dpHelper",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "printInfo",
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.printInfo = () => {
25
+ console.groupCollapsed('%cApi:%c', "color:orange", "");
26
+ console.debug(dphelper.api);
27
+ console.groupEnd();
28
+ };
package/scripts/purge.js CHANGED
@@ -1,41 +1,53 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * purge
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.purge = ( d = body, time = 10000 ) => {
13
-
14
- setTimeout(() => {
15
- if( d === undefined ) return null;
16
-
17
- let a = d.attributes, i, l, n;
18
-
19
- if (a) {
20
- l = a.length;
21
- for( i = 0; i < l; i += 1 ) {
22
- n = a[i].name;
23
- if( typeof d[n] === 'function' ) { d[n] = null; }
24
- if( typeof d[n] === 'undefined' ) { d[n] = null; }
25
- }
26
-
27
- }
28
-
29
- a = d.childNodes;
30
-
31
- if (a) {
32
- l = a.length;
33
- for( i = 0; i < l; i += 1 ) {
34
- Purge( d.childNodes[i] );
35
- }
36
- }
37
- }, time );
38
-
39
- };
40
-
41
- // purge()
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" : "Purge From Memory",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "purge",
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.purge = ( d = body, time = 10000 ) => {
25
+
26
+ setTimeout(() => {
27
+ if( d === undefined ) return null;
28
+
29
+ let a = d.attributes, i, l, n;
30
+
31
+ if (a) {
32
+ l = a.length;
33
+ for( i = 0; i < l; i += 1 ) {
34
+ n = a[i].name;
35
+ if( typeof d[n] === 'function' ) { d[n] = null; }
36
+ if( typeof d[n] === 'undefined' ) { d[n] = null; }
37
+ }
38
+
39
+ }
40
+
41
+ a = d.childNodes;
42
+
43
+ if (a) {
44
+ l = a.length;
45
+ for( i = 0; i < l; i += 1 ) {
46
+ Purge( d.childNodes[i] );
47
+ }
48
+ }
49
+ }, time );
50
+
51
+ };
52
+
53
+ // purge()
@@ -1,14 +1,33 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * pushState
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.pushState = (state, title, url) => {
13
- return history.pushState( state, title, url );
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" : "Push In To State Of Browser (Ajax)",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "push",
14
+ "subCommand" : [
15
+ {
16
+ "name":"state",
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.push = {
30
+ state: (state, title, url) => {
31
+ return history.pushState( state, title, url );
32
+ }
33
+ };