forked from I2P_Developers/i2p.i2p
Consolidated the common iframing JS into /js/iframed.js
This commit is contained in:
@ -17,47 +17,11 @@
|
|||||||
<%@include file="css.jsi" %>
|
<%@include file="css.jsi" %>
|
||||||
<%=intl.title("addressbook")%>
|
<%=intl.title("addressbook")%>
|
||||||
<script src="/js/ajax.js" type="text/javascript"></script>
|
<script src="/js/ajax.js" type="text/javascript"></script>
|
||||||
|
<script src="/js/iframed.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
|
var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
|
||||||
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
||||||
function initAjax() { setTimeout(requestAjax1, <%=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';
|
|
||||||
}
|
|
||||||
function resizeFrame(f) {
|
|
||||||
// offsetHeight returns the height of the visible area for an object, in pixels.
|
|
||||||
// The value contains the height with the padding, scrollBar, and the border,
|
|
||||||
// but does not include the margin. Therefore, any content within the iframe
|
|
||||||
// should have no margins at the very top or very bottom to avoid a scrollbar.
|
|
||||||
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
|
|
||||||
var totalHeight = doc.body.offsetHeight;
|
|
||||||
|
|
||||||
// Detect if horizontal scrollbar is present, and add its width to height if so.
|
|
||||||
// This prevents a vertical scrollbar appearing when the min-width is passed.
|
|
||||||
// FIXME: How to detect horizontal scrollbar in iframe? Always apply for now.
|
|
||||||
if (true) {
|
|
||||||
// Create the measurement node
|
|
||||||
var scrollDiv = document.createElement("div");
|
|
||||||
scrollDiv.className = "scrollbar-measure";
|
|
||||||
scrollDiv.style.width = "100px";
|
|
||||||
scrollDiv.style.height = "100px";
|
|
||||||
scrollDiv.style.overflow = "scroll";
|
|
||||||
scrollDiv.style.position = "absolute";
|
|
||||||
scrollDiv.style.top = "-9999px";
|
|
||||||
document.body.appendChild(scrollDiv);
|
|
||||||
|
|
||||||
// Get the scrollbar width
|
|
||||||
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
||||||
totalHeight += scrollbarWidth;
|
|
||||||
|
|
||||||
// Delete the div
|
|
||||||
document.body.removeChild(scrollDiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
f.style.height = totalHeight + "px";
|
|
||||||
}
|
|
||||||
function setupFrame() {
|
function setupFrame() {
|
||||||
f = document.getElementById("susidnsframe");
|
f = document.getElementById("susidnsframe");
|
||||||
injectClass(f);
|
injectClass(f);
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
<%@include file="css.jsi" %>
|
<%@include file="css.jsi" %>
|
||||||
<%=intl.title("i2p tunnel manager")%>
|
<%=intl.title("i2p tunnel manager")%>
|
||||||
<script src="/js/ajax.js" type="text/javascript"></script>
|
<script src="/js/ajax.js" type="text/javascript"></script>
|
||||||
|
<script src="/js/iframed.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
|
var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
|
||||||
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
||||||
function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000); }
|
function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000); }
|
||||||
function injectClass(f) {
|
function injectClassSpecific(f) {
|
||||||
f.className += ' iframed';
|
|
||||||
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
|
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
|
||||||
if (doc.getElementsByClassName == undefined) {
|
if (doc.getElementsByClassName == undefined) {
|
||||||
doc.getElementsByClassName = function(className)
|
doc.getElementsByClassName = function(className)
|
||||||
@ -41,44 +41,12 @@
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc.body.className += ' iframed';
|
|
||||||
doc.getElementsByClassName('panel')[0].className += ' iframed';
|
doc.getElementsByClassName('panel')[0].className += ' iframed';
|
||||||
}
|
}
|
||||||
function resizeFrame(f) {
|
|
||||||
// offsetHeight returns the height of the visible area for an object, in pixels.
|
|
||||||
// The value contains the height with the padding, scrollBar, and the border,
|
|
||||||
// but does not include the margin. Therefore, any content within the iframe
|
|
||||||
// should have no margins at the very top or very bottom to avoid a scrollbar.
|
|
||||||
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
|
|
||||||
var totalHeight = doc.body.offsetHeight;
|
|
||||||
|
|
||||||
// Detect if horizontal scrollbar is present, and add its width to height if so.
|
|
||||||
// This prevents a vertical scrollbar appearing when the min-width is passed.
|
|
||||||
// FIXME: How to detect horizontal scrollbar in iframe? Always apply for now.
|
|
||||||
if (true) {
|
|
||||||
// Create the measurement node
|
|
||||||
var scrollDiv = document.createElement("div");
|
|
||||||
scrollDiv.className = "scrollbar-measure";
|
|
||||||
scrollDiv.style.width = "100px";
|
|
||||||
scrollDiv.style.height = "100px";
|
|
||||||
scrollDiv.style.overflow = "scroll";
|
|
||||||
scrollDiv.style.position = "absolute";
|
|
||||||
scrollDiv.style.top = "-9999px";
|
|
||||||
document.body.appendChild(scrollDiv);
|
|
||||||
|
|
||||||
// Get the scrollbar width
|
|
||||||
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
||||||
totalHeight += scrollbarWidth;
|
|
||||||
|
|
||||||
// Delete the div
|
|
||||||
document.body.removeChild(scrollDiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
f.style.height = totalHeight + "px";
|
|
||||||
}
|
|
||||||
function setupFrame() {
|
function setupFrame() {
|
||||||
f = document.getElementById("i2ptunnelframe");
|
f = document.getElementById("i2ptunnelframe");
|
||||||
injectClass(f);
|
injectClass(f);
|
||||||
|
injectClassSpecific(f);
|
||||||
resizeFrame(f);
|
resizeFrame(f);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
38
apps/routerconsole/jsp/js/iframed.js
Normal file
38
apps/routerconsole/jsp/js/iframed.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
function injectClass(f) {
|
||||||
|
f.className += ' iframed';
|
||||||
|
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
|
||||||
|
doc.body.className += ' iframed';
|
||||||
|
}
|
||||||
|
function resizeFrame(f) {
|
||||||
|
// offsetHeight returns the height of the visible area for an object, in pixels.
|
||||||
|
// The value contains the height with the padding, scrollBar, and the border,
|
||||||
|
// but does not include the margin. Therefore, any content within the iframe
|
||||||
|
// should have no margins at the very top or very bottom to avoid a scrollbar.
|
||||||
|
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
|
||||||
|
var totalHeight = doc.body.offsetHeight;
|
||||||
|
|
||||||
|
// Detect if horizontal scrollbar is present, and add its width to height if so.
|
||||||
|
// This prevents a vertical scrollbar appearing when the min-width is passed.
|
||||||
|
// FIXME: How to detect horizontal scrollbar in iframe? Always apply for now.
|
||||||
|
if (true) {
|
||||||
|
// Create the measurement node
|
||||||
|
var scrollDiv = document.createElement("div");
|
||||||
|
scrollDiv.className = "scrollbar-measure";
|
||||||
|
scrollDiv.style.width = "100px";
|
||||||
|
scrollDiv.style.height = "100px";
|
||||||
|
scrollDiv.style.overflow = "scroll";
|
||||||
|
scrollDiv.style.position = "absolute";
|
||||||
|
scrollDiv.style.top = "-9999px";
|
||||||
|
document.body.appendChild(scrollDiv);
|
||||||
|
|
||||||
|
// Get the scrollbar width
|
||||||
|
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
||||||
|
totalHeight += scrollbarWidth;
|
||||||
|
|
||||||
|
// Delete the div
|
||||||
|
document.body.removeChild(scrollDiv);
|
||||||
|
}
|
||||||
|
|
||||||
|
f.style.height = totalHeight + "px";
|
||||||
|
}
|
||||||
|
|
@ -17,47 +17,11 @@
|
|||||||
<%@include file="css.jsi" %>
|
<%@include file="css.jsi" %>
|
||||||
<%=intl.title("torrents")%>
|
<%=intl.title("torrents")%>
|
||||||
<script src="/js/ajax.js" type="text/javascript"></script>
|
<script src="/js/ajax.js" type="text/javascript"></script>
|
||||||
|
<script src="/js/iframed.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
|
var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
|
||||||
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
||||||
function initAjax() { setTimeout(requestAjax1, <%=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';
|
|
||||||
}
|
|
||||||
function resizeFrame(f) {
|
|
||||||
// offsetHeight returns the height of the visible area for an object, in pixels.
|
|
||||||
// The value contains the height with the padding, scrollBar, and the border,
|
|
||||||
// but does not include the margin. Therefore, any content within the iframe
|
|
||||||
// should have no margins at the very top or very bottom to avoid a scrollbar.
|
|
||||||
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
|
|
||||||
var totalHeight = doc.body.offsetHeight;
|
|
||||||
|
|
||||||
// Detect if horizontal scrollbar is present, and add its width to height if so.
|
|
||||||
// This prevents a vertical scrollbar appearing when the min-width is passed.
|
|
||||||
// FIXME: How to detect horizontal scrollbar in iframe? Always apply for now.
|
|
||||||
if (true) {
|
|
||||||
// Create the measurement node
|
|
||||||
var scrollDiv = document.createElement("div");
|
|
||||||
scrollDiv.className = "scrollbar-measure";
|
|
||||||
scrollDiv.style.width = "100px";
|
|
||||||
scrollDiv.style.height = "100px";
|
|
||||||
scrollDiv.style.overflow = "scroll";
|
|
||||||
scrollDiv.style.position = "absolute";
|
|
||||||
scrollDiv.style.top = "-9999px";
|
|
||||||
document.body.appendChild(scrollDiv);
|
|
||||||
|
|
||||||
// Get the scrollbar width
|
|
||||||
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
||||||
totalHeight += scrollbarWidth;
|
|
||||||
|
|
||||||
// Delete the div
|
|
||||||
document.body.removeChild(scrollDiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
f.style.height = totalHeight + "px";
|
|
||||||
}
|
|
||||||
function setupFrame() {
|
function setupFrame() {
|
||||||
f = document.getElementById("i2psnarkframe");
|
f = document.getElementById("i2psnarkframe");
|
||||||
injectClass(f);
|
injectClass(f);
|
||||||
|
@ -17,47 +17,11 @@
|
|||||||
<%@include file="css.jsi" %>
|
<%@include file="css.jsi" %>
|
||||||
<%=intl.title("webmail")%>
|
<%=intl.title("webmail")%>
|
||||||
<script src="/js/ajax.js" type="text/javascript"></script>
|
<script src="/js/ajax.js" type="text/javascript"></script>
|
||||||
|
<script src="/js/iframed.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
|
var failMessage = "<hr><b><%=intl._("Router is down")%><\/b>";
|
||||||
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); }
|
||||||
function initAjax() { setTimeout(requestAjax1, <%=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';
|
|
||||||
}
|
|
||||||
function resizeFrame(f) {
|
|
||||||
// offsetHeight returns the height of the visible area for an object, in pixels.
|
|
||||||
// The value contains the height with the padding, scrollBar, and the border,
|
|
||||||
// but does not include the margin. Therefore, any content within the iframe
|
|
||||||
// should have no margins at the very top or very bottom to avoid a scrollbar.
|
|
||||||
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
|
|
||||||
var totalHeight = doc.body.offsetHeight;
|
|
||||||
|
|
||||||
// Detect if horizontal scrollbar is present, and add its width to height if so.
|
|
||||||
// This prevents a vertical scrollbar appearing when the min-width is passed.
|
|
||||||
// FIXME: How to detect horizontal scrollbar in iframe? Always apply for now.
|
|
||||||
if (true) {
|
|
||||||
// Create the measurement node
|
|
||||||
var scrollDiv = document.createElement("div");
|
|
||||||
scrollDiv.className = "scrollbar-measure";
|
|
||||||
scrollDiv.style.width = "100px";
|
|
||||||
scrollDiv.style.height = "100px";
|
|
||||||
scrollDiv.style.overflow = "scroll";
|
|
||||||
scrollDiv.style.position = "absolute";
|
|
||||||
scrollDiv.style.top = "-9999px";
|
|
||||||
document.body.appendChild(scrollDiv);
|
|
||||||
|
|
||||||
// Get the scrollbar width
|
|
||||||
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
|
|
||||||
totalHeight += scrollbarWidth;
|
|
||||||
|
|
||||||
// Delete the div
|
|
||||||
document.body.removeChild(scrollDiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
f.style.height = totalHeight + "px";
|
|
||||||
}
|
|
||||||
function setupFrame() {
|
function setupFrame() {
|
||||||
f = document.getElementById("susimailframe");
|
f = document.getElementById("susimailframe");
|
||||||
injectClass(f);
|
injectClass(f);
|
||||||
|
Reference in New Issue
Block a user