From 5acb2499c1df14d6275b1ad9e139f02d1280cb9c Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Thu, 13 Jan 2022 10:15:12 +0100 Subject: facilitate managing repository URLs in a list; minor other changes --- common/patterns.js | 3 + compute_scripts.awk | 15 +- html/dialog.js | 10 ++ html/grid.css | 6 +- html/item_list.html | 8 + html/item_list.js | 4 +- html/item_preview.html | 2 +- html/payload_create.html | 3 - html/payload_create.js | 5 +- html/text_entry_list.html | 65 ++++++++ html/text_entry_list.js | 321 ++++++++++++++++++++++++++++++++++++++ test/unit/test_item_list.py | 17 +- test/unit/test_payload_create.py | 2 - test/unit/test_text_entry_list.py | 310 ++++++++++++++++++++++++++++++++++++ test/unit/utils.py | 3 + 15 files changed, 743 insertions(+), 31 deletions(-) create mode 100644 html/text_entry_list.html create mode 100644 html/text_entry_list.js create mode 100644 test/unit/test_text_entry_list.py diff --git a/common/patterns.js b/common/patterns.js index 36cabfb..1398961 100644 --- a/common/patterns.js +++ b/common/patterns.js @@ -185,3 +185,6 @@ function* each_url_pattern(url) } } #EXPORT each_url_pattern + +#EXPORT "https://hydrillabugs.koszko.org/projects/haketilo/wiki/URL_patterns" \ + AS patterns_doc_url diff --git a/compute_scripts.awk b/compute_scripts.awk index 1db79e0..6235e19 100755 --- a/compute_scripts.awk +++ b/compute_scripts.awk @@ -119,8 +119,7 @@ BEGIN { function process_file(path, read_path, mode, line, result, line_part, directive, directive_args, - if_nesting, if_nesting_true, if_branch_processed, - additional_line_nr) { + if_nesting, if_nesting_true, if_branch_processed) { if (path in modes && modes[path] != mode) { printf "ERROR: File %s used multiple times in different contexts\n", path > "/dev/stderr" @@ -166,10 +165,10 @@ function process_file(path, read_path, mode, } if (result == 0) { if (!(path in appended_lines_counts) || \ - additional_line_nr == appended_lines_counts[path]) + additional_line_nr[path] == appended_lines_counts[path]) break - line = appended_lines[path,++additional_line_nr] + line = appended_lines[path,++additional_line_nr[path]] } if (line !~ /^#/) { @@ -188,8 +187,8 @@ function process_file(path, read_path, mode, } if (result == 0) { if (path in appended_lines_counts && \ - additional_line_nr < appended_lines_counts[path]) { - line_part = appended_lines[path,++additional_line_nr] + additional_line_nr[path] < appended_lines_counts[path]) { + line_part = appended_lines[path,++additional_line_nr[path]] } else { printf "ERROR: Unexpected EOF in %s\n", read_path > "/dev/stderr" @@ -646,7 +645,7 @@ function print_amalgamation(js_deps, js_deps_count, } function print_usage() { - printf "USAGE: %s compute_scripts.awk -- [-D PREPROCESSOR_DEFINITION]... [-M manifest/to/process/manifest.json]... [-H html/to/process.html]... [-J js/to/process.js]... [-A js/to/append/to.js:appended_code]... [--help|-h] [--output-dir=./build] [--write-js-deps] [--write-html-deps] [--output=files-to-copy|--output=amalgamate-js:js/to/process.js]\n", + printf "USAGE: %s compute_scripts.awk -- [-D PREPROCESSOR_DEFINITION]... [-M manifest/to/process/manifest.json]... [-H html/to/process.html]... [-J js/to/process.js]... [-A file/to/append/to.js:appended_code]... [--help|-h] [--output-dir=./build] [--write-js-deps] [--write-html-deps] [--output=files-to-copy|--output=amalgamate-js:js/to/process.js]\n", ARGV[0] > "/dev/stderr" } @@ -711,8 +710,6 @@ function main(i, j, path, letter, dir, max_line_nr, js_deps, js_deps_count, return 1 } - modes[path] = "js" - clear_array(tmp_lines) code = ARGV[i] sub(/^[^:]+:/, "", code) diff --git a/html/dialog.js b/html/dialog.js index c4bba5d..a2406e8 100644 --- a/html/dialog.js +++ b/html/dialog.js @@ -129,3 +129,13 @@ const ask = (ctx, ...msg) => show_dialog(ctx, "ask_buts", msg); const loader = (ctx, ...msg) => show_dialog(ctx, null, msg); #EXPORT loader + +/* + * Wrapper around target.addEventListener() that makes the requested callback + * only execute if dialog is not shown. + */ +function onevent(ctx, target, event, cb) +{ + target.addEventListener(event, e => !ctx.shown && cb(e)); +} +#EXPORT onevent diff --git a/html/grid.css b/html/grid.css index aa8fc80..20bb85e 100644 --- a/html/grid.css +++ b/html/grid.css @@ -49,7 +49,7 @@ grid-column: 1 / span 2; } -span.grid_col_1 { +span.grid_col_1, label.grid_col_1 { text-align: right; } @@ -61,11 +61,11 @@ div.grid_col_both { text-align: initial; } -.grid_2>span { +.grid_2>span, grid_2>label { margin-top: 0.75em; } -.grid_form>span { +.grid_form>span, .grid_form>label { margin-top: 1.5em; margin-left: 1em; margin-right: 1em; diff --git a/html/item_list.html b/html/item_list.html index 5d2a163..4e23868 100644 --- a/html/item_list.html +++ b/html/item_list.html @@ -57,6 +57,14 @@ .item_list>li.item_li_highlight { cursor: default; } + .item_list.list_disabled, + .item_list.list_disabled *, + .item_list.list_disabled .item_li_highlight { + -moz-user-select: none; + user-select: none; + opacity: 0.75; + cursor: not-allowed; + } .list_buttons { margin: 1em auto; text-align: center; diff --git a/html/item_list.js b/html/item_list.js index 34dec83..198e0f9 100644 --- a/html/item_list.js +++ b/html/item_list.js @@ -185,14 +185,14 @@ async function item_list(preview_cb, track_cb, remove_cb) function on_dialog_show(list_ctx) { - list_ctx.ul; // TODO: make ul non-selectable when dialog is shown + list_ctx.ul.classList.add("list_disabled"); list_ctx.preview_container.classList.add("hide"); list_ctx.dialog_container.classList.remove("hide"); } function on_dialog_hide(list_ctx) { - list_ctx.ul; + list_ctx.ul.classList.remove("list_disabled"); if (list_ctx.previewed_item !== null) list_ctx.preview_container.classList.remove("hide"); list_ctx.dialog_container.classList.add("hide"); diff --git a/html/item_preview.html b/html/item_preview.html index 6cd15a8..160c01d 100644 --- a/html/item_preview.html +++ b/html/item_preview.html @@ -39,7 +39,7 @@ #LOADCSS html/grid.css