aboutsummaryrefslogtreecommitdiff
path: root/html
diff options
context:
space:
mode:
Diffstat (limited to 'html')
-rw-r--r--html/options_main.js25
1 files changed, 12 insertions, 13 deletions
diff --git a/html/options_main.js b/html/options_main.js
index cf4c9b1..e1e6cbe 100644
--- a/html/options_main.js
+++ b/html/options_main.js
@@ -11,7 +11,6 @@
* IMPORT TYPE_PREFIX
* IMPORT TYPE_NAME
* IMPORT list_prefixes
- * IMPORT url_extract_target
* IMPORT nice_name
* IMPORTS_END
*/
@@ -633,7 +632,7 @@ function hide_import_window()
/*
* Reset file <input>. Without this, a second attempt to import the same
- * file would result in "change" event on happening on <input> element.
+ * file would result in "change" event not happening on <input> element.
*/
file_opener_form.reset();
}
@@ -685,26 +684,26 @@ function initialize_import_facility()
*
* We don't need to worry about the state of the page (e.g. some editing being
* in progress) in jump_to_item() - this function is called at the beginning,
- * before callbacks are assigned to buttons, so it is safe to assume lists are
- * initialized with items and page is in its virgin state with regard to
- * everything else.
+ * together with callbacks being assigned to buttons, so it is safe to assume
+ * lists are initialized with items and page is in its virgin state with regard
+ * to everything else.
*/
function jump_to_item(url_with_item)
{
- const parsed_url = url_extract_target(url_with_item);
-
- if (parsed_url.target === undefined)
+ const [dummy1, base_url, dummy2, target] =
+ /^([^#]*)(#(.*))?$/i.exec(url_with_item);
+ if (target === undefined)
return;
- const prefix = parsed_url.target.substring(1, 2);
+ const prefix = target.substring(0, 1);
if (!list_prefixes.includes(prefix)) {
- history.replaceState(null, "", parsed_url.base_url);
+ history.replaceState(null, "", base_url);
return;
}
by_id(`show_${TYPE_NAME[prefix]}s`).checked = true;
- edit_item(prefix, decodeURIComponent(parsed_url.target.substring(2)));
+ edit_item(prefix, decodeURIComponent(target.substring(1)));
}
async function main()
@@ -718,8 +717,6 @@ async function main()
add_radio_li(prefix, item);
}
- jump_to_item(document.URL);
-
let name = TYPE_NAME[prefix];
let add_but = by_id(`add_${name}_but`);
@@ -746,6 +743,8 @@ async function main()
cancel_components_but.addEventListener("click", cancel_components);
}
+ jump_to_item(document.URL);
+
initialize_import_facility();
storage.add_change_listener(handle_change);