Commit 62f88b85 authored by Leigh Stoller's avatar Leigh Stoller

Futzing with cross-browser support in the hope I could get Safari to

do the right thing. No such luck, giving up for now ...
parent c5749e35
......@@ -193,33 +193,6 @@ if (!isset($SAJAX_INCLUDED)) {
sajax_debug(func_name + " waiting..");
delete x;
}
function getObjbyName(name) {
if (document.getElementById) {
return document.getElementById(name);
}
else if (document.all) {
return document.all[name];
}
else if (document.layers) {
return getObjNN4(document,name);
}
return null;
}
function getObjNN4(obj,name) {
var x = document.layers;
var foundLayer;
for (var i=0; i < x.length; i++) {
if (x[i].id == name)
foundLayer = x[i];
else if (x[i].layers.length)
var tmp = getObjNN4(x[i],name);
if (tmp) foundLayer = tmp;
}
return foundLayer;
}
<?php
$html = ob_get_contents();
ob_end_clean();
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2006 University of Utah and the Flux Group.
* Copyright (c) 2006, 2007 University of Utah and the Flux Group.
* All rights reserved.
*/
/*
......@@ -10,8 +10,8 @@
/* Clear the various 'loading' indicators. */
function ClearLoadingIndicators(done_msg)
{
var busyimg = document.getElementById('busy');
var loadingspan = document.getElementById('loading');
var busyimg = getObjbyName('busy');
var loadingspan = getObjbyName('loading');
loadingspan.innerHTML = done_msg;
busyimg.style.display = "none";
......@@ -31,11 +31,16 @@ function PageReplace(URL)
function IframeDocument(id)
{
var oIframe = document.getElementById(id);
var oIframe = getObjbyName(id);
var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
if (oIframe.document) {
// Safari
return oIframe.document;
}
if (oDoc.document) {
oDoc = oDoc.document;
return oDoc.document;
}
return oDoc;
}
......@@ -65,7 +70,7 @@ function GraphChange(which) {
}
function GetMaxHeight(id) {
var Iframe = document.getElementById(id);
var Iframe = getObjbyName(id);
var winheight = 0;
var yoff = 0;
......@@ -95,7 +100,7 @@ function GetMaxHeight(id) {
}
function SetupOutputArea(id) {
var Iframe = document.getElementById(id);
var Iframe = getObjbyName(id);
var IframeDoc = IframeDocument(id);
var winheight = GetMaxHeight(id);
......@@ -111,7 +116,7 @@ function SetupOutputArea(id) {
}
function HideFrame(id) {
var Iframe = document.getElementById(id);
var Iframe = getObjbyName(id);
var IframeDoc = IframeDocument(id);
Iframe.style.border = "0px none";
......@@ -122,7 +127,7 @@ function HideFrame(id) {
}
function ShowDownLoader(id) {
var Iframe = document.getElementById(id);
var Iframe = getObjbyName(id);
var IframeDoc = IframeDocument(id);
var winheight = 0;
......@@ -161,8 +166,8 @@ function ShowDownLoader(id) {
/* @return The innerHeight of the window. */
function getInnerHeight(id) {
var retval;
var win = document.getElementById(id).contentWindow;
var doc = document.getElementById(id).contentWindow.document;
var win = getObjbyName(id).contentWindow;
var doc = getObjbyName(id).contentWindow.document;
if (win.innerHeight)
// all except Explorer
......@@ -180,8 +185,8 @@ function getInnerHeight(id) {
/* @return The scrollTop of the window. */
function getScrollTop(id) {
var retval;
var win = document.getElementById(id).contentWindow;
var doc = document.getElementById(id).contentWindow.document;
var win = getObjbyName(id).contentWindow;
var doc = getObjbyName(id).contentWindow.document;
if (win.pageYOffset)
// all except Explorer
......@@ -199,8 +204,8 @@ function getScrollTop(id) {
/* @return The height of the document. */
function getScrollHeight(id) {
var retval;
var win = document.getElementById(id).contentWindow;
var doc = document.getElementById(id).contentWindow.document;
var win = getObjbyName(id).contentWindow;
var doc = getObjbyName(id).contentWindow.document;
var test1 = doc.body.scrollHeight;
var test2 = doc.body.offsetHeight;
......@@ -221,7 +226,7 @@ var lastLine = ""; // The last line of the download text.
var firstLine = 1; // Flag.
function WriteOutputText(id, stuff) {
var Iframe = document.getElementById(id);
var Iframe = getObjbyName(id);
var idoc = IframeDocument(id);
var output = idoc.getElementById('outputarea');
......@@ -304,7 +309,7 @@ function GetInnerText(el) {
* tags (mozilla, IE), they will be stripped.
*/
function GetInputText(id) {
var ifr = document.getElementById(id);
var ifr = getObjbyName(id);
var retval = null;
try {
......@@ -357,3 +362,32 @@ function StopOutput() {
LookforOutput();
}
/*
* Cross browser support for finding objects by id.
*/
function getObjbyName(name) {
if (document.getElementById) {
return document.getElementById(name);
}
else if (document.all) {
return document.all[name];
}
else if (document.layers) {
return getObjNN4(document,name);
}
return null;
}
function getObjNN4(obj,name) {
var x = document.layers;
var foundLayer;
for (var i=0; i < x.length; i++) {
if (x[i].id == name)
foundLayer = x[i];
else if (x[i].layers.length)
var tmp = getObjNN4(x[i],name);
if (tmp) foundLayer = tmp;
}
return foundLayer;
}
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2006 University of Utah and the Flux Group.
* Copyright (c) 2006, 2007 University of Utah and the Flux Group.
* All rights reserved.
*/
var LOG_STATE_LOADING = 1;
......@@ -91,9 +91,17 @@ function ml_getBodyText(ifr) {
var retval = null;
try {
var oDoc = (ifr.contentWindow || ifr.contentDocument);
if (oDoc.document) {
oDoc = oDoc.document;
var oDoc;
if (ifr.document) {
// Safari
oDoc = ifr.document;
}
else {
oDoc = (ifr.contentWindow || ifr.contentDocument);
if (oDoc.document) {
oDoc = oDoc.document;
}
}
for (lpc = 0; lpc < oDoc.childNodes.length; lpc++) {
text = ml_getInnerText(oDoc.childNodes[lpc]);
......@@ -116,8 +124,8 @@ function ml_getBodyText(ifr) {
/* @return The innerHeight of the window. */
function ml_getInnerHeight() {
var retval;
var win = document.getElementById('outputframe').contentWindow;
var doc = document.getElementById('outputframe').contentWindow.document;
var win = getObjbyName('outputframe').contentWindow;
var doc = getObjbyName('outputframe').contentWindow.document;
if (win.innerHeight) // all except Explorer
retval = win.innerHeight;
......@@ -133,8 +141,8 @@ function ml_getInnerHeight() {
/* @return The scrollTop of the window. */
function ml_getScrollTop() {
var retval;
var win = document.getElementById('outputframe').contentWindow;
var doc = document.getElementById('outputframe').contentWindow.document;
var win = getObjbyName('outputframe').contentWindow;
var doc = getObjbyName('outputframe').contentWindow.document;
if (win.pageYOffset) // all except Explorer
retval = win.pageYOffset;
......@@ -149,8 +157,8 @@ function ml_getScrollTop() {
/* @return The height of the document. */
function ml_getScrollHeight() {
var retval;
var win = document.getElementById('outputframe').contentWindow;
var doc = document.getElementById('outputframe').contentWindow.document;
var win = getObjbyName('outputframe').contentWindow;
var doc = getObjbyName('outputframe').contentWindow.document;
var test1 = doc.body.scrollHeight;
var test2 = doc.body.offsetHeight;
......@@ -170,10 +178,10 @@ function ml_getScrollHeight() {
* @param state The state of the download.
*/
function ml_handleReadyState(state) {
var Iframe = document.getElementById('outputframe');
var Iframe = getObjbyName('outputframe');
var idoc = IframeDocument('outputframe');
var oa = idoc.getElementById('outputarea');
var dl = document.getElementById('downloader');
var dl = getObjbyName('downloader');
if (docTriesLeft < 0) {
/* Already decided we were broken; just ignore */
......
......@@ -117,9 +117,10 @@ function STARTLOG($experiment)
echo "</center>\n";
echo "<br>\n";
echo "<div><iframe id='outputframe' src='busy.gif' ".
"width=100% height=600 scrolling=auto border=4></iframe></div>\n";
echo "<div><iframe id='outputframe' name='outputframe' ".
"width='100%' height='600px' overflow='auto' border='4'>".
"</iframe></div>\n";
echo "<script type='text/javascript' language='javascript' src='json.js'>
</script>".
"<script type='text/javascript' language='javascript'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment