John Dalberg said:
Not a very good example, because your news client broke the
lines. That means that the code we see is not even syntactically
correct Javascript, and we will have to work harder to just make it
correct again, before we can start solving the problem.
As for the method:
Take that code, and put it into another file. Write these lines before
the code:
<script type="text/javascript">
function foo(){
and this after:
};
document.write("<pre>"+foo.toString()+"<\/pre>");
</script>
and load it into your browser as an HTML file. Use cut'n'paste to
pick out the area between
function foo() {
and
}
In Opera it makes the blocks structure much clearer. In IE it doesn't
help that much. Mozilla FireFox is by far the prettiest, with
indentation and everything. Your code, as displayed by FireFox, is
here (if the lines are broken, check your newsreader):
---
var cspbDetectedBrowser = "IE5DHTML";
var cspbVS = "cspbPanelBarLoading";
var cspbGD = new Object();
var cspbFO = true;
var cspbTL = 0;
var cspbTD = 0;
var cspbGDH = 0;
var cspbEIA = false;
function cspbShowSection() {
if (cspbEIA) {
return;
}
if (cspbVS == "cspbPanelBarLoading") {
document.all.cspbButtons.style.display = "inline";
document.all[cspbVS].style.display = "none";
cspbVS = "";
}
var count = 0;
for (count = 0; count < arguments.length; count++) {
var id = arguments[count];
if (typeof (id) == "string") {
id = cspbGetGroupIndex(id);
}
if (document.all["cspbGroup" + id]) {
cspbGD = document.all["cspbGroup" + id];
if (cspbGD.style.display == "inline") {
document.all["cspbBtnCell" + id].className = "cspbBtnCell";
if (navigator.platform != "MacPPC") {
cspbGDH = cspbGD.offsetHeight;
cspbEC(0);
} else {
cspbGD.style.display = "none";
}
} else {
document.all["cspbBtnCell" + id].className = "cspbBtnCellSlt";
cspbGD.style.display = "inline";
if (!cspbFO && navigator.platform != "MacPPC") {
cspbGDH = cspbGD.offsetHeight;
cspbGD.style.height = 1;
cspbEO(cspbGDH);
}
}
}
}
cspbFO = false;
}
function cspbGetGroupIndex(caption) {
var aCaptions = new Array();
aCaptions[0] = "Customers";
aCaptions[1] = "Orders";
aCaptions[2] = "Orders2";
aCaptions[3] = "About Us";
var count = 0;
for (count = 0; count < aCaptions.length; count++) {
if (aCaptions[count] == caption) {
return count;
}
}
return 0;
}
function cspbHBT(id) {
document.all["cspbBtnText" + id].className = "cspbBtnHvr";
}
function cspbDBT(id) {
document.all["cspbBtnText" + id].className = "cspbBtn";
}
function cspbEO(l) {
var RES = 3;
cspbEIA = true;
cspbTL = l;
if (cspbTL == 0) {
cspbGD.style.height = cspbGDH;
cspbEIA = false;
} else {
if (cspbTL <= RES) {
cspbTD = 1;
} else {
cspbTD = parseInt(cspbTL / RES);
}
if (cspbGDH != cspbTL) {
cspbGD.style.height = cspbGDH - cspbTL;
}
setTimeout("cspbEO(cspbTL-cspbTD);", 25);
}
}
function cspbEC(l) {
var RES = 6;
cspbEIA = true;
cspbTL = l;
if (cspbGDH == cspbTL) {
cspbGD.style.display = "none";
cspbGD.style.height = cspbGDH;
cspbEIA = false;
} else {
if ((cspbGDH - cspbTL) <= RES) {
cspbTD = 1;
} else {
cspbTD = parseInt((cspbGDH - cspbTL) / RES);
}
cspbGD.style.height = cspbGDH - cspbTL;
setTimeout("cspbEC(cspbTL+cspbTD);", 10);
}
}
function cspbRefresh() {
}
function cspbSetHeight(px) {
}
var cspbFSTID;
var cspbFSIID;
var cspbFSE = false;
function cspbWSEH() {
if (cspbFSE == true) {
clearTimeout(cspbFSTID);
cspbFSTID = window.setTimeout("cspbSFSI();", 200);
} else {
if ((navigator.userAgent.indexOf("MSIE") > -1) &&
(navigator.platform != "MacPPC")) {
cspbFSE = true;
}
}
}
function cspbSFSI() {
clearInterval(cspbFSIID);
cspbFSIID = window.setInterval("cspbFS();", 1);
}
function cspbFS() {
var scrollTop = parseInt(document.body.scrollTop) + 0;
var PBTop = parseInt(document.all.cspbPanelBar.style.top);
if (scrollTop == PBTop) {
clearInterval(cspbFSIID);
} else {
if (PBTop < scrollTop) {
if ((scrollTop - PBTop) <= 6) {
document.all.cspbPanelBar.style.top = PBTop + 1;
} else {
document.all.cspbPanelBar.style.top = parseInt(PBTop + ((scrollTop - PBTop) / 6));
}
} else {
if ((PBTop - scrollTop) <= 6) {
document.all.cspbPanelBar.style.top = PBTop - 1;
} else {
document.all.cspbPanelBar.style.top = parseInt(PBTop - ((PBTop - scrollTop) / 6));
}
}
}
}
function cspbASH() {
var e = window.onscroll;
if (typeof (e) == "function") {
e = e.toString();
e = e.substring(e.indexOf("{") + 1, e.lastIndexOf("}"));
var f = cspbWindowScroll.toString();
f = f.substring(f.indexOf("{") + 1, f.lastIndexOf("}"));
var sh = new Function(f + e);
window.onscroll = sh;
} else {
window.onscroll = cspbWSEH;
}
}
if (navigator.platform != "MacPPC") {
this.attachEvent("onscroll", cspbWSEH);
}