Skip to content

Commit a7a4d05

Browse files
Release 20250705
1 parent 04d996e commit a7a4d05

File tree

9 files changed

+106
-11
lines changed

9 files changed

+106
-11
lines changed

hlp-aguide/Help-cs.zip

0 Bytes
Binary file not shown.

hlp-aguide/Help-en.zip

-69 Bytes
Binary file not shown.

hlp-user/Help-cs.zip

34 Bytes
Binary file not shown.

hlp-user/Help-en.zip

25 Bytes
Binary file not shown.

hlp/Help-cs.zip

314 Bytes
Binary file not shown.

hlp/Help-en.zip

360 Bytes
Binary file not shown.

hvdata/appmain.js

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
const PAR_NAME_DOC = 'd'; // Help file path
2+
3+
const id_JSAppRun = 'appRun';
4+
const FILENAME_ZIP_ON_USER_INPUT = '!.zip';
5+
6+
function _T(id) {
7+
return id;
8+
}
9+
10+
function appendField(target, id, defaultV = '', type = 'text') {
11+
target.innerHTML +=
12+
`<div class="form-row">
13+
<label for="${id}">${_T(id)}</label>
14+
<input type="${type}" id="${id}" value="${defaultV}" />
15+
</div>`;
16+
}
17+
18+
function formCorsHelpFilesUpload()
19+
{
20+
const formO = document.getElementById('formIn');
21+
const fieldHvData = 'data.zip';
22+
const fieldHelpLang = 'Help-(language).zip';
23+
//const fieldHelpBase = 'Help-.zip';
24+
const typeFile = 'file';
25+
26+
appendField(formO, fieldHvData, '', typeFile);
27+
appendField(formO, fieldHelpLang, '', typeFile);
28+
//appendField(formO, fieldHelpBase, '', typeFile);
29+
30+
const formM = document.getElementById('form');
31+
formM.addEventListener("submit", function(e) {
32+
e.preventDefault();
33+
34+
const hvData = document.getElementById(fieldHvData);
35+
const helpLang = document.getElementById(fieldHelpLang);
36+
37+
if (!hvData?.files?.length || !helpLang?.files?.length)
38+
return;
39+
40+
const fileHvData = hvData.files[0];
41+
const fileHelpLang = helpLang.files[0];
42+
43+
// var fileHelpBase = document.getElementById(fieldHelpBase);
44+
45+
// if (fileHelpBase?.files?.length)
46+
// fileHelpBase = fileHelpBase[0];
47+
// else
48+
// fileHelpBase = null;
49+
50+
document.getElementById(id_JSAppRun)?.remove();
51+
st = _Storage.add(STO_HELP, FILENAME_ZIP_ON_USER_INPUT, fileHelpLang).then(obsah => {
52+
main(fileHvData);
53+
const url = new URL(window.location.href);
54+
url.searchParams.set(PAR_NAME_DOC, FILENAME_ZIP_ON_USER_INPUT);
55+
window.history.pushState({}, "", url);
56+
});
57+
58+
})
59+
}
60+
161
const STO_DATA = 'STO_DATA';
262
const STO_HELP = 'STO_HELP';
363
const STOF_TEXT = 'text';
@@ -13,10 +73,10 @@ const STORAGE_ENGINES = {
1373
var _Storage = (() => {
1474
var storagesC = new Map();
1575

16-
async function add(key, path) {
76+
async function add(key, path, data = null) {
1777
for (const keyC in STORAGE_ENGINES) {
1878
if (path.endsWith(keyC)) {
19-
const eng = await STORAGE_ENGINES[keyC](path);
79+
const eng = await STORAGE_ENGINES[keyC](data || path);
2080
storagesC.set(key, eng);
2181
return true;
2282
}
@@ -179,16 +239,19 @@ async function newStorageDir(path) {
179239
};
180240
}
181241

182-
async function main() {
242+
async function main(baseDataStream = null) {
183243
var st = null;
184-
185-
try {
186-
st = await _Storage.add(STO_DATA, `${DATA_FILE_PATH_BASE}.zip`);
187-
} catch (error) {
188-
st = await _Storage.add(STO_DATA, `${DATA_FILE_PATH_BASE}/`);
244+
if (!baseDataStream) {
245+
try {
246+
st = await _Storage.add(STO_DATA, `${DATA_FILE_PATH_BASE}.zip`);
247+
} catch (error) {
248+
st = await _Storage.add(STO_DATA, `${DATA_FILE_PATH_BASE}/`);
249+
}
250+
} else {
251+
st = await _Storage.add(STO_DATA, `${DATA_FILE_PATH_BASE}.zip`, baseDataStream);
189252
}
190253
const srcT = await _Storage.search(STO_DATA, 'appmainRun.js');
191-
appendJavaScript('appRun', srcT, document.body);
254+
appendJavaScript(id_JSAppRun, srcT, document.body);
192255
runApp();
193256
}
194257

@@ -206,7 +269,12 @@ async function fetchData(url) {
206269
const ZIPHelpers = (() => {
207270
async function loadZipFromUrl(url) {
208271
try {
209-
const arrayBuffer = await fetchData(url);
272+
var arrayBuffer = null;
273+
if (typeof url === "string") {
274+
arrayBuffer = await fetchData(url);
275+
} else {
276+
arrayBuffer = await url.arrayBuffer();
277+
}
210278
const arch = await JSZip.loadAsync(arrayBuffer);
211279
return arch;
212280
} catch (error) {

hvdata/data.zip

7.32 KB
Binary file not shown.

index.html

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@
1515
<meta property="og:type" content="website">
1616
<meta property="og:image" content="favicon.png">
1717
<meta name="robots" content="index,follow">
18+
<style id="i-formsupport-css">
19+
.form-row {
20+
display: flex;
21+
gap: 1em;
22+
align-items: baseline;
23+
margin: 0.5em;
24+
}
25+
26+
.form-row label {
27+
width: 120px;
28+
margin-right: 0.5em;
29+
text-align: left;
30+
}
31+
32+
.form-row input {
33+
flex: 1;
34+
}
35+
</style>
1836
<!-- %NREL% -->
1937
</head>
2038
<script>
@@ -29,7 +47,16 @@
2947
</noscript>
3048
<div id="cors-error">
3149
<p> ⚠ Do you see this message only? Then viewer is not reading help file content.<br>This may be caused by your browser blocking local file access (file://) due to CORS policy restrictions. </p>
32-
<p>You need to run your browser in mode with bypass CORS policy:</p>
50+
<p>You can select these files:</p>
51+
<form id="form">
52+
<div id="formIn">
53+
</div>
54+
<button type="submit">Odeslat</button>
55+
</form>
56+
<script>
57+
formCorsHelpFilesUpload();
58+
</script>
59+
<p>Alternatively you need to run your browser in mode with bypass CORS policy:</p>
3360
<ul>
3461
<li><p>Chrome:</p>
3562
<blockquote>

0 commit comments

Comments
 (0)