|
4 | 4 | let l_previous_click_diagram_global;
|
5 | 5 | let initialize_Maps_global;
|
6 | 6 |
|
| 7 | + /** |
| 8 | + * 初期状態でURLからsearchとhashを除く。 |
| 9 | + */ |
| 10 | + const s_initial_url_global = location.href.match(/\/([^/#?]*)(?:[#?][^/]*)?$/u)[1]; |
| 11 | + |
7 | 12 | const s_START_color_global = "#ffcaea";
|
8 | 13 |
|
9 | 14 | const e_input_screen_global = document.getElementById("input_screen");
|
|
12 | 17 | const e_diagram_global = document.getElementById("diagram");
|
13 | 18 | const e_mermaid_code_global = document.getElementById("mermaid_code");
|
14 | 19 |
|
15 |
| - history.replaceState({ "number": 0 }, ""); |
| 20 | + history.replaceState({ "number": 0 }, "", s_initial_url_global); |
16 | 21 |
|
17 | 22 | const escape_code = (s_mermaid_code) => s_mermaid_code.replaceAll(/\\/gu, "\\\\").replaceAll(/[_@*]/gu, "\\$&");
|
18 | 23 |
|
|
96 | 101 | /**
|
97 | 102 | * Object.create(null) としたのは o_functions={} なら if 条件の判定 o_functions[o_function_flow.s_to] でエラーになる場合があるため。
|
98 | 103 | * o_function_flow.s_to がプロトタイプ名と被ったときプロパティ名が最初から存在すると判定されてしまう。
|
99 |
| - * if 条件の判定ほうも Object.hasOwnProperty.call に変更した。 |
| 104 | + * if 条件判定のほうも Object.hasOwnProperty.call に変更した。 |
100 | 105 | */
|
101 | 106 | const o_functions = Object.create(null);
|
102 | 107 |
|
|
383 | 388 | e_output_screen_global.style.display = "none";
|
384 | 389 |
|
385 | 390 | e_input_screen_global.classList.remove("dragenter");
|
386 |
| - document.body.style.cursor = "initial"; |
| 391 | + document.body.style.cursor = ""; |
387 | 392 |
|
388 |
| - history.replaceState({ "number": 0 }, ""); |
| 393 | + history.replaceState({ "number": 0 }, "", s_initial_url_global); |
389 | 394 | };
|
390 | 395 |
|
391 | 396 | if (s_code_global === void 0) {
|
|
469 | 474 |
|
470 | 475 | e_input_screen_global.classList.remove("dragenter");
|
471 | 476 | // eslint-disable-next-line require-atomic-updates
|
472 |
| - document.body.style.cursor = "initial"; |
| 477 | + document.body.style.cursor = ""; |
473 | 478 |
|
474 | 479 | if (history.state?.number !== 1) {
|
475 |
| - history.pushState({ "number": 1 }, ""); |
| 480 | + history.pushState({ "number": 1 }, "", `${s_initial_url_global}?diagram`); |
476 | 481 | }
|
477 | 482 | };
|
478 | 483 |
|
|
484 | 489 | const e_select_file = document.getElementById("select_file");
|
485 | 490 | const e_body = document.body;
|
486 | 491 |
|
487 |
| - const l_change_file = () => { |
| 492 | + const l_change_file = async () => { |
488 | 493 | const { files } = e_select_file;
|
489 | 494 | const file = files[0];
|
490 | 495 | const s_filename = file.name;
|
491 | 496 | s_filename_global = s_filename;
|
492 | 497 |
|
493 |
| - const reader = new FileReader(); |
| 498 | + const s_code = await file.text(); |
494 | 499 |
|
495 |
| - reader.onload = () => { |
496 |
| - const s_code = reader.result; |
497 |
| - s_code_global = s_code; |
| 500 | + s_code_global = s_code; |
498 | 501 |
|
499 |
| - update_output_screen(s_code, s_filename); |
500 |
| - }; |
| 502 | + // eslint-disable-next-line require-atomic-updates |
| 503 | + e_select_file.value = ""; |
501 | 504 |
|
502 |
| - reader.readAsText(file); |
| 505 | + update_output_screen(s_code, s_filename); |
503 | 506 | };
|
504 | 507 |
|
505 | 508 | const l_dragenter_body = (e) => {
|
|
518 | 521 | }
|
519 | 522 | };
|
520 | 523 |
|
521 |
| - const l_drop_handler = (e) => { |
| 524 | + const l_drop_handler = async (e) => { |
522 | 525 | e.preventDefault();
|
523 | 526 |
|
524 | 527 | const item = [...e.dataTransfer.items].find((a) => a.kind === "file");
|
|
529 | 532 | const s_filename = file.name;
|
530 | 533 | s_filename_global = s_filename;
|
531 | 534 |
|
532 |
| - const reader = new FileReader(); |
533 |
| - |
534 |
| - reader.onload = () => { |
535 |
| - const s_code = reader.result; |
536 |
| - s_code_global = s_code; |
| 535 | + const s_code = await file.text(); |
537 | 536 |
|
538 |
| - update_output_screen(s_code, s_filename); |
539 |
| - }; |
| 537 | + s_code_global = s_code; |
540 | 538 |
|
541 |
| - reader.readAsText(file); |
| 539 | + update_output_screen(s_code, s_filename); |
542 | 540 | };
|
543 | 541 |
|
544 | 542 | const l_dragover_body = (e) => {
|
|
0 commit comments