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 04a641adc2
commit b03f6fae6d
2 changed files with 11 additions and 9 deletions

View File

@ -74,14 +74,6 @@ window.addEventListener('message', async (event) => {
return; 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 $el_parent_window = $(window_for_app_instance(event.data.appInstanceID));
const parent_window_id = $el_parent_window.attr('data-id'); const parent_window_id = $el_parent_window.attr('data-id');
const $el_parent_disable_mask = $el_parent_window.find('.window-disable-mask'); const $el_parent_disable_mask = $el_parent_window.find('.window-disable-mask');

View File

@ -3512,4 +3512,14 @@ window.change_clock_visible = (clock_visible) => {
} }
$('select.change-clock-visible').val(window.user_preferences.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);
};