/* exported build_asu_request, init */
let current_model = {};
+let url_params = undefined;
function $(query) {
if (typeof query === "string") {
select.appendChild(option);
}
- // pre-select version from config.json
- const preselect = config.default_version;
+ // pre-select version from URL or config.json
+ const preselect = url_params.get("version") || config.default_version;
if (preselect) {
$("#versions").value = preselect;
}
updatePackageList(version, target);
}
+ // set current selection in URL
+ history.pushState(
+ null,
+ null,
+ document.location.href.split("?")[0] +
+ "?version=" +
+ encodeURIComponent(version) +
+ "&id=" +
+ encodeURIComponent(mobj["id"])
+ );
+
show("#images");
} else {
hide("#images");
}
function init() {
+ url_params = new URLSearchParams(window.location.search);
let build_date = "unknown";
setupSelectList($("#versions"), Object.keys(config.versions), (version) => {
);
// set model when selected version changes
- setModel(obj, current_model["id"], current_model["model"]);
+ setModel(
+ obj,
+ current_model["id"] || url_params.get("id"),
+ current_model["model"] || url_params.get("model")
+ );
// trigger update of current selected model
$("#models").onfocus();