From 0deaab7c1acc0df31c8985130d98aa38bf12e01d Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Thu, 12 Jul 2012 13:07:48 +0000 Subject: [PATCH] Improvements to resizing JS in iframed app container pages --- apps/routerconsole/jsp/i2ptunnelmgr.jsp | 14 +++++++++----- apps/routerconsole/jsp/torrents.jsp | 13 ++++++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/apps/routerconsole/jsp/i2ptunnelmgr.jsp b/apps/routerconsole/jsp/i2ptunnelmgr.jsp index dc388f28c2..5db19465ff 100644 --- a/apps/routerconsole/jsp/i2ptunnelmgr.jsp +++ b/apps/routerconsole/jsp/i2ptunnelmgr.jsp @@ -21,16 +21,20 @@ var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>"; function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); } function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000); } + function injectClass(f) { + f.className += ' iframed'; + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + doc.body.className += ' iframed'; + doc.getElementsByClassName('panel')[0].className += ' iframed'; + } function resizeFrame(f) { - var body = f.contentWindow.document.body, - html = f.contentWindow.document.documentElement; - f.style.height = body.scrollHeight + "px"; + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + f.style.height = doc.body.offsetHeight + "px"; } - function injectClass(f) { f.contentWindow.document.body.setAttribute('class', 'iframed'); } function setupFrame() { f = document.getElementById("i2ptunnelframe"); - resizeFrame(f); injectClass(f); + resizeFrame(f); } </script> </head><body onload="initAjax()"> diff --git a/apps/routerconsole/jsp/torrents.jsp b/apps/routerconsole/jsp/torrents.jsp index 690be49a5a..ed052ace0c 100644 --- a/apps/routerconsole/jsp/torrents.jsp +++ b/apps/routerconsole/jsp/torrents.jsp @@ -21,12 +21,19 @@ var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>"; function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); } function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000); } - function resizeFrame(f) { f.style.height = f.contentWindow.document.body.scrollHeight + "px"; } - function injectClass(f) { f.contentWindow.document.body.setAttribute('class', 'iframed'); } + function injectClass(f) { + f.className += ' iframed'; + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + doc.body.className += ' iframed'; + } + function resizeFrame(f) { + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + f.style.height = doc.body.offsetHeight + "px"; + } function setupFrame() { f = document.getElementById("i2psnarkframe"); - resizeFrame(f); injectClass(f); + resizeFrame(f); } </script> </head><body onload="initAjax()"> -- GitLab