Commit e31b59ec authored by Robert Ricci's avatar Robert Ricci

A few new simple javascript functions to manage the window.onload

variable - we have lots of javascript that wants to install its
intiailization code there, and these functions just provide a simple
mechanism for doing that. So. From now on:

    Thou Shalt Not Mess With window.onload Or window.onunload Directly.
    Instead, Thou Shalt Call addLoadFunction() and addUnloadFunction().
parent 1f544b22
......@@ -205,11 +205,5 @@ if (window.addEventListener) {
} else if (window.attachEvent) {
window.attachEvent('onload', InlineConsole.addConsole);
} else {
window.onload = (function() {
var nextfn = window.onload || function(){};
return function() {
addConsole();
nextfn();
}
})();
addLoadFunction(addConsole());
}
......@@ -1318,10 +1318,8 @@ function SET_DHTML()
dd.n4? d_o.oimg.src = spacer : d_o.oimg.style.visibility = 'hidden';
}
dd.mkWzDom();
if(window.onload) dd.loadFunc = window.onload;
if(window.onunload) dd.uloadFunc = window.onunload;
window.onload = dd.initz;
window.onunload = dd.finlz;
addLoadFunction(dd.initz);
addUnloadFunction(dd.finlz);
dd.setDwnHdl(PICK);
}
function ADD_DHTML(d_o) // layers only!
......
......@@ -829,6 +829,10 @@ function PAGEBEGINNING( $title, $nobanner = 0, $nocontent = 0,
echo "<meta name=\"description\" ".
"content=\"emulab - network emulation testbed home\">\n";
}
# This needs to stay first! It defines things that might get used by
# later scripts
echo "<script type='text/javascript'
src='${BASEPATH}/onload.js'></script>\n";
if ($extra_headers) {
echo $extra_headers;
}
......
......@@ -48,13 +48,9 @@ function GetPNodes_cb(data) {
* event for iframes.
*/
if (is_safari) {
window.onload = (function() {
var nextfn = window.onload || function(){};
return function() {
ml_handleReadyState(LOG_STATE_LOADED);
nextfn();
}
})();
addLoadFunction(function() {
ml_handleReadyState(LOG_STATE_LOADED);
});
}
/* Clear the various 'loading' indicators. */
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2009 University of Utah and the Flux Group.
* All rights reserved.
*/
/*
* Simple funciton to handle multiple onload/onunload events
*/
var LOADFUNCTIONS = [];
var UNLOADFUNCTIONS = [];
function addLoadFunction(func) {
LOADFUNCTIONS.push(func);
}
function addUnloadFunction(func) {
UNLOADFUNCTIONS.push(func);
}
/*
* Just loop through our arrays calling all of the appropriate functions
*/
function callAllLoadFunctions() {
for (var i = 0; i < LOADFUNCTIONS.length; i++) {
LOADFUNCTIONS[i].call();
}
}
function callAllUnloadFunctions() {
for (var i = 0; i < UNLOADFUNCTIONS.length; i++) {
UNLOADFUNCTIONS[i].call();
}
}
/*
* Set the onload and onunload functions to the ones we just made
*/
window.onload = callAllLoadFunctions;
window.onunload = callAllUnloadFunctions;
......@@ -245,7 +245,7 @@ function init() {
//divflipvis('selectiondiv');
}
window.onload = init;
addLoadFunction(init);
function setElementValue(id,value) {
if (id == null) {
......
......@@ -700,7 +700,7 @@ function init() {
refresh(resource);
}
window.onload = init;
addLoadFunction(init);
window.onresize = resizeVizForceRedraw;
</script>
......
......@@ -366,7 +366,7 @@ if (/WebKit/i.test(navigator.userAgent)) { // sniff
}
/* for other browsers */
window.onload = sorttable.init;
addLoadFunction(sorttable.init);
// written by Dean Edwards, 2005
// with input from Tino Zijdel, Matthias Miller, Diego Perini
......
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