underpost 2.7.1 → 2.7.3
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/.dockerignore +13 -13
- package/.env.development +7 -7
- package/.env.production +7 -7
- package/.env.test +7 -7
- package/.github/workflows/publish.yml +26 -0
- package/.github/workflows/test.yml +80 -0
- package/.nycrc +9 -9
- package/.prettierignore +12 -12
- package/.prettierrc +9 -9
- package/.vscode/extensions.json +72 -72
- package/.vscode/settings.json +100 -99
- package/Dockerfile +89 -89
- package/LICENSE +21 -21
- package/README.md +96 -96
- package/bin/db.js +172 -119
- package/bin/deploy.js +607 -661
- package/bin/file.js +93 -92
- package/bin/index.js +76 -53
- package/bin/ssl.js +55 -64
- package/bin/util.js +182 -182
- package/bin/vs.js +35 -35
- package/conf.js +251 -249
- package/docker-compose.yml +67 -67
- package/jsconfig.json +7 -7
- package/jsdoc.json +32 -32
- package/nodemon.json +6 -6
- package/package.json +137 -132
- package/prometheus.yml +36 -36
- package/setup.sh +24 -24
- package/src/api/core/core.controller.js +69 -69
- package/src/api/core/core.model.js +11 -11
- package/src/api/core/core.router.js +23 -23
- package/src/api/core/core.service.js +29 -29
- package/src/api/crypto/crypto.controller.js +51 -51
- package/src/api/crypto/crypto.model.js +23 -23
- package/src/api/crypto/crypto.router.js +20 -20
- package/src/api/crypto/crypto.service.js +64 -64
- package/src/api/default/default.controller.js +69 -69
- package/src/api/default/default.model.js +20 -20
- package/src/api/default/default.router.js +23 -23
- package/src/api/default/default.service.js +31 -31
- package/src/api/file/file.controller.js +53 -51
- package/src/api/file/file.model.js +19 -19
- package/src/api/file/file.router.js +21 -20
- package/src/api/file/file.service.js +76 -70
- package/src/api/instance/instance.controller.js +69 -69
- package/src/api/instance/instance.model.js +36 -36
- package/src/api/instance/instance.router.js +33 -33
- package/src/api/instance/instance.service.js +48 -48
- package/src/api/test/test.controller.js +59 -59
- package/src/api/test/test.model.js +14 -14
- package/src/api/test/test.router.js +21 -21
- package/src/api/test/test.service.js +35 -35
- package/src/api/user/user.build.js +16 -0
- package/src/api/user/user.controller.js +70 -70
- package/src/api/user/user.model.js +65 -65
- package/src/api/user/user.router.js +345 -345
- package/src/api/user/user.service.js +479 -479
- package/src/api.js +23 -23
- package/src/client/Default.index.js +40 -40
- package/src/client/components/core/Account.js +290 -290
- package/src/client/components/core/AgGrid.js +160 -160
- package/src/client/components/core/Auth.js +19 -19
- package/src/client/components/core/Badge.js +32 -32
- package/src/client/components/core/{BlockChain.js → Blockchain.js} +41 -41
- package/src/client/components/core/Blog.js +9 -9
- package/src/client/components/core/BtnIcon.js +101 -94
- package/src/client/components/core/CalendarCore.js +458 -319
- package/src/client/components/core/Chat.js +64 -64
- package/src/client/components/core/ColorPalette.js +5267 -5267
- package/src/client/components/core/CommonJs.js +735 -732
- package/src/client/components/core/Content.js +193 -49
- package/src/client/components/core/Css.js +1064 -1027
- package/src/client/components/core/CssCore.js +817 -796
- package/src/client/components/core/D3Chart.js +44 -44
- package/src/client/components/core/Docs.js +229 -229
- package/src/client/components/core/DropDown.js +164 -164
- package/src/client/components/core/EventsUI.js +46 -54
- package/src/client/components/core/FileExplorer.js +699 -624
- package/src/client/components/core/FullScreen.js +45 -45
- package/src/client/components/core/Input.js +346 -259
- package/src/client/components/core/JoyStick.js +77 -77
- package/src/client/components/core/Keyboard.js +73 -73
- package/src/client/components/core/LoadingAnimation.js +179 -157
- package/src/client/components/core/LogIn.js +187 -181
- package/src/client/components/core/LogOut.js +58 -52
- package/src/client/components/core/Logger.js +26 -26
- package/src/client/components/core/Modal.js +1612 -1596
- package/src/client/components/core/NotificationManager.js +84 -84
- package/src/client/components/core/Panel.js +613 -413
- package/src/client/components/core/PanelForm.js +468 -0
- package/src/client/components/core/Polyhedron.js +162 -162
- package/src/client/components/core/Recover.js +204 -204
- package/src/client/components/core/Responsive.js +53 -53
- package/src/client/components/core/RichText.js +51 -27
- package/src/client/components/core/Router.js +76 -77
- package/src/client/components/core/Scroll.js +34 -0
- package/src/client/components/core/SignUp.js +125 -125
- package/src/client/components/core/SocketIo.js +72 -72
- package/src/client/components/core/Stream.js +113 -113
- package/src/client/components/core/ToggleSwitch.js +87 -87
- package/src/client/components/core/ToolTip.js +26 -26
- package/src/client/components/core/Translate.js +437 -408
- package/src/client/components/core/Validator.js +100 -100
- package/src/client/components/core/VanillaJs.js +460 -457
- package/src/client/components/core/Wallet.js +106 -106
- package/src/client/components/core/Webhook.js +25 -25
- package/src/client/components/core/Worker.js +272 -272
- package/src/client/components/default/CommonDefault.js +29 -29
- package/src/client/components/default/CssDefault.js +13 -13
- package/src/client/components/default/ElementsDefault.js +38 -38
- package/src/client/components/default/LogInDefault.js +41 -41
- package/src/client/components/default/LogOutDefault.js +28 -28
- package/src/client/components/default/MenuDefault.js +389 -389
- package/src/client/components/default/RoutesDefault.js +48 -48
- package/src/client/components/default/SettingsDefault.js +16 -16
- package/src/client/components/default/SignUpDefault.js +9 -9
- package/src/client/components/default/SocketIoDefault.js +54 -54
- package/src/client/components/default/TranslateDefault.js +7 -7
- package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
- package/src/client/public/default/browserconfig.xml +11 -11
- package/src/client/public/default/manifest.webmanifest +68 -68
- package/src/client/public/default/plantuml/client-conf.svg +1 -0
- package/src/client/public/default/plantuml/client-schema.svg +1 -0
- package/src/client/public/default/plantuml/cron-conf.svg +1 -0
- package/src/client/public/default/plantuml/cron-schema.svg +1 -0
- package/src/client/public/default/plantuml/server-conf.svg +1 -0
- package/src/client/public/default/plantuml/server-schema.svg +1 -0
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -0
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -0
- package/src/client/public/default/sitemap +147 -147
- package/src/client/public/default/yandex-browser-manifest.json +8 -8
- package/src/client/public/doc/sitemap +147 -147
- package/src/client/public/test/sitemap +147 -147
- package/src/client/services/core/core.service.js +170 -152
- package/src/client/services/crypto/crypto.service.js +70 -70
- package/src/client/services/default/default.management.js +345 -345
- package/src/client/services/default/default.service.js +89 -89
- package/src/client/services/file/file.service.js +70 -70
- package/src/client/services/instance/instance.management.js +74 -74
- package/src/client/services/instance/instance.service.js +89 -89
- package/src/client/services/test/test.service.js +70 -70
- package/src/client/services/user/user.management.js +50 -50
- package/src/client/services/user/user.service.js +89 -89
- package/src/client/ssr/Render.js +16 -16
- package/src/client/ssr/body-components/CacheControl.js +114 -113
- package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -79
- package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -21
- package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -17
- package/src/client/ssr/head-components/Css.js +241 -241
- package/src/client/ssr/head-components/DefaultScripts.js +3 -3
- package/src/client/ssr/head-components/Microdata.js +11 -11
- package/src/client/ssr/head-components/Production.js +1 -1
- package/src/client/ssr/head-components/PwaDefault.js +59 -59
- package/src/client/ssr/head-components/Seo.js +14 -14
- package/src/client/sw/default.sw.js +201 -201
- package/src/client/sw/template.sw.js +84 -84
- package/src/client.build.js +22 -22
- package/src/client.dev.js +21 -21
- package/src/cron.js +25 -25
- package/src/db/DataBaseProvider.js +34 -34
- package/src/db/mariadb/MariaDB.js +33 -33
- package/src/db/mongo/MongooseDB.js +137 -46
- package/src/dns.js +22 -22
- package/src/index.js +42 -29
- package/src/mailer/EmailRender.js +69 -69
- package/src/mailer/MailerProvider.js +96 -96
- package/src/proxy.js +22 -22
- package/src/runtime/lampp/Lampp.js +115 -44
- package/src/runtime/nginx/Nginx.js +3 -3
- package/src/runtime/xampp/Xampp.js +49 -49
- package/src/server/auth.js +235 -204
- package/src/server/backup.js +101 -94
- package/src/server/client-build-live.js +72 -72
- package/src/server/client-build.js +699 -699
- package/src/server/client-dev-server.js +60 -58
- package/src/server/client-formatted.js +48 -48
- package/src/server/client-icons.js +149 -150
- package/src/server/conf.js +860 -611
- package/src/server/dns.js +98 -98
- package/src/server/downloader.js +42 -42
- package/src/server/logger.js +190 -180
- package/src/server/network.js +122 -122
- package/src/server/peer.js +33 -33
- package/src/server/process.js +66 -66
- package/src/server/prompt-optimizer.js +28 -28
- package/src/server/proxy.js +118 -118
- package/src/server/runtime.js +444 -393
- package/src/server/ssl.js +120 -107
- package/src/server.js +25 -25
- package/src/ws/IoInterface.js +45 -45
- package/src/ws/IoServer.js +39 -39
- package/src/ws/core/channels/core.ws.chat.js +23 -23
- package/src/ws/core/channels/core.ws.mailer.js +35 -35
- package/src/ws/core/channels/core.ws.stream.js +31 -31
- package/src/ws/core/core.ws.connection.js +28 -28
- package/src/ws/core/core.ws.emit.js +14 -14
- package/src/ws/core/core.ws.server.js +24 -24
- package/src/ws/core/management/core.ws.chat.js +8 -8
- package/src/ws/core/management/core.ws.mailer.js +16 -16
- package/src/ws/core/management/core.ws.stream.js +8 -8
- package/src/ws/default/channels/default.ws.main.js +16 -16
- package/src/ws/default/default.ws.connection.js +22 -22
- package/src/ws/default/default.ws.emit.js +14 -14
- package/src/ws/default/default.ws.server.js +20 -20
- package/src/ws/default/management/default.ws.main.js +8 -8
- package/startup.js +11 -11
- package/supervisord-openssh-server.conf +4 -4
- package/test/api.test.js +60 -60
- package/bin/dns.js +0 -1
- package/bin/install.js +0 -357
- package/bin/shortcut.js +0 -44
|
@@ -1,457 +1,460 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vanilla JavaScript module for manipulating the DOM.
|
|
3
|
-
* @module src/client/components/core/VanillaJs.js
|
|
4
|
-
* @namespace VanillaJS
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { s4 } from './CommonJs.js';
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
|
|
11
|
-
Name: es6-string-html
|
|
12
|
-
Id: Tobermory.es6-string-html
|
|
13
|
-
Description: Syntax highlighting in es6 multiline strings
|
|
14
|
-
Version: 2.12.1
|
|
15
|
-
Publisher: Tobermory
|
|
16
|
-
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html
|
|
17
|
-
|
|
18
|
-
Name: es6-string-css
|
|
19
|
-
Id: bashmish.es6-string-css
|
|
20
|
-
Description: Highlight CSS language in ES6 template literals
|
|
21
|
-
Version: 0.1.0
|
|
22
|
-
Publisher: Mikhail Bashkirov
|
|
23
|
-
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=bashmish.es6-string-css
|
|
24
|
-
|
|
25
|
-
Name: lit-html
|
|
26
|
-
Id: bierner.lit-html
|
|
27
|
-
Description: Syntax highlighting and IntelliSense for html inside of JavaScript and TypeScript tagged template strings
|
|
28
|
-
Version: 1.11.1
|
|
29
|
-
Publisher: Matt Bierner
|
|
30
|
-
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=bierner.lit-html
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
// Docs by https://mintlify.com
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Query selector.
|
|
38
|
-
*
|
|
39
|
-
* @param {string} el The query selector.
|
|
40
|
-
* @returns {Element} Document object element.
|
|
41
|
-
* @memberof VanillaJS
|
|
42
|
-
*/
|
|
43
|
-
const s = (el) => document.querySelector(el);
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The function `htmls` takes an element and HTML content as arguments and sets the inner HTML of the
|
|
47
|
-
* element to the provided content.
|
|
48
|
-
* @param el - The `el` parameter in the `htmls` function represents the element in the HTML document
|
|
49
|
-
* that you want to update with the new HTML content.
|
|
50
|
-
* @param html - The `html` parameter in the `htmls` function is the HTML content that you want to set
|
|
51
|
-
* inside the specified element.
|
|
52
|
-
* @memberof VanillaJS
|
|
53
|
-
*/
|
|
54
|
-
const htmls = (el, html) => (s(el).innerHTML = html);
|
|
55
|
-
/**
|
|
56
|
-
* The `append` function inserts HTML content at the end of a specified element.
|
|
57
|
-
* @param el - The `el` parameter in the `append` function represents the element to which you want to
|
|
58
|
-
* append the HTML content.
|
|
59
|
-
* @param html - The `html` parameter in the `append` function represents the HTML content that you
|
|
60
|
-
* want to insert into the specified element. This content will be added to the end of the element's
|
|
61
|
-
* existing content.
|
|
62
|
-
* @memberof VanillaJS
|
|
63
|
-
*/
|
|
64
|
-
const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
|
|
65
|
-
/**
|
|
66
|
-
* The `prepend` function inserts the specified HTML content at the beginning of the selected element.
|
|
67
|
-
* @param el - The `el` parameter in the `prepend` function is the element to which the HTML content
|
|
68
|
-
* will be prepended.
|
|
69
|
-
* @param html - The `html` parameter in the `prepend` function represents the HTML content that you
|
|
70
|
-
* want to insert at the beginning of the specified element.
|
|
71
|
-
* @memberof VanillaJS
|
|
72
|
-
*/
|
|
73
|
-
const prepend = (el, html) => s(el).insertAdjacentHTML('afterbegin', html);
|
|
74
|
-
/**
|
|
75
|
-
* The function `sa` takes a CSS selector as an argument and returns a NodeList of elements that match
|
|
76
|
-
* the selector.
|
|
77
|
-
* @param el - The `el` parameter in the `sa` function is a string representing a CSS selector. This
|
|
78
|
-
* selector is used to query the document and select all elements that match the specified selector.
|
|
79
|
-
* @memberof VanillaJS
|
|
80
|
-
*/
|
|
81
|
-
const sa = (el) => document.querySelectorAll(el); // .forEach((currentValue, currentIndex, listObj)
|
|
82
|
-
|
|
83
|
-
// s(el).classList.remove(targetClass);
|
|
84
|
-
// s(el).classList.add(targetClass);
|
|
85
|
-
// s(el).classList.value;
|
|
86
|
-
// Array.from(s(el).classList);
|
|
87
|
-
// document.createElement('div');
|
|
88
|
-
// button.setAttribute("disabled", "");
|
|
89
|
-
// button.removeAttribute("disabled")
|
|
90
|
-
|
|
91
|
-
//  
|
|
92
|
-
|
|
93
|
-
// sa('[data-example]');
|
|
94
|
-
// <div data-example ></div>
|
|
95
|
-
|
|
96
|
-
// s(input).onblur = inputCheckFunction;
|
|
97
|
-
// s(input).oninput = inputCheckFunction;
|
|
98
|
-
// s(input).onfocus = inputCheckFunction;
|
|
99
|
-
// s(input).focus();
|
|
100
|
-
|
|
101
|
-
// s(`form`).onsubmit = (e) => {
|
|
102
|
-
// e.preventDefault();
|
|
103
|
-
// };
|
|
104
|
-
|
|
105
|
-
// s(el).onmouseover = () => null;
|
|
106
|
-
// s(el).onmouseout = () => null;
|
|
107
|
-
// `0`.repeat(3) -> 000
|
|
108
|
-
|
|
109
|
-
// s(`.${idModal}`).offsetWidth
|
|
110
|
-
// s(`.${idModal}`).offsetHeight
|
|
111
|
-
|
|
112
|
-
// get css style tag data definitions
|
|
113
|
-
// window.getComputedStyle(el).color;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* The `copyData` function uses the Clipboard API to copy the provided data to the clipboard and
|
|
117
|
-
* returns a promise that resolves to true if successful or false if unsuccessful.
|
|
118
|
-
* @param data - The `data` parameter in the `copyData` function represents the text data that you want
|
|
119
|
-
* to copy to the clipboard.
|
|
120
|
-
* @memberof VanillaJS
|
|
121
|
-
*/
|
|
122
|
-
const copyData = (data) =>
|
|
123
|
-
new Promise((resolve, reject) =>
|
|
124
|
-
navigator.clipboard.writeText(data).then(
|
|
125
|
-
() => resolve(true),
|
|
126
|
-
() => reject(false),
|
|
127
|
-
),
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* The function `pasteData` uses the Clipboard API to read text from the clipboard and returns it as a
|
|
132
|
-
* promise.
|
|
133
|
-
* @memberof VanillaJS
|
|
134
|
-
*/
|
|
135
|
-
const pasteData = () => new Promise((resolve) => navigator.clipboard.readText().then((clipText) => resolve(clipText)));
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* The setPath function in JavaScript updates the browser's history with a new path, state, and title.
|
|
139
|
-
* @param path - The `path` parameter is a string that represents the URL path where you want to
|
|
140
|
-
* navigate or update in the browser history. It is the first parameter in the `setPath` function and
|
|
141
|
-
* has a default value of `'/'`.
|
|
142
|
-
* @param stateStorage - The `stateStorage` parameter in the `setPath` function is an object that
|
|
143
|
-
* represents the state object associated with the new history entry. It is used to store data related
|
|
144
|
-
* to the state of the application when navigating to a new path using `history.pushState()`. This data
|
|
145
|
-
* can be accessed later
|
|
146
|
-
* @param title - The `title` parameter in the `setPath` function is a string that represents the
|
|
147
|
-
* title of the new history entry. It is used as the title of the new history entry in the browser's
|
|
148
|
-
* history.
|
|
149
|
-
* @memberof VanillaJS
|
|
150
|
-
*/
|
|
151
|
-
const setPath = (path = '/', stateStorage = {}, title = '') => history.pushState(stateStorage, title, path);
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* The function `getQueryParams` extracts query parameters from the current URL and returns them as an
|
|
155
|
-
* object.
|
|
156
|
-
* @returns An object containing the query parameters from the current URL is being returned.
|
|
157
|
-
* @memberof VanillaJS
|
|
158
|
-
*/
|
|
159
|
-
const getQueryParams = () => {
|
|
160
|
-
const params = new URLSearchParams(window.location.search);
|
|
161
|
-
let queries = {};
|
|
162
|
-
for (const param of params) {
|
|
163
|
-
queries[param[0]] = param[1];
|
|
164
|
-
}
|
|
165
|
-
return queries;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* The `preHTML` function in JavaScript replaces special characters like &, <, and > with their
|
|
170
|
-
* corresponding HTML entities.
|
|
171
|
-
* @param raw - The `raw` parameter in the `preHTML` function represents the raw HTML content that you
|
|
172
|
-
* want to sanitize by replacing special characters like `&`, `<`, and `>` with their corresponding
|
|
173
|
-
* HTML entities.
|
|
174
|
-
* @memberof VanillaJS
|
|
175
|
-
*/
|
|
176
|
-
const preHTML = (raw) => raw.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>');
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* The function `disableOptionsClick` disables specific user interaction options like right-click menu,
|
|
180
|
-
* drag, and text selection on a given HTML element.
|
|
181
|
-
* @param element - The `element` parameter in the `disableOptionsClick` function refers to the HTML
|
|
182
|
-
* element to which you want to disable certain user interactions like right-click context menu,
|
|
183
|
-
* drag-and-drop, or text selection based on the specified types.
|
|
184
|
-
* @param types - The `types` parameter in the `disableOptionsClick` function is an array that
|
|
185
|
-
* specifies the types of interactions to disable on the given `element`. The possible values for
|
|
186
|
-
* `types` are 'menu', 'drag', and 'select'.
|
|
187
|
-
* @returns In the `disableOptionsClick` function, event handlers are being assigned to the specified
|
|
188
|
-
* `element` based on the `types` array provided. The function is returning `false` for the
|
|
189
|
-
* corresponding events based on the types included in the `types` array.
|
|
190
|
-
* @memberof VanillaJS
|
|
191
|
-
*/
|
|
192
|
-
const disableOptionsClick = (element, types) => {
|
|
193
|
-
if (types.includes('menu'))
|
|
194
|
-
s(element).oncontextmenu = function () {
|
|
195
|
-
return false;
|
|
196
|
-
};
|
|
197
|
-
if (types.includes('drag'))
|
|
198
|
-
s(element).ondragstart = function () {
|
|
199
|
-
return false;
|
|
200
|
-
};
|
|
201
|
-
if (types.includes('select'))
|
|
202
|
-
s(element).onselectstart = function () {
|
|
203
|
-
return false;
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* The function `checkFullScreen` checks if the document is in full screen mode and returns a boolean
|
|
209
|
-
* value accordingly.
|
|
210
|
-
* @returns The function `checkFullScreen` is returning `true` if `document.fullscreenElement` is
|
|
211
|
-
* truthy, otherwise it returns `false`.
|
|
212
|
-
* @memberof VanillaJS
|
|
213
|
-
*/
|
|
214
|
-
const checkFullScreen = () => {
|
|
215
|
-
// !(!window.screenTop && !window.screenY) ||
|
|
216
|
-
return document.fullscreenElement ? true : false;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* The function `fullScreenOut` is used to exit full screen mode in a web browser.
|
|
221
|
-
* @memberof VanillaJS
|
|
222
|
-
*/
|
|
223
|
-
const fullScreenOut = () => {
|
|
224
|
-
if (document.exitFullscreen) {
|
|
225
|
-
document.exitFullscreen();
|
|
226
|
-
} else if (document.mozCancelFullScreen) {
|
|
227
|
-
document.mozCancelFullScreen();
|
|
228
|
-
} else if (document.webkitExitFullscreen) {
|
|
229
|
-
document.webkitExitFullscreen();
|
|
230
|
-
} else if (document.msExitFullscreen) {
|
|
231
|
-
window.top.document.msExitFullscreen();
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* The `fullScreenIn` function is used to request full screen mode in a web browser using different
|
|
237
|
-
* vendor-specific methods.
|
|
238
|
-
* @memberof VanillaJS
|
|
239
|
-
*/
|
|
240
|
-
const fullScreenIn = () => {
|
|
241
|
-
const elem = document.documentElement;
|
|
242
|
-
if (elem.requestFullscreen) {
|
|
243
|
-
elem.requestFullscreen();
|
|
244
|
-
} else if (elem.mozRequestFullScreen) {
|
|
245
|
-
/* Firefox */
|
|
246
|
-
elem.mozRequestFullScreen();
|
|
247
|
-
} else if (elem.webkitRequestFullscreen) {
|
|
248
|
-
/* Chrome, Safari & Opera */
|
|
249
|
-
elem.webkitRequestFullscreen();
|
|
250
|
-
} else if (elem.msRequestFullscreen) {
|
|
251
|
-
/* IE/Edge */
|
|
252
|
-
elem = window.top.document.body; //To break out of frame in IE
|
|
253
|
-
elem.msRequestFullscreen();
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* The function `getResponsiveData` returns an object containing the width, height, minimum value,
|
|
259
|
-
* maximum value, and corresponding types based on the window dimensions.
|
|
260
|
-
* @returns The `getResponsiveData` function returns an object that contains the width and height of
|
|
261
|
-
* the window, along with additional properties based on whether the width is greater than the height
|
|
262
|
-
* or not. If the width is greater than the height, the returned object includes the width, height,
|
|
263
|
-
* minValue (height), maxValue (width), minType ('height'), and maxType ('width'). If the height is
|
|
264
|
-
* greater than
|
|
265
|
-
* @memberof VanillaJS
|
|
266
|
-
*/
|
|
267
|
-
const getResponsiveData = () => {
|
|
268
|
-
const inner = { width: window.innerWidth, height: window.innerHeight };
|
|
269
|
-
return inner.width > inner.height
|
|
270
|
-
? { ...inner, minValue: window.innerHeight, maxValue: window.innerWidth, minType: 'height', maxType: 'width' }
|
|
271
|
-
: { ...inner, minValue: window.innerWidth, maxValue: window.innerHeight, minType: 'width', maxType: 'height' };
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* The function `isElement` checks if a given object is an instance of `Element` or `HTMLDocument`.
|
|
276
|
-
* @param element - The `element` parameter is a variable that represents an HTML element or an HTML
|
|
277
|
-
* document. The `isElement` function checks if the provided `element` is an instance of the `Element`
|
|
278
|
-
* interface or the `HTMLDocument` interface.
|
|
279
|
-
* @memberof VanillaJS
|
|
280
|
-
*/
|
|
281
|
-
const isElement = (element) => element instanceof Element || element instanceof HTMLDocument;
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Download File.
|
|
285
|
-
*
|
|
286
|
-
* @param {File | Blob} fileInstance The file or blob object.
|
|
287
|
-
* @param {string} fileName The file name with extension.
|
|
288
|
-
* @returns {void} void.
|
|
289
|
-
* @memberof VanillaJS
|
|
290
|
-
*/
|
|
291
|
-
function downloadFile(fileInstance, fileName) {
|
|
292
|
-
// const blob = new Blob([raw], { type: 'image/png' })
|
|
293
|
-
// const file = new File([blob], { type: 'image/png' }); // open window save name
|
|
294
|
-
// downloadFile(blob | file, `${name}.png`);
|
|
295
|
-
|
|
296
|
-
// Create a URL for the file
|
|
297
|
-
const url = URL.createObjectURL(fileInstance);
|
|
298
|
-
|
|
299
|
-
// Create an anchor element
|
|
300
|
-
const idDownload = 'downloader-' + s4() + s4();
|
|
301
|
-
append('body', html`<a class="${idDownload}" style="display: none"></a>`);
|
|
302
|
-
|
|
303
|
-
// Exec download
|
|
304
|
-
s(`.${idDownload}`).href = url;
|
|
305
|
-
s(`.${idDownload}`).download = fileName;
|
|
306
|
-
s(`.${idDownload}`).click();
|
|
307
|
-
s(`.${idDownload}`).remove();
|
|
308
|
-
|
|
309
|
-
// Revoke the URL object to free up resources
|
|
310
|
-
return URL.revokeObjectURL(url);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* The function `getRawContentFile` reads the raw content of a file using a FileReader in JavaScript.
|
|
315
|
-
* @param blob - The `blob` parameter in the `getRawContentFile` function is a Buffer object that
|
|
316
|
-
* represents raw binary data. It is used to read the content of a file as text using a FileReader in
|
|
317
|
-
* the browser environment.
|
|
318
|
-
* @memberof VanillaJS
|
|
319
|
-
*/
|
|
320
|
-
const getRawContentFile = (blob = new Buffer()) =>
|
|
321
|
-
new Promise((resolve) => {
|
|
322
|
-
{
|
|
323
|
-
const reader = new FileReader();
|
|
324
|
-
reader.onload = () => resolve(reader.result);
|
|
325
|
-
reader.readAsText(blob);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* The function `getBlobFromUint8ArrayFile` creates a Blob object from a Uint8Array file data with a
|
|
331
|
-
* specified mimetype.
|
|
332
|
-
* @param data - The `data` parameter in the `getBlobFromUint8ArrayFile` function is an array of
|
|
333
|
-
* arrays containing Uint8Array data.
|
|
334
|
-
* @param mimetype - The `mimetype` parameter in the
|
|
335
|
-
* `getBlobFromUint8ArrayFile` function is a string that specifies the type of the Blob object being
|
|
336
|
-
* created. It indicates the MIME type of the data contained in the Blob. For example, common MIME
|
|
337
|
-
* types include 'image/jpeg' for JPEG images,
|
|
338
|
-
* @returns A Blob object is being returned, created from the provided Uint8Array data and mimetype.
|
|
339
|
-
* @memberof VanillaJS
|
|
340
|
-
*/
|
|
341
|
-
const getBlobFromUint8ArrayFile = (data = [[]], mimetype = 'application/octet-stream') => {
|
|
342
|
-
return new Blob([new Uint8Array(data)], { type: mimetype });
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
// Router
|
|
346
|
-
/**
|
|
347
|
-
* The function `getProxyPath` returns a proxy path based on the current location pathname.
|
|
348
|
-
* @returns The `getProxyPath` function returns the path based on the current location. If the first
|
|
349
|
-
* segment of the pathname is not empty, it returns `/<first-segment>/`, otherwise it returns `/`. If
|
|
350
|
-
* the `window.Routes` object exists and the path is not `/` and the path without the trailing slash is
|
|
351
|
-
* a key in the `window.Routes` object, it returns `/`.
|
|
352
|
-
* @memberof VanillaJS
|
|
353
|
-
*/
|
|
354
|
-
const getProxyPath = () => {
|
|
355
|
-
// warning: evaluates headers html source
|
|
356
|
-
let path = location.pathname.split('/')[1] ? `/${location.pathname.split('/')[1]}/` : '/';
|
|
357
|
-
if (window.Routes && path !== '/' && path.slice(0, -1) in window.Routes()) path = '/';
|
|
358
|
-
return path;
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* The function `isNavigator` checks if the user agent string contains a specified name.
|
|
363
|
-
* @param name - The `name` parameter is a string that represents the name of a browser or device to
|
|
364
|
-
* check against the user agent string of the browser.
|
|
365
|
-
* @memberof VanillaJS
|
|
366
|
-
*/
|
|
367
|
-
const isNavigator = (name) => navigator.userAgent.toLowerCase().match(name.toLowerCase());
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* The function `getTimeZone` returns the current time zone based on the user's browser settings.
|
|
371
|
-
* @memberof VanillaJS
|
|
372
|
-
*/
|
|
373
|
-
const getTimeZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* The function `getAllChildNodes` recursively retrieves all child nodes of a given parent node in a
|
|
377
|
-
* tree-like structure.
|
|
378
|
-
* @param node - The `node` parameter in the `getAllChildNodes` function is the starting node from
|
|
379
|
-
* which you want to retrieve all child nodes recursively.
|
|
380
|
-
* @returns The `getAllChildNodes` function returns an array containing all the child nodes of the
|
|
381
|
-
* input `node`, including nested child nodes.
|
|
382
|
-
* @memberof VanillaJS
|
|
383
|
-
*/
|
|
384
|
-
function getAllChildNodes(node) {
|
|
385
|
-
const allNodes = [];
|
|
386
|
-
|
|
387
|
-
function traverse(node) {
|
|
388
|
-
if (node.childNodes.length === 0) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
for (let i = 0; i < node.childNodes.length; i++) {
|
|
393
|
-
const child = node.childNodes[i];
|
|
394
|
-
allNodes.push(child);
|
|
395
|
-
traverse(child);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
traverse(node);
|
|
400
|
-
return allNodes;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* The function `isActiveTab` checks if the document has focus.
|
|
405
|
-
* @memberof VanillaJS
|
|
406
|
-
*/
|
|
407
|
-
const isActiveTab = () => document.hasFocus();
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* The function `isActiveElement` checks if the active element in the document matches a specified
|
|
411
|
-
* class search.
|
|
412
|
-
* @param classSearch - The `classSearch` parameter is a string that is used to search for a specific
|
|
413
|
-
* class name within the `classList` of the active element in the document.
|
|
414
|
-
* @memberof VanillaJS
|
|
415
|
-
*/
|
|
416
|
-
const isActiveElement = (classSearch = '') =>
|
|
417
|
-
document.activeElement?.classList?.value?.match(classSearch) ? true : false;
|
|
418
|
-
|
|
419
|
-
const getCurrentTrace = () => {
|
|
420
|
-
try {
|
|
421
|
-
_stack;
|
|
422
|
-
} catch (error) {
|
|
423
|
-
return error.stack.split('is not defined')[1];
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
const isDevInstance = () => location.origin.match('localhost') && location.port;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Vanilla JavaScript module for manipulating the DOM.
|
|
3
|
+
* @module src/client/components/core/VanillaJs.js
|
|
4
|
+
* @namespace VanillaJS
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { s4 } from './CommonJs.js';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
|
|
11
|
+
Name: es6-string-html
|
|
12
|
+
Id: Tobermory.es6-string-html
|
|
13
|
+
Description: Syntax highlighting in es6 multiline strings
|
|
14
|
+
Version: 2.12.1
|
|
15
|
+
Publisher: Tobermory
|
|
16
|
+
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html
|
|
17
|
+
|
|
18
|
+
Name: es6-string-css
|
|
19
|
+
Id: bashmish.es6-string-css
|
|
20
|
+
Description: Highlight CSS language in ES6 template literals
|
|
21
|
+
Version: 0.1.0
|
|
22
|
+
Publisher: Mikhail Bashkirov
|
|
23
|
+
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=bashmish.es6-string-css
|
|
24
|
+
|
|
25
|
+
Name: lit-html
|
|
26
|
+
Id: bierner.lit-html
|
|
27
|
+
Description: Syntax highlighting and IntelliSense for html inside of JavaScript and TypeScript tagged template strings
|
|
28
|
+
Version: 1.11.1
|
|
29
|
+
Publisher: Matt Bierner
|
|
30
|
+
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=bierner.lit-html
|
|
31
|
+
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
// Docs by https://mintlify.com
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Query selector.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} el The query selector.
|
|
40
|
+
* @returns {Element} Document object element.
|
|
41
|
+
* @memberof VanillaJS
|
|
42
|
+
*/
|
|
43
|
+
const s = (el) => document.querySelector(el);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The function `htmls` takes an element and HTML content as arguments and sets the inner HTML of the
|
|
47
|
+
* element to the provided content.
|
|
48
|
+
* @param el - The `el` parameter in the `htmls` function represents the element in the HTML document
|
|
49
|
+
* that you want to update with the new HTML content.
|
|
50
|
+
* @param html - The `html` parameter in the `htmls` function is the HTML content that you want to set
|
|
51
|
+
* inside the specified element.
|
|
52
|
+
* @memberof VanillaJS
|
|
53
|
+
*/
|
|
54
|
+
const htmls = (el, html) => (s(el).innerHTML = html);
|
|
55
|
+
/**
|
|
56
|
+
* The `append` function inserts HTML content at the end of a specified element.
|
|
57
|
+
* @param el - The `el` parameter in the `append` function represents the element to which you want to
|
|
58
|
+
* append the HTML content.
|
|
59
|
+
* @param html - The `html` parameter in the `append` function represents the HTML content that you
|
|
60
|
+
* want to insert into the specified element. This content will be added to the end of the element's
|
|
61
|
+
* existing content.
|
|
62
|
+
* @memberof VanillaJS
|
|
63
|
+
*/
|
|
64
|
+
const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);
|
|
65
|
+
/**
|
|
66
|
+
* The `prepend` function inserts the specified HTML content at the beginning of the selected element.
|
|
67
|
+
* @param el - The `el` parameter in the `prepend` function is the element to which the HTML content
|
|
68
|
+
* will be prepended.
|
|
69
|
+
* @param html - The `html` parameter in the `prepend` function represents the HTML content that you
|
|
70
|
+
* want to insert at the beginning of the specified element.
|
|
71
|
+
* @memberof VanillaJS
|
|
72
|
+
*/
|
|
73
|
+
const prepend = (el, html) => s(el).insertAdjacentHTML('afterbegin', html);
|
|
74
|
+
/**
|
|
75
|
+
* The function `sa` takes a CSS selector as an argument and returns a NodeList of elements that match
|
|
76
|
+
* the selector.
|
|
77
|
+
* @param el - The `el` parameter in the `sa` function is a string representing a CSS selector. This
|
|
78
|
+
* selector is used to query the document and select all elements that match the specified selector.
|
|
79
|
+
* @memberof VanillaJS
|
|
80
|
+
*/
|
|
81
|
+
const sa = (el) => document.querySelectorAll(el); // .forEach((currentValue, currentIndex, listObj)
|
|
82
|
+
|
|
83
|
+
// s(el).classList.remove(targetClass);
|
|
84
|
+
// s(el).classList.add(targetClass);
|
|
85
|
+
// s(el).classList.value;
|
|
86
|
+
// Array.from(s(el).classList);
|
|
87
|
+
// document.createElement('div');
|
|
88
|
+
// button.setAttribute("disabled", "");
|
|
89
|
+
// button.removeAttribute("disabled")
|
|
90
|
+
|
|
91
|
+
//  
|
|
92
|
+
|
|
93
|
+
// sa('[data-example]');
|
|
94
|
+
// <div data-example ></div>
|
|
95
|
+
|
|
96
|
+
// s(input).onblur = inputCheckFunction;
|
|
97
|
+
// s(input).oninput = inputCheckFunction;
|
|
98
|
+
// s(input).onfocus = inputCheckFunction;
|
|
99
|
+
// s(input).focus();
|
|
100
|
+
|
|
101
|
+
// s(`form`).onsubmit = (e) => {
|
|
102
|
+
// e.preventDefault();
|
|
103
|
+
// };
|
|
104
|
+
|
|
105
|
+
// s(el).onmouseover = () => null;
|
|
106
|
+
// s(el).onmouseout = () => null;
|
|
107
|
+
// `0`.repeat(3) -> 000
|
|
108
|
+
|
|
109
|
+
// s(`.${idModal}`).offsetWidth
|
|
110
|
+
// s(`.${idModal}`).offsetHeight
|
|
111
|
+
|
|
112
|
+
// get css style tag data definitions
|
|
113
|
+
// window.getComputedStyle(el).color;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The `copyData` function uses the Clipboard API to copy the provided data to the clipboard and
|
|
117
|
+
* returns a promise that resolves to true if successful or false if unsuccessful.
|
|
118
|
+
* @param data - The `data` parameter in the `copyData` function represents the text data that you want
|
|
119
|
+
* to copy to the clipboard.
|
|
120
|
+
* @memberof VanillaJS
|
|
121
|
+
*/
|
|
122
|
+
const copyData = (data) =>
|
|
123
|
+
new Promise((resolve, reject) =>
|
|
124
|
+
navigator.clipboard.writeText(data).then(
|
|
125
|
+
() => resolve(true),
|
|
126
|
+
() => reject(false),
|
|
127
|
+
),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The function `pasteData` uses the Clipboard API to read text from the clipboard and returns it as a
|
|
132
|
+
* promise.
|
|
133
|
+
* @memberof VanillaJS
|
|
134
|
+
*/
|
|
135
|
+
const pasteData = () => new Promise((resolve) => navigator.clipboard.readText().then((clipText) => resolve(clipText)));
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The setPath function in JavaScript updates the browser's history with a new path, state, and title.
|
|
139
|
+
* @param path - The `path` parameter is a string that represents the URL path where you want to
|
|
140
|
+
* navigate or update in the browser history. It is the first parameter in the `setPath` function and
|
|
141
|
+
* has a default value of `'/'`.
|
|
142
|
+
* @param stateStorage - The `stateStorage` parameter in the `setPath` function is an object that
|
|
143
|
+
* represents the state object associated with the new history entry. It is used to store data related
|
|
144
|
+
* to the state of the application when navigating to a new path using `history.pushState()`. This data
|
|
145
|
+
* can be accessed later
|
|
146
|
+
* @param title - The `title` parameter in the `setPath` function is a string that represents the
|
|
147
|
+
* title of the new history entry. It is used as the title of the new history entry in the browser's
|
|
148
|
+
* history.
|
|
149
|
+
* @memberof VanillaJS
|
|
150
|
+
*/
|
|
151
|
+
const setPath = (path = '/', stateStorage = {}, title = '') => history.pushState(stateStorage, title, path);
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The function `getQueryParams` extracts query parameters from the current URL and returns them as an
|
|
155
|
+
* object.
|
|
156
|
+
* @returns An object containing the query parameters from the current URL is being returned.
|
|
157
|
+
* @memberof VanillaJS
|
|
158
|
+
*/
|
|
159
|
+
const getQueryParams = () => {
|
|
160
|
+
const params = new URLSearchParams(window.location.search);
|
|
161
|
+
let queries = {};
|
|
162
|
+
for (const param of params) {
|
|
163
|
+
queries[param[0]] = param[1];
|
|
164
|
+
}
|
|
165
|
+
return queries;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The `preHTML` function in JavaScript replaces special characters like &, <, and > with their
|
|
170
|
+
* corresponding HTML entities.
|
|
171
|
+
* @param raw - The `raw` parameter in the `preHTML` function represents the raw HTML content that you
|
|
172
|
+
* want to sanitize by replacing special characters like `&`, `<`, and `>` with their corresponding
|
|
173
|
+
* HTML entities.
|
|
174
|
+
* @memberof VanillaJS
|
|
175
|
+
*/
|
|
176
|
+
const preHTML = (raw) => raw.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>');
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The function `disableOptionsClick` disables specific user interaction options like right-click menu,
|
|
180
|
+
* drag, and text selection on a given HTML element.
|
|
181
|
+
* @param element - The `element` parameter in the `disableOptionsClick` function refers to the HTML
|
|
182
|
+
* element to which you want to disable certain user interactions like right-click context menu,
|
|
183
|
+
* drag-and-drop, or text selection based on the specified types.
|
|
184
|
+
* @param types - The `types` parameter in the `disableOptionsClick` function is an array that
|
|
185
|
+
* specifies the types of interactions to disable on the given `element`. The possible values for
|
|
186
|
+
* `types` are 'menu', 'drag', and 'select'.
|
|
187
|
+
* @returns In the `disableOptionsClick` function, event handlers are being assigned to the specified
|
|
188
|
+
* `element` based on the `types` array provided. The function is returning `false` for the
|
|
189
|
+
* corresponding events based on the types included in the `types` array.
|
|
190
|
+
* @memberof VanillaJS
|
|
191
|
+
*/
|
|
192
|
+
const disableOptionsClick = (element, types) => {
|
|
193
|
+
if (types.includes('menu'))
|
|
194
|
+
s(element).oncontextmenu = function () {
|
|
195
|
+
return false;
|
|
196
|
+
};
|
|
197
|
+
if (types.includes('drag'))
|
|
198
|
+
s(element).ondragstart = function () {
|
|
199
|
+
return false;
|
|
200
|
+
};
|
|
201
|
+
if (types.includes('select'))
|
|
202
|
+
s(element).onselectstart = function () {
|
|
203
|
+
return false;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The function `checkFullScreen` checks if the document is in full screen mode and returns a boolean
|
|
209
|
+
* value accordingly.
|
|
210
|
+
* @returns The function `checkFullScreen` is returning `true` if `document.fullscreenElement` is
|
|
211
|
+
* truthy, otherwise it returns `false`.
|
|
212
|
+
* @memberof VanillaJS
|
|
213
|
+
*/
|
|
214
|
+
const checkFullScreen = () => {
|
|
215
|
+
// !(!window.screenTop && !window.screenY) ||
|
|
216
|
+
return document.fullscreenElement ? true : false;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The function `fullScreenOut` is used to exit full screen mode in a web browser.
|
|
221
|
+
* @memberof VanillaJS
|
|
222
|
+
*/
|
|
223
|
+
const fullScreenOut = () => {
|
|
224
|
+
if (document.exitFullscreen) {
|
|
225
|
+
document.exitFullscreen();
|
|
226
|
+
} else if (document.mozCancelFullScreen) {
|
|
227
|
+
document.mozCancelFullScreen();
|
|
228
|
+
} else if (document.webkitExitFullscreen) {
|
|
229
|
+
document.webkitExitFullscreen();
|
|
230
|
+
} else if (document.msExitFullscreen) {
|
|
231
|
+
window.top.document.msExitFullscreen();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The `fullScreenIn` function is used to request full screen mode in a web browser using different
|
|
237
|
+
* vendor-specific methods.
|
|
238
|
+
* @memberof VanillaJS
|
|
239
|
+
*/
|
|
240
|
+
const fullScreenIn = () => {
|
|
241
|
+
const elem = document.documentElement;
|
|
242
|
+
if (elem.requestFullscreen) {
|
|
243
|
+
elem.requestFullscreen();
|
|
244
|
+
} else if (elem.mozRequestFullScreen) {
|
|
245
|
+
/* Firefox */
|
|
246
|
+
elem.mozRequestFullScreen();
|
|
247
|
+
} else if (elem.webkitRequestFullscreen) {
|
|
248
|
+
/* Chrome, Safari & Opera */
|
|
249
|
+
elem.webkitRequestFullscreen();
|
|
250
|
+
} else if (elem.msRequestFullscreen) {
|
|
251
|
+
/* IE/Edge */
|
|
252
|
+
elem = window.top.document.body; //To break out of frame in IE
|
|
253
|
+
elem.msRequestFullscreen();
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* The function `getResponsiveData` returns an object containing the width, height, minimum value,
|
|
259
|
+
* maximum value, and corresponding types based on the window dimensions.
|
|
260
|
+
* @returns The `getResponsiveData` function returns an object that contains the width and height of
|
|
261
|
+
* the window, along with additional properties based on whether the width is greater than the height
|
|
262
|
+
* or not. If the width is greater than the height, the returned object includes the width, height,
|
|
263
|
+
* minValue (height), maxValue (width), minType ('height'), and maxType ('width'). If the height is
|
|
264
|
+
* greater than
|
|
265
|
+
* @memberof VanillaJS
|
|
266
|
+
*/
|
|
267
|
+
const getResponsiveData = () => {
|
|
268
|
+
const inner = { width: window.innerWidth, height: window.innerHeight };
|
|
269
|
+
return inner.width > inner.height
|
|
270
|
+
? { ...inner, minValue: window.innerHeight, maxValue: window.innerWidth, minType: 'height', maxType: 'width' }
|
|
271
|
+
: { ...inner, minValue: window.innerWidth, maxValue: window.innerHeight, minType: 'width', maxType: 'height' };
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* The function `isElement` checks if a given object is an instance of `Element` or `HTMLDocument`.
|
|
276
|
+
* @param element - The `element` parameter is a variable that represents an HTML element or an HTML
|
|
277
|
+
* document. The `isElement` function checks if the provided `element` is an instance of the `Element`
|
|
278
|
+
* interface or the `HTMLDocument` interface.
|
|
279
|
+
* @memberof VanillaJS
|
|
280
|
+
*/
|
|
281
|
+
const isElement = (element) => element instanceof Element || element instanceof HTMLDocument;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Download File.
|
|
285
|
+
*
|
|
286
|
+
* @param {File | Blob} fileInstance The file or blob object.
|
|
287
|
+
* @param {string} fileName The file name with extension.
|
|
288
|
+
* @returns {void} void.
|
|
289
|
+
* @memberof VanillaJS
|
|
290
|
+
*/
|
|
291
|
+
function downloadFile(fileInstance, fileName) {
|
|
292
|
+
// const blob = new Blob([raw], { type: 'image/png' })
|
|
293
|
+
// const file = new File([blob], { type: 'image/png' }); // open window save name
|
|
294
|
+
// downloadFile(blob | file, `${name}.png`);
|
|
295
|
+
|
|
296
|
+
// Create a URL for the file
|
|
297
|
+
const url = URL.createObjectURL(fileInstance);
|
|
298
|
+
|
|
299
|
+
// Create an anchor element
|
|
300
|
+
const idDownload = 'downloader-' + s4() + s4();
|
|
301
|
+
append('body', html`<a class="${idDownload}" style="display: none"></a>`);
|
|
302
|
+
|
|
303
|
+
// Exec download
|
|
304
|
+
s(`.${idDownload}`).href = url;
|
|
305
|
+
s(`.${idDownload}`).download = fileName;
|
|
306
|
+
s(`.${idDownload}`).click();
|
|
307
|
+
s(`.${idDownload}`).remove();
|
|
308
|
+
|
|
309
|
+
// Revoke the URL object to free up resources
|
|
310
|
+
return URL.revokeObjectURL(url);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* The function `getRawContentFile` reads the raw content of a file using a FileReader in JavaScript.
|
|
315
|
+
* @param blob - The `blob` parameter in the `getRawContentFile` function is a Buffer object that
|
|
316
|
+
* represents raw binary data. It is used to read the content of a file as text using a FileReader in
|
|
317
|
+
* the browser environment.
|
|
318
|
+
* @memberof VanillaJS
|
|
319
|
+
*/
|
|
320
|
+
const getRawContentFile = (blob = new Buffer()) =>
|
|
321
|
+
new Promise((resolve) => {
|
|
322
|
+
{
|
|
323
|
+
const reader = new FileReader();
|
|
324
|
+
reader.onload = () => resolve(reader.result);
|
|
325
|
+
reader.readAsText(blob);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* The function `getBlobFromUint8ArrayFile` creates a Blob object from a Uint8Array file data with a
|
|
331
|
+
* specified mimetype.
|
|
332
|
+
* @param data - The `data` parameter in the `getBlobFromUint8ArrayFile` function is an array of
|
|
333
|
+
* arrays containing Uint8Array data.
|
|
334
|
+
* @param mimetype - The `mimetype` parameter in the
|
|
335
|
+
* `getBlobFromUint8ArrayFile` function is a string that specifies the type of the Blob object being
|
|
336
|
+
* created. It indicates the MIME type of the data contained in the Blob. For example, common MIME
|
|
337
|
+
* types include 'image/jpeg' for JPEG images,
|
|
338
|
+
* @returns A Blob object is being returned, created from the provided Uint8Array data and mimetype.
|
|
339
|
+
* @memberof VanillaJS
|
|
340
|
+
*/
|
|
341
|
+
const getBlobFromUint8ArrayFile = (data = [[]], mimetype = 'application/octet-stream') => {
|
|
342
|
+
return new Blob([new Uint8Array(data)], { type: mimetype });
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
// Router
|
|
346
|
+
/**
|
|
347
|
+
* The function `getProxyPath` returns a proxy path based on the current location pathname.
|
|
348
|
+
* @returns The `getProxyPath` function returns the path based on the current location. If the first
|
|
349
|
+
* segment of the pathname is not empty, it returns `/<first-segment>/`, otherwise it returns `/`. If
|
|
350
|
+
* the `window.Routes` object exists and the path is not `/` and the path without the trailing slash is
|
|
351
|
+
* a key in the `window.Routes` object, it returns `/`.
|
|
352
|
+
* @memberof VanillaJS
|
|
353
|
+
*/
|
|
354
|
+
const getProxyPath = () => {
|
|
355
|
+
// warning: evaluates headers html source
|
|
356
|
+
let path = location.pathname.split('/')[1] ? `/${location.pathname.split('/')[1]}/` : '/';
|
|
357
|
+
if (window.Routes && path !== '/' && path.slice(0, -1) in window.Routes()) path = '/';
|
|
358
|
+
return path;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* The function `isNavigator` checks if the user agent string contains a specified name.
|
|
363
|
+
* @param name - The `name` parameter is a string that represents the name of a browser or device to
|
|
364
|
+
* check against the user agent string of the browser.
|
|
365
|
+
* @memberof VanillaJS
|
|
366
|
+
*/
|
|
367
|
+
const isNavigator = (name) => navigator.userAgent.toLowerCase().match(name.toLowerCase());
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* The function `getTimeZone` returns the current time zone based on the user's browser settings.
|
|
371
|
+
* @memberof VanillaJS
|
|
372
|
+
*/
|
|
373
|
+
const getTimeZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* The function `getAllChildNodes` recursively retrieves all child nodes of a given parent node in a
|
|
377
|
+
* tree-like structure.
|
|
378
|
+
* @param node - The `node` parameter in the `getAllChildNodes` function is the starting node from
|
|
379
|
+
* which you want to retrieve all child nodes recursively.
|
|
380
|
+
* @returns The `getAllChildNodes` function returns an array containing all the child nodes of the
|
|
381
|
+
* input `node`, including nested child nodes.
|
|
382
|
+
* @memberof VanillaJS
|
|
383
|
+
*/
|
|
384
|
+
function getAllChildNodes(node) {
|
|
385
|
+
const allNodes = [];
|
|
386
|
+
|
|
387
|
+
function traverse(node) {
|
|
388
|
+
if (node.childNodes.length === 0) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
for (let i = 0; i < node.childNodes.length; i++) {
|
|
393
|
+
const child = node.childNodes[i];
|
|
394
|
+
allNodes.push(child);
|
|
395
|
+
traverse(child);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
traverse(node);
|
|
400
|
+
return allNodes;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* The function `isActiveTab` checks if the document has focus.
|
|
405
|
+
* @memberof VanillaJS
|
|
406
|
+
*/
|
|
407
|
+
const isActiveTab = () => document.hasFocus();
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* The function `isActiveElement` checks if the active element in the document matches a specified
|
|
411
|
+
* class search.
|
|
412
|
+
* @param classSearch - The `classSearch` parameter is a string that is used to search for a specific
|
|
413
|
+
* class name within the `classList` of the active element in the document.
|
|
414
|
+
* @memberof VanillaJS
|
|
415
|
+
*/
|
|
416
|
+
const isActiveElement = (classSearch = '') =>
|
|
417
|
+
document.activeElement?.classList?.value?.match(classSearch) ? true : false;
|
|
418
|
+
|
|
419
|
+
const getCurrentTrace = () => {
|
|
420
|
+
try {
|
|
421
|
+
_stack;
|
|
422
|
+
} catch (error) {
|
|
423
|
+
return error.stack.split('is not defined')[1];
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
const isDevInstance = () => location.origin.match('localhost') && location.port;
|
|
428
|
+
|
|
429
|
+
const getDataFromInputFile = async (file) => Array.from(new Uint8Array(await file.arrayBuffer()));
|
|
430
|
+
|
|
431
|
+
export {
|
|
432
|
+
s,
|
|
433
|
+
htmls,
|
|
434
|
+
append,
|
|
435
|
+
prepend,
|
|
436
|
+
sa,
|
|
437
|
+
copyData,
|
|
438
|
+
pasteData,
|
|
439
|
+
setPath,
|
|
440
|
+
getQueryParams,
|
|
441
|
+
preHTML,
|
|
442
|
+
disableOptionsClick,
|
|
443
|
+
checkFullScreen,
|
|
444
|
+
fullScreenOut,
|
|
445
|
+
fullScreenIn,
|
|
446
|
+
getResponsiveData,
|
|
447
|
+
isElement,
|
|
448
|
+
downloadFile,
|
|
449
|
+
getProxyPath,
|
|
450
|
+
getRawContentFile,
|
|
451
|
+
getBlobFromUint8ArrayFile,
|
|
452
|
+
isNavigator,
|
|
453
|
+
getTimeZone,
|
|
454
|
+
getAllChildNodes,
|
|
455
|
+
getCurrentTrace,
|
|
456
|
+
isActiveTab,
|
|
457
|
+
isActiveElement,
|
|
458
|
+
isDevInstance,
|
|
459
|
+
getDataFromInputFile,
|
|
460
|
+
};
|