Extract some helper functions for accessing a window/iframe by uuid

This commit is contained in:
Sam Atkins 2024-04-17 10:08:42 +01:00
parent 8cf58d7fc6
commit dfdda4f3b9
2 changed files with 11 additions and 9 deletions

View File

@ -74,14 +74,6 @@ window.addEventListener('message', async (event) => {
return;
}
const window_for_app_instance = (instance_id) => {
return $(`.window[data-element_uuid="${instance_id}"]`).get(0);
};
const iframe_for_app_instance = (instance_id) => {
return $(window_for_app_instance(instance_id)).find('.window-app-iframe').get(0);
};
const $el_parent_window = $(window_for_app_instance(event.data.appInstanceID));
const parent_window_id = $el_parent_window.attr('data-id');
const $el_parent_disable_mask = $el_parent_window.find('.window-disable-mask');

View File

@ -3513,3 +3513,13 @@ window.change_clock_visible = (clock_visible) => {
$('select.change-clock-visible').val(window.user_preferences.clock_visible);
}
// Finds the `.window` element for the given app instance ID
window.window_for_app_instance = (instance_id) => {
return $(`.window[data-element_uuid="${instance_id}"]`).get(0);
};
// Finds the `iframe` element for the given app instance ID
window.iframe_for_app_instance = (instance_id) => {
return $(window_for_app_instance(instance_id)).find('.window-app-iframe').get(0);
};