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.
Files changed (51) hide show
  1. package/index.js +2 -12
  2. package/index.js.LICENSE.txt +24 -0
  3. package/package.json +2 -5
  4. package/.editorconfig +0 -14
  5. package/.eslintrc.json +0 -36
  6. package/.gitattributes +0 -2
  7. package/.jshintrc +0 -13
  8. package/.prettierignore +0 -2
  9. package/.prettierrc +0 -7
  10. package/.vscode/settings.json +0 -19
  11. package/3party/shortcut.js +0 -224
  12. package/data/list.json +0 -19
  13. package/index.d.ts +0 -9
  14. package/init.js +0 -51
  15. package/scripts/anchorToOnClick.js +0 -47
  16. package/scripts/array.js +0 -142
  17. package/scripts/browser.js +0 -65
  18. package/scripts/console.js +0 -86
  19. package/scripts/coodinates.js +0 -41
  20. package/scripts/cookie.js +0 -97
  21. package/scripts/currency.js +0 -41
  22. package/scripts/date.js +0 -101
  23. package/scripts/disable.js +0 -90
  24. package/scripts/event.js +0 -39
  25. package/scripts/font.js +0 -52
  26. package/scripts/form.js +0 -113
  27. package/scripts/function.js +0 -47
  28. package/scripts/indexedDB.js +0 -222
  29. package/scripts/json.js +0 -42
  30. package/scripts/load.js +0 -85
  31. package/scripts/noCache.js +0 -26
  32. package/scripts/number.js +0 -66
  33. package/scripts/obj.js +0 -81
  34. package/scripts/onBeforeUnLoad.js +0 -120
  35. package/scripts/parseBool.js +0 -27
  36. package/scripts/path.js +0 -94
  37. package/scripts/promise.js +0 -35
  38. package/scripts/purge.js +0 -53
  39. package/scripts/screen.js +0 -64
  40. package/scripts/scrollbar.js +0 -226
  41. package/scripts/shortcut.js +0 -70
  42. package/scripts/storage.js +0 -62
  43. package/scripts/svg.js +0 -372
  44. package/scripts/text.js +0 -78
  45. package/scripts/time.js +0 -41
  46. package/scripts/timer.js +0 -35
  47. package/scripts/trigger.js +0 -46
  48. package/scripts/type.js +0 -56
  49. package/scripts/uuid.js +0 -33
  50. package/scripts/window.js +0 -50
  51. package/ws.code-workspace +0 -73
@@ -1,222 +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" : "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
-
47
- window.dphelper.indexedDB = {
48
-
49
- //CREATE: dphelper.indexedDB.create('database','table','id')
50
- create: ( storeName, table, name ) => {
51
-
52
- var request = window.indexedDB.open( storeName, 1 );
53
-
54
- request.onerror = ( e ) => {
55
- console.debug(e, "Database create error: " + e.target.errorCode);
56
- return;
57
- };
58
-
59
- request.onupgradeneeded = ( e ) => {
60
- var db = e.target.result;
61
- var objectStore = db.createObjectStore( table, { keyPath: 'id', autoIncrement:true } );
62
- objectStore.createIndex( 'id', 'id', { unique: true });
63
- // objectStore.createIndex( 'id', 'id', { unique: true });
64
- // objectStore.createIndex( 'json', 'json', { unique: false });
65
- // objectStore.createIndex( 'active', 'active', { unique: false });
66
- // console.debug( db );
67
- // db.close();
68
- };
69
-
70
- },
71
-
72
- /************************************************************************/
73
-
74
- open: ( storeName ) => {
75
-
76
- const indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
77
-
78
- if (!indexedDB) {
79
- console.debug( e );
80
- console.debug( "Your browser doesn't support a skey version of IndexedDB. Such and such feature will not be available.");
81
- console.debug( "Something went badly wrong with your indexedDB!" );
82
- }
83
-
84
- var request = window.indexedDB.open( storeName , 1 );
85
-
86
- request.onsuccess = ( e ) => {
87
- // console.debug( 'indexedDB "' + storeName + '" open' );
88
- // return e.target.result;
89
- // request.close();
90
- };
91
- request.onerror = ( e ) => {
92
- console.debug( "Database open error: " + e.target.errorCode );
93
- return;
94
- };
95
- return request;
96
-
97
- },
98
-
99
- /************************************************************************/
100
-
101
- //STORE: indexedDB.store('myDB','MyTable')
102
- store: ( storeName, table ) => {
103
- var request = indexedDB.open( storeName );
104
-
105
- request.onsuccess = function (e){
106
-
107
- var database = e.target.result;
108
- var version = parseInt(database.version);
109
- database.close();
110
-
111
- //var secondRequest = indexedDB.open( storeName , version + 1 );
112
- var secondRequest = indexedDB.open( storeName , 1 );
113
-
114
- secondRequest.onupgradeneeded = function (e) {
115
- // var database = e.target.result;
116
- // database.createObjectStore( table, { keyPath: 'id' });
117
- var db = e.target.result;
118
- var objectStore = db.createObjectStore( table, { keyPath: 'id', autoIncrement:true } );
119
- objectStore.createIndex( 'id', 'id', { unique: true });
120
- };
121
-
122
- secondRequest.onsuccess = function (e) {
123
- e.target.result.close();
124
- };
125
- };
126
-
127
- },
128
-
129
- /************************************************************************/
130
- //INSERT: indexedDB.insert('myDB','Mytable','Mykey','MyValue')
131
- insert: ( storeName, table, key, value ) => {
132
-
133
- //console.log( storeName, table, key, value );
134
-
135
- var request = window.indexedDB.open( storeName, 1 );
136
-
137
- request.onerror = ( e ) => {
138
- console.debug(e, "Database insert error: " + e.target.errorCode);
139
- return;
140
- };
141
-
142
- request.onsuccess = ( e ) => {
143
- try{
144
- var db = e.target.result;
145
- var StoreObj = db.transaction( storeName , "readwrite").objectStore( storeName );
146
- StoreObj.add( value, key, value );
147
- db.close();
148
- }catch( e ){
149
- console.debug( e, "IndexDB insert not work" );
150
- }
151
- };
152
- },
153
-
154
- /************************************************************************/
155
-
156
- //UPDATE: indexedDB.update('myDB','Mykey','MyValue')
157
- update: ( storeName, table, key, value ) => {
158
-
159
- var request = window.indexedDB.open( storeName, 1 );
160
- request.onerror = ( e ) => {
161
- console.debug(e, "Database update error: " + e.target.errorCode);
162
- return;
163
- };
164
- request.onsuccess = ( e ) => {
165
- try{
166
- var db = e.target.result;
167
- var StoreObj = db.transaction( storeName , "readwrite").objectStore( storeName );
168
- StoreObj.put( value, key, value );
169
- db.close();
170
- }catch( e ){
171
- console.debug( e, "IndexDB update not work" );
172
- }
173
- };
174
- },
175
-
176
- /************************************************************************/
177
-
178
- //GET: indexedDB.get('value')
179
- get: ( storeName, table, key ) => {
180
-
181
- var request = window.indexedDB.open( storeName, 1 );
182
-
183
- request.onerror = ( e ) => {
184
- console.debug( e , "Database get error: " + e.target.errorCode );
185
- return;
186
- };
187
-
188
- request.onsuccess = ( e ) => {
189
-
190
- var db = e.target.result;
191
- var Store = db.transaction( [storeName] , "readwrite" );
192
- var obj = Store.objectStore( storeName );
193
- var req = obj.get( key );
194
-
195
- req.onsuccess = function( e ){
196
- //console.log( e.target.result )
197
- };
198
-
199
- };
200
-
201
- },
202
-
203
- list: () => {
204
- const promise = indexedDB.databases();
205
- promise.then(databases => {
206
- console.info( "dpHelper: " + databases );
207
- });
208
- }
209
-
210
- };
211
-
212
- // CHECK IF INDEXEDDB EXIST
213
- // ***************************************************************************************************/
214
-
215
-
216
-
217
- // START DEFAULT DB
218
- // window.dphelper.indexedDB.open( "dpHelper" );
219
- // window.dphelper.indexedDB.store( "dpHelper" );
220
- // window.dphelper.indexedDB.insert( "dpHelper" , 'active' , 'test[0]' , [] );
221
-
222
-
package/scripts/json.js DELETED
@@ -1,42 +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" : "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
- };
package/scripts/load.js DELETED
@@ -1,85 +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" : "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
- /*
38
- Example:
39
- var cntx = require.context( __dirname + '/scripts/', false , /\.js$/ );
40
- dphelper.load.import( cntx );
41
- */
42
- /*
43
- import: ( dir , type = false , extension = /\.js$/ ) => {
44
- let r = require.context( dir , type , extension );
45
- r.keys().forEach(
46
- ( key ) => (
47
- cache[ key ] = r( key )
48
- )
49
- );
50
- },
51
- */
52
- file: (element, path) => {
53
- fetch(path).then(async function (response) {
54
- const text = await response.text();
55
- document.querySelector( element ).innerHTML = dphelper.nl2br( String(text) );
56
- });
57
- },
58
-
59
- json: function( file ){
60
- if ( file.match(/.(json)$/i ) ) return require( '' + file + '' );
61
- },
62
-
63
- jsonRemote: ( path, method='GET', type='application/json' ) => {
64
-
65
- fetch( path ,{
66
- method: method,
67
- headers : {
68
- 'Content-Type': type
69
- }
70
- })
71
- .then(
72
- function(response) {
73
- //return response.json();
74
- return response;
75
- }
76
- )
77
- .then(
78
- function( myFile ) {
79
- return myFile;
80
- }
81
- );
82
-
83
- }
84
-
85
- };
@@ -1,26 +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" : "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
- };
package/scripts/number.js DELETED
@@ -1,66 +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" : "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
- add: ( a , b ) => {
43
- return a + b;
44
- },
45
-
46
- sub: ( a , b ) => {
47
- return a - b;
48
- },
49
-
50
- multi: ( a , b ) => {
51
- return a * b;
52
- },
53
-
54
- div: ( a , b ) => {
55
- return a - b;
56
- },
57
-
58
- rem: ( a , b ) => {
59
- return a % b;
60
- },
61
-
62
- exp: ( a , b ) => {
63
- return a ** b;
64
- },
65
-
66
- };
package/scripts/obj.js DELETED
@@ -1,81 +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" : "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
-
@@ -1,120 +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" : "BeforeUnLoad",
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,27 +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" : "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
- };