Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,24 +419,13 @@ function show_custom_zoom_window() {

$w.$Button(localize("OK"), () => {
let option_val = $fieldset.find("input[name='custom-zoom-radio']:checked").val();
let mag;
if (option_val === "really-custom") {
option_val = $really_custom_input.val();
if (`${option_val}`.match(/\dx$/)) { // ...you can't actually type an x; oh well...
mag = parseFloat(option_val);
} else if (`${option_val}`.match(/\d%?$/)) {
mag = parseFloat(option_val) / 100;
}
if (isNaN(mag)) {
please_enter_a_number();
return;
}
setCustomizedSize($really_custom_input.val());
} else {
mag = parseFloat(option_val);
set_magnification(mag);
}

set_magnification(mag);

$w.close();
})[0].focus();
$w.$Button(localize("Cancel"), () => {
Expand All @@ -446,6 +435,20 @@ function show_custom_zoom_window() {
$w.center();
}

function setCustomizedSize(zoom_size) {
option_val = zoom_size;
let mag;
if (`${option_val}`.match(/\dx$/)) { // ...you can't actually type an x; oh well...
mag = parseFloat(option_val);
} else if (`${option_val}`.match(/\d%?$/)) {
mag = parseFloat(option_val) / 100;
}
if (isNaN(mag)) {
please_enter_a_number();
return;
}
set_magnification(mag);
}

function toggle_grid() {
show_grid = !show_grid;
Expand Down
18 changes: 17 additions & 1 deletion src/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@
const generate_session_id = () => (Math.random() * (2 ** 32)).toString(16).replace(".", "");
const update_session_from_location_hash = () => {
const session_match = location.hash.match(/^#?(?:.*,)?(session|local):(.*)$/i);
const load_from_url_match = location.hash.match(/^#?(?:.*,)?(load):(.*)$/i);
let load_from_url_match = location.hash.match(/^#?(?:.*,)?(load):(.*)$/i);
let change_zoom_size = location.hash.match(/^#?(?:.*,)?(zoom):(.*)$/i);
if (session_match) {
const local = session_match[1].toLowerCase() === "local";
const session_id = session_match[2];
Expand Down Expand Up @@ -534,6 +535,11 @@
}
}
} else if (load_from_url_match) {
let urlSplitted = load_from_url_match[2].trim().split("?")
if (urlSplitted.length > 1) {
load_from_url_match[2] = urlSplitted[0];
change_zoom_size = urlSplitted[1].match(/^#?(?:.*,)?(zoom):(.*)$/i);
}
const url = decodeURIComponent(load_from_url_match[2]);

const uris = get_uris(url);
Expand All @@ -549,8 +555,17 @@

load_image_from_uri(url).then((info) => {
open_from_image_info(info, null, null, true, true);
if (change_zoom_size) {
setCustomizedSize(change_zoom_size[2]);
}

}, show_resource_load_error_message);

} else if (change_zoom_size) {
end_current_session();
change_url_param("local", generate_session_id());

setCustomizedSize(change_zoom_size[2]);
} else {
log("No session ID in hash");
const old_hash = location.hash;
Expand All @@ -564,6 +579,7 @@
update_session_from_location_hash();
}
}

};

$G.on("hashchange popstate change-url-params", e => {
Expand Down