dphelper 0.2.86 → 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/CHANGELOG.txt +4 -0
- package/SECURITY.md +3 -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 +27 -20
- 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/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/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
|
@@ -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" : "Browser",
|
|
12
|
+
"version" : "0.0.1",
|
|
13
|
+
"command" : "browser",
|
|
14
|
+
"author" : "Dario Passariello",
|
|
15
|
+
"active" : true,
|
|
16
|
+
"example" : "",
|
|
17
|
+
"type" : "object",
|
|
18
|
+
"description":"test",
|
|
19
|
+
"subCommand" : [
|
|
20
|
+
{
|
|
21
|
+
"name":"state",
|
|
22
|
+
"version" : "0.0.1",
|
|
23
|
+
"example" : "",
|
|
24
|
+
"type" : "function",
|
|
25
|
+
"active": true,
|
|
26
|
+
"description":"test",
|
|
27
|
+
"subCommand" : []
|
|
28
|
+
},{
|
|
29
|
+
"name":"forw",
|
|
30
|
+
"version" : "0.0.1",
|
|
31
|
+
"example" : "",
|
|
32
|
+
"type" : "function",
|
|
33
|
+
"active": true,
|
|
34
|
+
"description":"test",
|
|
35
|
+
"subCommand" : []
|
|
36
|
+
},{
|
|
37
|
+
"name":"back",
|
|
38
|
+
"version" : "0.0.1",
|
|
39
|
+
"example" : "",
|
|
40
|
+
"type" : "function",
|
|
41
|
+
"active": true,
|
|
42
|
+
"description":"test",
|
|
43
|
+
"subCommand" : []
|
|
44
|
+
},{
|
|
45
|
+
"name":"reload",
|
|
46
|
+
"version" : "0.0.1",
|
|
47
|
+
"example" : "",
|
|
48
|
+
"type" : "function",
|
|
49
|
+
"active": true,
|
|
50
|
+
"description":"test",
|
|
51
|
+
"subCommand" : []
|
|
52
|
+
},{
|
|
53
|
+
"name":"href",
|
|
54
|
+
"version" : "0.0.1",
|
|
55
|
+
"example" : "",
|
|
56
|
+
"type" : "function",
|
|
57
|
+
"active": true,
|
|
58
|
+
"description":"test",
|
|
59
|
+
"subCommand" : []
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
dphelper._list.scripts.push( description );
|
|
66
|
+
|
|
67
|
+
/***********************************************************************/
|
|
68
|
+
|
|
69
|
+
dphelper.browser = {
|
|
70
|
+
|
|
71
|
+
state: (state, title, url) => {
|
|
72
|
+
return history.pushState( state, title, url );
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
forw: ( times ) => {
|
|
76
|
+
return history.go( times );
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
back: ( times ) => {
|
|
80
|
+
return history.go( -Math.abs( times ) );
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
reload: () => {
|
|
84
|
+
// DISCARD POST
|
|
85
|
+
return window.location.href = window.location.href;
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
href: ( url ) => {
|
|
89
|
+
// DISCARD POST
|
|
90
|
+
return window.location.href = url;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
Object.defineProperty( dphelper, 'browser', {
|
|
96
|
+
writable: false,
|
|
97
|
+
configurable: false
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
package/scripts/color.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
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" : "Color",
|
|
12
|
+
"version" : "0.0.1",
|
|
13
|
+
"command" : "color",
|
|
14
|
+
"author" : "Dario Passariello",
|
|
15
|
+
"active" : true,
|
|
16
|
+
"example" : "",
|
|
17
|
+
"type" : "object",
|
|
18
|
+
"description":"test",
|
|
19
|
+
"subCommand" : [
|
|
20
|
+
{
|
|
21
|
+
"name":"hex",
|
|
22
|
+
"version" : "0.0.1",
|
|
23
|
+
"example" : "",
|
|
24
|
+
"type" : "function",
|
|
25
|
+
"active": true,
|
|
26
|
+
"description":"test",
|
|
27
|
+
"subCommand" : []
|
|
28
|
+
},{
|
|
29
|
+
"name":"toHex",
|
|
30
|
+
"version" : "0.0.1",
|
|
31
|
+
"example" : "",
|
|
32
|
+
"type" : "function",
|
|
33
|
+
"active": true,
|
|
34
|
+
"description":"test",
|
|
35
|
+
"subCommand" : []
|
|
36
|
+
},{
|
|
37
|
+
"name":"toRGB",
|
|
38
|
+
"version" : "0.0.1",
|
|
39
|
+
"example" : "",
|
|
40
|
+
"type" : "function",
|
|
41
|
+
"active": true,
|
|
42
|
+
"description":"test",
|
|
43
|
+
"subCommand" : []
|
|
44
|
+
},{
|
|
45
|
+
"name":"gradient",
|
|
46
|
+
"version" : "0.0.1",
|
|
47
|
+
"example" : "",
|
|
48
|
+
"type" : "function",
|
|
49
|
+
"active": true,
|
|
50
|
+
"description":"test",
|
|
51
|
+
"subCommand" : []
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
dphelper._list.scripts.push( description );
|
|
58
|
+
|
|
59
|
+
/***********************************************************************/
|
|
60
|
+
|
|
61
|
+
dphelper.color = {
|
|
62
|
+
|
|
63
|
+
hex: (c) => {
|
|
64
|
+
var s = "0123456789abcdef";
|
|
65
|
+
var i = parseInt (c);
|
|
66
|
+
|
|
67
|
+
if (i == 0 || isNaN (c)) return "00";
|
|
68
|
+
|
|
69
|
+
i = Math.round (Math.min (Math.max (0, i), 255));
|
|
70
|
+
return s.charAt ((i - i % 16) / 16) + s.charAt (i % 16);
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
/* Convert an RGB triplet to a hex string */
|
|
74
|
+
toHex: (rgb) => {
|
|
75
|
+
return dphelper.color.hex(rgb[0]) +
|
|
76
|
+
dphelper.color.hex(rgb[1]) +
|
|
77
|
+
dphelper.color.hex(rgb[2]);
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/* Convert a hex string to an RGB triplet */
|
|
81
|
+
toRGB: (hex) => {
|
|
82
|
+
var color = [];
|
|
83
|
+
color[0] = parseInt (( dphelper.text.trim( hex, '#', 1, 7 ) ).substring (0, 2), 16);
|
|
84
|
+
color[1] = parseInt (( dphelper.text.trim( hex, '#', 1, 7 ) ).substring (2, 4), 16);
|
|
85
|
+
color[2] = parseInt (( dphelper.text.trim( hex, '#', 1, 7 ) ).substring (4, 6), 16);
|
|
86
|
+
return color;
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
gradient: ( colorStart, colorEnd, colorCount ) => {
|
|
90
|
+
|
|
91
|
+
var start = dphelper.color.toRGB (colorStart);
|
|
92
|
+
var end = dphelper.color.toRGB (colorEnd);
|
|
93
|
+
var len = colorCount;
|
|
94
|
+
var alpha = 0.0;
|
|
95
|
+
var colors = [];
|
|
96
|
+
|
|
97
|
+
for (var i = 0; i < len; i++) {
|
|
98
|
+
|
|
99
|
+
var c = [];
|
|
100
|
+
alpha += (1.0/len);
|
|
101
|
+
|
|
102
|
+
c[0] = start[0] * alpha + (1 - alpha) * end[0];
|
|
103
|
+
c[1] = start[1] * alpha + (1 - alpha) * end[1];
|
|
104
|
+
c[2] = start[2] * alpha + (1 - alpha) * end[2];
|
|
105
|
+
|
|
106
|
+
colors.push( dphelper.color.toHex (c) );
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return colors;
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
Object.defineProperty( dphelper, 'color', {
|
|
117
|
+
writable: false,
|
|
118
|
+
configurable: false
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
@@ -0,0 +1,97 @@
|
|
|
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" : "Console",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "console",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"info",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"stop",
|
|
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.printInfo = () => {
|
|
34
|
+
// console.debug( 'dpHelper: Please use "dphelper.path.rail()"' );
|
|
35
|
+
// return dphelper.console.info();
|
|
36
|
+
// };
|
|
37
|
+
|
|
38
|
+
/***********************************************************************/
|
|
39
|
+
|
|
40
|
+
dphelper.console = {
|
|
41
|
+
|
|
42
|
+
info: ( name, message, func ) => {
|
|
43
|
+
console.groupCollapsed('%c'+ name +':%c', "color:orange", "");
|
|
44
|
+
console.debug( message, dphelper[ func ] );
|
|
45
|
+
console.groupEnd();
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
stop: ( options = [
|
|
49
|
+
'assert',
|
|
50
|
+
'clear',
|
|
51
|
+
'count',
|
|
52
|
+
'debug',
|
|
53
|
+
'dir',
|
|
54
|
+
'dirxml',
|
|
55
|
+
'error',
|
|
56
|
+
'exception',
|
|
57
|
+
'group',
|
|
58
|
+
'groupCollapsed',
|
|
59
|
+
'groupEnd',
|
|
60
|
+
'info',
|
|
61
|
+
'log',
|
|
62
|
+
'markTimeline',
|
|
63
|
+
'profile',
|
|
64
|
+
'profileEnd',
|
|
65
|
+
'table',
|
|
66
|
+
'time',
|
|
67
|
+
'timeEnd',
|
|
68
|
+
'timeline',
|
|
69
|
+
'timelineEnd',
|
|
70
|
+
'timeStamp',
|
|
71
|
+
'trace',
|
|
72
|
+
'warn',
|
|
73
|
+
'verbose'
|
|
74
|
+
]) => {
|
|
75
|
+
|
|
76
|
+
console.clear();
|
|
77
|
+
console.disableYellowBox = true;
|
|
78
|
+
console = {};
|
|
79
|
+
console.log = function(){};
|
|
80
|
+
window.console = console;
|
|
81
|
+
if(!window.console) window.console = {};
|
|
82
|
+
const noop = () => {};
|
|
83
|
+
|
|
84
|
+
options.forEach( ( method ) => {
|
|
85
|
+
window.console[ method ] = noop;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
Object.defineProperty( dphelper, 'console', {
|
|
93
|
+
writable: false,
|
|
94
|
+
configurable: false
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
@@ -0,0 +1,160 @@
|
|
|
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
|
+
dphelper.console.debug = function( parentDom ){
|
|
11
|
+
|
|
12
|
+
//parent must be content
|
|
13
|
+
if( !parentDom ) throw Error( "Parent dom element required!" );
|
|
14
|
+
|
|
15
|
+
//Private fields
|
|
16
|
+
var _keysMapped = false;
|
|
17
|
+
var _oldLog = console.log;
|
|
18
|
+
var _oldInfo = console.info;
|
|
19
|
+
var _oldWarn = console.warn;
|
|
20
|
+
var _oldErr = console.error;
|
|
21
|
+
|
|
22
|
+
var _appendToDomElement = function( type ){
|
|
23
|
+
var args = Array.prototype.slice.call( arguments[ 1 ] ).join( " " );
|
|
24
|
+
if( type === TYPE.WARN ) args = "<font color=\"#FF6600\">* WARN: " + args;
|
|
25
|
+
else if( type === TYPE.ERR ) args = "<font color=\"#FF0000\">* ERR: " + args;
|
|
26
|
+
else args = "* " + args;
|
|
27
|
+
|
|
28
|
+
this.domElement.innerHTML += args + "<br/>";
|
|
29
|
+
if( this.autoScroll && this.visible ) this.domElement.scrollTop = this.domElement.scrollHeight;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var TYPE = {
|
|
33
|
+
LOG: 0,
|
|
34
|
+
INFO: 1,
|
|
35
|
+
WARN: 2,
|
|
36
|
+
ERR: 3
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
this.autoScroll = true;
|
|
40
|
+
|
|
41
|
+
//Disable all logging features, both this console and globally.
|
|
42
|
+
this.disableConsoleLogging = false;
|
|
43
|
+
|
|
44
|
+
//Create the element
|
|
45
|
+
var domElement = document.createElement( 'div' );
|
|
46
|
+
domElement.id = 'debugConsole';
|
|
47
|
+
|
|
48
|
+
parentDom.appendChild( domElement );
|
|
49
|
+
this.domElement = domElement;
|
|
50
|
+
|
|
51
|
+
this.initKeyMappings = function(){
|
|
52
|
+
|
|
53
|
+
if( _keysMapped ){
|
|
54
|
+
console.warn( 'DebugConsole: keys already mapped!' );
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
dphelper.state( "toggle_console", ( function(){ this.visible = !this.visible; } ).bind( this ) );
|
|
59
|
+
_keysMapped = true;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// overrideConsole the standard console, by monkey-patching it.
|
|
63
|
+
this.overrideConsole = function(){
|
|
64
|
+
//console.log('123');
|
|
65
|
+
|
|
66
|
+
console.log = ( function(){
|
|
67
|
+
if( this.disableConsoleLogging ) return;
|
|
68
|
+
|
|
69
|
+
_appendToDomElement.call( this, TYPE.LOG, arguments );
|
|
70
|
+
_oldLog.apply( console, arguments );
|
|
71
|
+
} ).bind( this );
|
|
72
|
+
|
|
73
|
+
console.info = ( function(){
|
|
74
|
+
if( dphelper.state.disableConsoleLogging ) return;
|
|
75
|
+
|
|
76
|
+
_appendToDomElement.call( this, TYPE.INFO, arguments );
|
|
77
|
+
_oldInfo.apply( console, arguments );
|
|
78
|
+
} ).bind( this );
|
|
79
|
+
|
|
80
|
+
console.warn = ( function(){
|
|
81
|
+
if( dphelper.state.disableConsoleLogging ) return;
|
|
82
|
+
|
|
83
|
+
_appendToDomElement.call( this, TYPE.WARN, arguments );
|
|
84
|
+
_oldWarn.apply( console, arguments );
|
|
85
|
+
} ).bind( this );
|
|
86
|
+
|
|
87
|
+
console.error = ( function(){
|
|
88
|
+
if( dphelper.state.disableConsoleLogging ) return;
|
|
89
|
+
|
|
90
|
+
_appendToDomElement.call( this, TYPE.ERR, arguments );
|
|
91
|
+
_oldErr.apply( console, arguments );
|
|
92
|
+
} ).bind( this );
|
|
93
|
+
|
|
94
|
+
//onError handler
|
|
95
|
+
window.onerror = function( errorMsg, url, lineNumber ){
|
|
96
|
+
var msg = [
|
|
97
|
+
errorMsg,
|
|
98
|
+
" in <a href='",
|
|
99
|
+
url,
|
|
100
|
+
"' target='_blank'>",
|
|
101
|
+
url.split( '/' ).pop(),
|
|
102
|
+
"</a>:",
|
|
103
|
+
lineNumber
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
console.error( msg.join( '' ) );
|
|
107
|
+
return false;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
this.overrideConsole();
|
|
112
|
+
|
|
113
|
+
// Clear the log history
|
|
114
|
+
this.clear = function(){
|
|
115
|
+
this.domElement.innerHTML = '';
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Public properties
|
|
119
|
+
Object.defineProperties(
|
|
120
|
+
this, {
|
|
121
|
+
"visible": {
|
|
122
|
+
"get": function() { return this.domElement.style.display === ''; },
|
|
123
|
+
"set": function( value )
|
|
124
|
+
{
|
|
125
|
+
if( value ){
|
|
126
|
+
this.domElement.style.display = '';
|
|
127
|
+
if( this.autoScroll ) this.domElement.scrollTop = this.domElement.scrollHeight;
|
|
128
|
+
} else this.domElement.style.display = 'none';
|
|
129
|
+
},
|
|
130
|
+
configurable: true
|
|
131
|
+
},
|
|
132
|
+
// "top": {
|
|
133
|
+
// "get": function() { return this.domElement.style.top; },
|
|
134
|
+
// "set": function( value ) { this.domElement.style.top = value; }
|
|
135
|
+
// },
|
|
136
|
+
// "left": {
|
|
137
|
+
// "get": function() { return this.domElement.style.left; },
|
|
138
|
+
// "set": function( value ) { this.domElement.style.left = value; }
|
|
139
|
+
// },
|
|
140
|
+
// "bottom": {
|
|
141
|
+
// "get": function() { return this.domElement.style.bottom; },
|
|
142
|
+
// "set": function( value ) { this.domElement.style.bottom = value; }
|
|
143
|
+
// },
|
|
144
|
+
// "right": {
|
|
145
|
+
// "get": function() { return this.domElement.style.right; },
|
|
146
|
+
// "set": function( value ) { this.domElement.style.right = value; }
|
|
147
|
+
// },
|
|
148
|
+
// "width": {
|
|
149
|
+
// "get": function() { return this.domElement.style.width; },
|
|
150
|
+
// "set": function( value ) { this.domElement.style.width = value; }
|
|
151
|
+
// },
|
|
152
|
+
// "height": {
|
|
153
|
+
// "get": function() { return this.domElement.style.height; },
|
|
154
|
+
// "set": function( value ) { this.domElement.style.height = value; }
|
|
155
|
+
// }
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
};
|
package/scripts/coods.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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" : "Coords",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "coords",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"degreesToRadians",
|
|
18
|
+
"description":"test",
|
|
19
|
+
},{
|
|
20
|
+
"name":"latToMeters",
|
|
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
|
+
|
|
34
|
+
let R = 6378.1;
|
|
35
|
+
dphelper.coords = {
|
|
36
|
+
|
|
37
|
+
degreesToRadians: ( degrees ) => {
|
|
38
|
+
var pi = Math.PI;
|
|
39
|
+
return degrees * (pi/180);
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
latToMeters: ( latitude , longitude ) => {
|
|
43
|
+
return R * Math.cos(latitude) * Math.cos(longitude);
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
lngToMeters: ( latitude , longitude ) => {
|
|
47
|
+
return R * Math.cos(latitude) * Math.sin(longitude);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
Object.defineProperty( dphelper, 'coords', {
|
|
53
|
+
writable: false,
|
|
54
|
+
configurable: false
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
@@ -0,0 +1,105 @@
|
|
|
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" : "Cookie",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "cookie",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"set",
|
|
18
|
+
"description":"test"
|
|
19
|
+
},{
|
|
20
|
+
"name":"get",
|
|
21
|
+
"description":"test"
|
|
22
|
+
},{
|
|
23
|
+
"name":"delete",
|
|
24
|
+
"description":"test"
|
|
25
|
+
},{
|
|
26
|
+
"name":"clearAll",
|
|
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
|
+
var CookieType = "Lax";
|
|
40
|
+
var CookieSecure = "false";
|
|
41
|
+
var CookieSameSite = "false";
|
|
42
|
+
|
|
43
|
+
if (location.protocol === 'https:') {
|
|
44
|
+
CookieSecure = "Secure";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
dphelper.cookie = {
|
|
48
|
+
|
|
49
|
+
// CREATE THE COOKIE
|
|
50
|
+
|
|
51
|
+
set: ( cname , value , time , path = '/' ) => {
|
|
52
|
+
var d = new Date();
|
|
53
|
+
d.setTime( d.getTime() + 3600 * 1000 * 24 * 365 );
|
|
54
|
+
|
|
55
|
+
if( !time ) time = d.toGMTString();
|
|
56
|
+
if( cname ){
|
|
57
|
+
document.cookie = cname + '=' + value + ';expires=' + time + ';path=' + path + ';SameSite=' + CookieSameSite + ';requireSSL='+ CookieSecure +';' + CookieSecure;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
// GET THE COOKIE
|
|
62
|
+
|
|
63
|
+
get: ( cname ) => {
|
|
64
|
+
var asCookies = document.cookie.split( "; " );
|
|
65
|
+
|
|
66
|
+
for ( var i = 0; i < asCookies.length; i++ ){
|
|
67
|
+
var asCookie = asCookies[ i ].split( "=" );
|
|
68
|
+
if ( cname === asCookie[0] ) return ( unescape( asCookie[1] ) );
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return null;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// DELETE THE COOKIE
|
|
75
|
+
|
|
76
|
+
delete: ( cname ) => {
|
|
77
|
+
document.cookie = cname + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;SameSite=' + CookieSameSite + ';requireSSL='+ CookieSecure +';' + CookieSecure;
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
// CLEAR ALL COOKIE
|
|
81
|
+
|
|
82
|
+
clearAll: () => {
|
|
83
|
+
var cookies = document.cookie.split(";");
|
|
84
|
+
|
|
85
|
+
for ( var i = 0; i < cookies.length; i++ ) {
|
|
86
|
+
|
|
87
|
+
var cookie = cookies[i];
|
|
88
|
+
var eqPos = cookie.indexOf("=");
|
|
89
|
+
var cname = eqPos > -1 ? cookie.slice( 0 , eqPos ) : cookie;
|
|
90
|
+
stpro.cookie.delete( cname );
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// START COOKIE DB
|
|
98
|
+
// dphelper.cookie.set( "dpHelper", 'active' );
|
|
99
|
+
|
|
100
|
+
Object.defineProperty( dphelper, 'cookie', {
|
|
101
|
+
writable: false,
|
|
102
|
+
configurable: false
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|