From b03f6fae6d038fba04222e1f124fa09181a88802 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 17 Apr 2024 10:08:42 +0100 Subject: [PATCH] Extract some helper functions for accessing a window/iframe by uuid --- src/IPC.js | 8 -------- src/helpers.js | 12 +++++++++++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/IPC.js b/src/IPC.js index f8aad660..dbe18eb1 100644 --- a/src/IPC.js +++ b/src/IPC.js @@ -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'); diff --git a/src/helpers.js b/src/helpers.js index f9504ca4..5c0ff66a 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -3512,4 +3512,14 @@ window.change_clock_visible = (clock_visible) => { } $('select.change-clock-visible').val(window.user_preferences.clock_visible); -} \ No newline at end of file +} + +// 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); +};