dphelper 0.2.88 → 0.2.89
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.
- package/.editorconfig +13 -0
- package/.env +3 -0
- package/.eslintignore +13 -0
- package/.eslintrc.json +87 -0
- package/.eslintrc.legacy.json +91 -0
- package/.gitattributes +2 -0
- package/.hintrc +11 -0
- package/.jsbeautifyrc +25 -0
- package/.jshintrc +16 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +8 -0
- package/.stylelintignore +0 -0
- package/.stylelintrc.json +468 -0
- package/.vscode/launch.json +34 -0
- package/.vscode/settings.json +58 -0
- package/3party/shortcut.js +224 -0
- package/__mocks__/fileMock.js +3 -0
- package/__mocks__/styleMock.js +3 -0
- package/babel.config.js +30 -0
- package/backup.bat +43 -0
- package/coverage/coverage-final.json +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +101 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +0 -0
- package/data/list.json +19 -0
- package/dist/LICENSE.txt +209 -0
- package/dist/README.md +79 -0
- package/elements/button/component.js +0 -0
- package/elements/code/component.js +0 -0
- package/elements/costants.tsx +13 -0
- package/elements/fieldset/component.js +0 -0
- package/elements/input/checkbox/component.js +0 -0
- package/elements/input/date/component.js +27 -0
- package/elements/input/number/component.js +0 -0
- package/elements/input/radio/component.js +0 -0
- package/elements/input/search/component.js +0 -0
- package/elements/input/select/component.js +0 -0
- package/elements/input/slider/component.js +0 -0
- package/elements/input/switch/component.js +0 -0
- package/elements/tab/component.js +0 -0
- package/elements/table/component.js +0 -0
- package/elements/tags.less +0 -0
- package/elements/textarea/component.js +0 -0
- package/elements/x-foo/define.js +33 -0
- package/elements/x-foo/namespace.d.ts +7 -0
- package/index.js +12 -2
- package/init.js +87 -0
- package/jest.config.js +81 -0
- package/node/createTag.js +7 -0
- package/node/gitDeploy.js +7 -0
- package/node/goLive.js +7 -0
- package/package.json +7 -7
- package/{assets → public/assets}/images/banner.png +0 -0
- package/{assets → public/assets}/logos/logo.svg +0 -0
- package/{documents → public/documents}/iDB/list.html +0 -0
- package/{documents → public/documents}/iDB/toState.html +0 -0
- package/scripts/.OLD/import.js +48 -0
- package/scripts/.OLD/onBeforeUnLoad.js +120 -0
- package/scripts/.OLD/purge.js +53 -0
- package/scripts/.OLD/string.js +27 -0
- package/scripts/anchor.js +73 -0
- package/scripts/array.js +203 -0
- package/scripts/avoid.js +48 -0
- package/scripts/browser.js +100 -0
- package/scripts/color.js +121 -0
- package/scripts/console.js +97 -0
- package/scripts/console.mapped.js +160 -0
- package/scripts/coods.js +57 -0
- package/scripts/cookie.js +105 -0
- package/scripts/date.js +179 -0
- package/scripts/disable.js +91 -0
- package/scripts/errors.js +3 -0
- package/scripts/event.js +57 -0
- package/scripts/font.js +60 -0
- package/scripts/form.js +211 -0
- package/scripts/format.js +71 -0
- package/scripts/function.js +55 -0
- package/scripts/iDB.js +688 -0
- package/scripts/json.js +84 -0
- package/scripts/load.js +112 -0
- package/scripts/math.js +100 -0
- package/scripts/obj.js +118 -0
- package/scripts/path.js +101 -0
- package/scripts/promise.js +56 -0
- package/scripts/screen.js +82 -0
- package/scripts/scrollbar.js +293 -0
- package/scripts/shortcut.js +83 -0
- package/scripts/socket.js +184 -0
- package/scripts/state.js +87 -0
- package/scripts/storage.js +93 -0
- package/scripts/store.js +115 -0
- package/scripts/svg.js +380 -0
- package/scripts/text.js +116 -0
- package/scripts/time.js +43 -0
- package/scripts/timer.js +54 -0
- package/scripts/tool.js +73 -0
- package/scripts/trigger.js +57 -0
- package/scripts/type.js +76 -0
- package/scripts/ui.js +41 -0
- package/scripts/window.js +244 -0
- package/styles/console.less +95 -0
- package/tests/setupJest.tsx +4 -0
- package/typings/.OLD/cordova.d.ts +12 -0
- package/typings/.OLD/layerpro.d.ts +20 -0
- package/typings/.OLD/menupro.d.ts +20 -0
- package/typings/dphelper.d.ts +26 -0
- package/typings/image.d.ts +5 -0
- package/typings/styles.d.ts +23 -0
- package/webpack.config.js +249 -0
- package/index.js.LICENSE.txt +0 -31
package/scripts/json.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Json",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "json",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"counter",
|
|
18
|
+
"description" : "",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name":"toCsv",
|
|
22
|
+
"description" : "",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name":"saveCsvAs",
|
|
26
|
+
"description" : "",
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"example" : "",
|
|
30
|
+
"author" : "Dario Passariello",
|
|
31
|
+
"active" : true
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
dphelper._list.scripts.push( description );
|
|
35
|
+
|
|
36
|
+
/***********************************************************************/
|
|
37
|
+
|
|
38
|
+
dphelper.json = {
|
|
39
|
+
|
|
40
|
+
counter: (json, key, val) => {
|
|
41
|
+
if (!json) return null;
|
|
42
|
+
let keyCount;
|
|
43
|
+
if (key && val) {
|
|
44
|
+
keyCount = Object.keys(jsonObject).length;
|
|
45
|
+
} else {
|
|
46
|
+
keyCount = json.items.filter(value => value.key === val).lengt;
|
|
47
|
+
}
|
|
48
|
+
return keyCount;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
toCsv: (jsonInput) => {
|
|
52
|
+
const items = jsonInput;
|
|
53
|
+
const replacer = (key, value) => (value === null ? '' : value); // specify how you want to handle null values here
|
|
54
|
+
const header = Object.keys(items[0]);
|
|
55
|
+
let csv = items?.map(row => header?.map(fieldName => JSON.stringify(row[fieldName], replacer)).join(','));
|
|
56
|
+
csv.unshift(header.join(','));
|
|
57
|
+
csv = csv.join('\r\n');
|
|
58
|
+
// csv = csv.split("\"").join("");
|
|
59
|
+
return csv
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
saveCsvAs: (csvData, fileName) => {
|
|
63
|
+
const blob = new Blob( [csvData] , { type: 'text/csv;charset=utf-8;' })
|
|
64
|
+
const link = document.createElement('a')
|
|
65
|
+
let urlFile = ''
|
|
66
|
+
const d = dphelper.date.dateTimeToString( new Date( Date.now() ) )
|
|
67
|
+
const filename = `${fileName}_${ d }.csv`
|
|
68
|
+
urlFile = URL.createObjectURL(blob)
|
|
69
|
+
link.setAttribute('href', urlFile)
|
|
70
|
+
link.setAttribute('download', filename)
|
|
71
|
+
link.style.visibility = 'hidden'
|
|
72
|
+
document.body.appendChild(link)
|
|
73
|
+
link.click()
|
|
74
|
+
document.body.removeChild(link)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
Object.defineProperty( dphelper, 'json', {
|
|
80
|
+
writable: false,
|
|
81
|
+
configurable: false
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
package/scripts/load.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Load",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "load",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"file",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"json",
|
|
21
|
+
"description":"test"
|
|
22
|
+
},{
|
|
23
|
+
"name":"jsonRemote",
|
|
24
|
+
"description":"test"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"example" : "",
|
|
28
|
+
"author" : "Dario Passariello",
|
|
29
|
+
"active" : true
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
dphelper._list.scripts.push( description );
|
|
33
|
+
|
|
34
|
+
/***********************************************************************/
|
|
35
|
+
|
|
36
|
+
dphelper.load = {
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
Example:
|
|
40
|
+
var cntx = require.context( __dirname + '/scripts/', false , /\.js$/ );
|
|
41
|
+
dphelper.load.import( cntx );
|
|
42
|
+
*/
|
|
43
|
+
/*
|
|
44
|
+
import: ( dir , type = false , extension = /\.js$/ ) => {
|
|
45
|
+
let r = require.context( dir , type , extension );
|
|
46
|
+
r.keys().forEach(
|
|
47
|
+
( key ) => (
|
|
48
|
+
cache[ key ] = r( key )
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
file: (element, path) => {
|
|
55
|
+
fetch(path).then(async function (response) {
|
|
56
|
+
const text = await response.text();
|
|
57
|
+
//document.querySelector( element ).innerHTML = dphelper.text.nl2br( String(text) );
|
|
58
|
+
document.querySelector( element ).innerHTML = String(text);
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
json: function( file ){
|
|
63
|
+
if ( file.match(/.(json)$/i ) ) return require( '' + file + '' );
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
remote: ( path, method='GET', type='application/json' ) => {
|
|
67
|
+
|
|
68
|
+
fetch( path ,{
|
|
69
|
+
method: method,
|
|
70
|
+
headers : {
|
|
71
|
+
'Content-Type': type
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
.then(
|
|
75
|
+
function(response) {
|
|
76
|
+
//return response.json();
|
|
77
|
+
return response;
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
.then(
|
|
81
|
+
function( myFile ) {
|
|
82
|
+
return myFile;
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
//TODO: API functions (more to be added) should be in their own file!
|
|
89
|
+
axios: ( url, name ) => {
|
|
90
|
+
|
|
91
|
+
if( !url || !name ) return;
|
|
92
|
+
|
|
93
|
+
axios
|
|
94
|
+
.get( url )
|
|
95
|
+
.then( response => {
|
|
96
|
+
dphelper.state.api[ name ] = response;
|
|
97
|
+
console.log( response );
|
|
98
|
+
})
|
|
99
|
+
.catch(function (error) {
|
|
100
|
+
console.debug(error);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
Object.defineProperty( dphelper, 'load', {
|
|
108
|
+
writable: false,
|
|
109
|
+
configurable: false
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
package/scripts/math.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Math",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "math",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"rnd",
|
|
18
|
+
"description":"test",
|
|
19
|
+
},{
|
|
20
|
+
"name":"tmr",
|
|
21
|
+
"description":"test",
|
|
22
|
+
},{
|
|
23
|
+
"name":"add",
|
|
24
|
+
"description":"test",
|
|
25
|
+
},{
|
|
26
|
+
"name":"sub",
|
|
27
|
+
"description":"test",
|
|
28
|
+
},{
|
|
29
|
+
"name":"multi",
|
|
30
|
+
"description":"test",
|
|
31
|
+
},{
|
|
32
|
+
"name":"div",
|
|
33
|
+
"description":"test",
|
|
34
|
+
},{
|
|
35
|
+
"name":"rem",
|
|
36
|
+
"description":"test",
|
|
37
|
+
},{
|
|
38
|
+
"name":"exp",
|
|
39
|
+
"description":"test",
|
|
40
|
+
},{
|
|
41
|
+
"name":"isOdd",
|
|
42
|
+
"description":"check if math is odd or even",
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"example" : "",
|
|
46
|
+
"author" : "Dario Passariello",
|
|
47
|
+
"active" : true
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
dphelper._list.scripts.push( description );
|
|
51
|
+
|
|
52
|
+
/***********************************************************************/
|
|
53
|
+
|
|
54
|
+
dphelper.math = {
|
|
55
|
+
|
|
56
|
+
rnd: () => {
|
|
57
|
+
return Math.floor( 100000 + Math.random() * dphelper.math.tmr() );
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
tmr: () => {
|
|
61
|
+
return Math.round( dphelper.time.epoch() / 1000 );
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
add: ( a , b ) => {
|
|
65
|
+
return a + b;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
sub: ( a , b ) => {
|
|
69
|
+
return a - b;
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
multi: ( a , b ) => {
|
|
73
|
+
return a * b;
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
div: ( a , b ) => {
|
|
77
|
+
return a - b;
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
rem: ( a , b ) => {
|
|
81
|
+
return a % b;
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
exp: ( a , b ) => {
|
|
85
|
+
return a ** b;
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
isOdd: ( num ) => {
|
|
89
|
+
var result = num % 2 == 0 ? true : false;
|
|
90
|
+
return result;
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
Object.defineProperty( dphelper, 'math', {
|
|
96
|
+
writable: false,
|
|
97
|
+
configurable: false
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
package/scripts/obj.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Obj",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "obj",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"toArray",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"replaceNullObjects",
|
|
21
|
+
"description":"test"
|
|
22
|
+
},{
|
|
23
|
+
"name":"serialize",
|
|
24
|
+
"description":"test"
|
|
25
|
+
},{
|
|
26
|
+
"name":"deSerialize",
|
|
27
|
+
"description":"test"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"example" : "",
|
|
31
|
+
"author" : "Dario Passariello",
|
|
32
|
+
"active" : true
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
dphelper._list.scripts.push( description );
|
|
36
|
+
|
|
37
|
+
/***********************************************************************/
|
|
38
|
+
|
|
39
|
+
dphelper.obj = {
|
|
40
|
+
|
|
41
|
+
toArray: ( object ) => {
|
|
42
|
+
return Object.entries( object );
|
|
43
|
+
// .map(
|
|
44
|
+
// ([ key, value ]) => {
|
|
45
|
+
// //console.log( ">" , [ key, value ] );
|
|
46
|
+
// Object.assign(
|
|
47
|
+
// { key } ,
|
|
48
|
+
// value && typeof value === 'object' ? {
|
|
49
|
+
// array: dphelper.obj.toArray( value )
|
|
50
|
+
// } : {
|
|
51
|
+
// value, array: []
|
|
52
|
+
// }
|
|
53
|
+
// );
|
|
54
|
+
// }
|
|
55
|
+
// );
|
|
56
|
+
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
replaceNullObjects: (data) => {
|
|
60
|
+
const loData = data
|
|
61
|
+
Object.keys(data).forEach((key) => {
|
|
62
|
+
if (data[key] === null) {
|
|
63
|
+
loData[key] = ''
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
return loData
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
serialize: ( value ) => {
|
|
70
|
+
|
|
71
|
+
if (typeof value === 'function') {
|
|
72
|
+
return value.toString();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (typeof value === 'object') {
|
|
76
|
+
let serializeObject = {};
|
|
77
|
+
for (const [objectKey, objectValue] of Object.entries(value)) {
|
|
78
|
+
console.info( `objectKey=${objectKey} value=${objectValue}` );
|
|
79
|
+
serializeObject[objectKey] = dphelper.obj.serialize(objectValue);
|
|
80
|
+
}
|
|
81
|
+
return serializeObject;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return value;
|
|
85
|
+
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
deSerialize: ( valueNew ) => {
|
|
89
|
+
|
|
90
|
+
if (valueNew.toLowerCase().startsWith( 'function(' ) ) {
|
|
91
|
+
return Function('"use strict"; return ' + valueNew);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (typeof valueNew === 'object') {
|
|
95
|
+
let deserializeObject = {};
|
|
96
|
+
for (const [objectKey, objectValue] of Object.entries(valueNew)) {
|
|
97
|
+
console.info( `objectKey=${objectKey} value=${objectValue}` );
|
|
98
|
+
deserializeObject[objectKey] = dphelper.obj.deSerialize(objectValue);
|
|
99
|
+
}
|
|
100
|
+
return deserializeObject;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return value;
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
sort: ( o )=>{
|
|
107
|
+
return Object.keys(o).sort().reduce((r, k) => (r[k] = o[k], r), {});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
Object.defineProperty( dphelper, 'obj', {
|
|
113
|
+
writable: false,
|
|
114
|
+
configurable: false
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
118
|
+
|
package/scripts/path.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Path",
|
|
12
|
+
"description" : "url path: rail, hash or query to array",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "path",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"rail",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"hash",
|
|
21
|
+
"description":"test"
|
|
22
|
+
},{
|
|
23
|
+
"name":"query",
|
|
24
|
+
"description":"test"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"example" : "",
|
|
28
|
+
"author" : "Dario Passariello",
|
|
29
|
+
"active" : true
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
dphelper._list.scripts.push( description );
|
|
33
|
+
|
|
34
|
+
/***********************************************************************/
|
|
35
|
+
|
|
36
|
+
// // ALIAS
|
|
37
|
+
// dphelper.pathHash = () => {
|
|
38
|
+
// console.debug( 'dpHelper: Please use "dphelper.path.hash()"' );
|
|
39
|
+
// return dphelper.path.hash();
|
|
40
|
+
// };
|
|
41
|
+
|
|
42
|
+
// dphelper.pathQuery = () => {
|
|
43
|
+
// console.debug( 'dpHelper: Please use "dphelper.path.query()"' );
|
|
44
|
+
// return dphelper.path.query();
|
|
45
|
+
// };
|
|
46
|
+
|
|
47
|
+
// dphelper.pathRail = () => {
|
|
48
|
+
// console.debug( 'dpHelper: Please use "dphelper.path.rail()"' );
|
|
49
|
+
// return dphelper.path.rail();
|
|
50
|
+
// };
|
|
51
|
+
|
|
52
|
+
/***********************************************************************/
|
|
53
|
+
|
|
54
|
+
dphelper.path = {
|
|
55
|
+
|
|
56
|
+
rail: () => {
|
|
57
|
+
const array = location.href
|
|
58
|
+
.split("?")[0]
|
|
59
|
+
.replace(location.protocol, '')
|
|
60
|
+
.replace(location.host, '')
|
|
61
|
+
.replace(location.hash, '')
|
|
62
|
+
.split('/');
|
|
63
|
+
if ( array.length > 0 ) {
|
|
64
|
+
const arrayFinal = array.filter(item => item);
|
|
65
|
+
return arrayFinal;
|
|
66
|
+
} else {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
hash: () => {
|
|
72
|
+
const array = location.hash.replace('#', '').split('/');
|
|
73
|
+
if (array.length) {
|
|
74
|
+
return array.filter(item => item);
|
|
75
|
+
} else {
|
|
76
|
+
return ["empty"];
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
query: () => {
|
|
81
|
+
let x, y, array = [], search = location.search;
|
|
82
|
+
if (search) {
|
|
83
|
+
search.replace("?", '').split('&')
|
|
84
|
+
.map(x => {
|
|
85
|
+
y = x.split('=');
|
|
86
|
+
array[y[0]] = y[1];
|
|
87
|
+
});
|
|
88
|
+
return array;
|
|
89
|
+
} else {
|
|
90
|
+
return ["empty"];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
Object.defineProperty( dphelper, 'path', {
|
|
97
|
+
writable: false,
|
|
98
|
+
configurable: false
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Promise",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "promise",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"check",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"resolve",
|
|
21
|
+
"description":"test"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"example" : "",
|
|
25
|
+
"author" : "Dario Passariello",
|
|
26
|
+
"active" : true
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
dphelper._list.scripts.push( description );
|
|
30
|
+
|
|
31
|
+
/***********************************************************************/
|
|
32
|
+
|
|
33
|
+
dphelper.promise = {
|
|
34
|
+
|
|
35
|
+
check: (p) => {
|
|
36
|
+
return p && Object.prototype.toString.call(p) === "[object Promise]";
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
resolve: async ( data ) => {
|
|
40
|
+
var p = {};
|
|
41
|
+
if( dphelper.promise.check( data ) ){
|
|
42
|
+
Promise.resolve( data ).then( function( value ) {
|
|
43
|
+
p.promise = value;
|
|
44
|
+
});
|
|
45
|
+
return await p;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
Object.defineProperty( dphelper, 'promise', {
|
|
52
|
+
writable: false,
|
|
53
|
+
configurable: false
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Screen",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "screen",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"fullScreen",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"toggle",
|
|
21
|
+
"description":"test"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"example" : "",
|
|
25
|
+
"author" : "Dario Passariello",
|
|
26
|
+
"active" : true
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
dphelper._list.scripts.push( description );
|
|
30
|
+
|
|
31
|
+
/***********************************************************************/
|
|
32
|
+
|
|
33
|
+
dphelper.screen = {
|
|
34
|
+
|
|
35
|
+
fullScreen: function( el ){
|
|
36
|
+
|
|
37
|
+
if ( el.requestFullScreen ) {
|
|
38
|
+
el.requestFullScreen();
|
|
39
|
+
} else if ( el.mozRequestFullScreen ) {
|
|
40
|
+
el.mozRequestFullScreen();
|
|
41
|
+
} else if ( el.webkitRequestFullScreen ) {
|
|
42
|
+
el.webkitRequestFullScreen();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
toggle: function( el ) {
|
|
48
|
+
|
|
49
|
+
let requestFullScreen = el.requestFullscreen || el.mozRequestFullScreen || el.webkitRequestFullScreen || el.msRequestFullscreen;
|
|
50
|
+
let cancelFullScreen = el.exitFullscreen || el.mozCancelFullScreen || el.webkitExitFullscreen || el.msExitFullscreen;
|
|
51
|
+
|
|
52
|
+
if( !doc.fullscreenElement && !el.mozFullScreenElement && !el.webkitFullscreenElement && !el.msFullscreenElement ) {
|
|
53
|
+
requestFullScreen.call( el );
|
|
54
|
+
}else{
|
|
55
|
+
cancelFullScreen.call( el );
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
info:() => {
|
|
61
|
+
var final = [
|
|
62
|
+
screen.width,
|
|
63
|
+
screen.height,
|
|
64
|
+
screen.availWidth,
|
|
65
|
+
screen.availHeight,
|
|
66
|
+
screen.colorDepth,
|
|
67
|
+
screen.pixelDepth
|
|
68
|
+
];
|
|
69
|
+
return final;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// dphelper.fullScreen.go( document.body )
|
|
75
|
+
// dphelper.fullScreen.toggle( document.body )
|
|
76
|
+
|
|
77
|
+
Object.defineProperty( dphelper, 'screen', {
|
|
78
|
+
writable: false,
|
|
79
|
+
configurable: false
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|