From 31c064b012c72c7d1f7296717e73f89e11eb30a8 Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Mon, 14 Oct 2024 13:18:48 +0200 Subject: [PATCH] only save screen size when not iframed --- .../panorama/root/js/panorama_js_functions.js | 2 +- .../panorama/templates/panorama_js.tt | 2 +- root/thruk/javascript/thruk-3.18.js | 21 ++++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/plugins/plugins-available/panorama/root/js/panorama_js_functions.js b/plugins/plugins-available/panorama/root/js/panorama_js_functions.js index f3dde77120..f0b389bbb0 100644 --- a/plugins/plugins-available/panorama/root/js/panorama_js_functions.js +++ b/plugins/plugins-available/panorama/root/js/panorama_js_functions.js @@ -1256,7 +1256,7 @@ var TP = { /* called on body unload */ unload: function() { TP.isUnloading = true; - cookieSave("thruk_screen", JSON.stringify(getScreenData())); + cookieSaveScreenSize(); }, deleteDowntime: function(id, panelId, type) { var panel = Ext.getCmp(panelId); diff --git a/plugins/plugins-available/panorama/templates/panorama_js.tt b/plugins/plugins-available/panorama/templates/panorama_js.tt index 98766b3d43..883b1d3e79 100644 --- a/plugins/plugins-available/panorama/templates/panorama_js.tt +++ b/plugins/plugins-available/panorama/templates/panorama_js.tt @@ -27,7 +27,7 @@ Ext.QuickTips.init(); Ext.onReady(function() { cookieSave("thruk_tz", getBrowserTimezone()); - cookieSave("thruk_screen", JSON.stringify(getScreenData())); + cookieSaveScreenSize(); /* main viewport */ if(one_tab_only) { diff --git a/root/thruk/javascript/thruk-3.18.js b/root/thruk/javascript/thruk-3.18.js index 49135faed0..17beb38549 100644 --- a/root/thruk/javascript/thruk-3.18.js +++ b/root/thruk/javascript/thruk-3.18.js @@ -142,12 +142,12 @@ function init_page() { // store browsers timezone in a cookie so we can use it in later requests cookieSave("thruk_tz", getBrowserTimezone()); - cookieSave("thruk_screen", JSON.stringify(getScreenData())); + cookieSaveScreenSize(); jQuery(document).off("resize").on("resize", function() { - cookieSave("thruk_screen", JSON.stringify(getScreenData())); + cookieSaveScreenSize(); }); jQuery(window).off("resize").on("resize", function() { - cookieSave("thruk_screen", JSON.stringify(getScreenData())); + cookieSaveScreenSize(); }); /* show calendar popups for these */ @@ -287,6 +287,21 @@ function init_page() { } catch(err) { console.log(err); } } +function cookieSaveScreenSize() { + if(inIframe()) { + return; + } + cookieSave("thruk_screen", JSON.stringify(getScreenData())); +} + +function inIframe () { + try { + return window.self !== window.top; + } catch (e) { + return true; + } +} + function initLastUserInteraction() { jQuery(window) .off("mousewheel DOMMouseScroll click keyup")