PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_Progress2 » Bug #8684

Problem with generated JavaScript.

Details

Submitted2006-09-13 11:35 UTC
Fromipa at assis dot lt
Assignedfarell
StatusClosed
PackageHTML_Progress2
PHP VersionIrrelevant
OSAll
Roadmaps(Not assigned)

Comments

[2006-09-13 11:35 UTC] ipa at assis dot lt

Description:
------------
In generated Javascript functions variable `name` is not in local scope. Therefore beeing global, that functions modify window.name property. In that case it can brake HTML links from working properly.

Test script:
---------------
HTML_Progress2 generates:

function showCell(pCell, pIdent, pVisibility)
{
name = '%progressCell%' + pCell + 'A' + pIdent;
document.getElementById(name).style.visibility = pVisibility;
}

function hideProgress(pIdent, pCellCount)
{
name = 'tfrm' + pIdent;
document.getElementById(name).style.visibility = 'hidden';
for (i = 0; i < pCellCount; i++) {
showCell(i, pIdent, 'hidden');
}
}

function setLabelText(pIdent, pName, pText)
{
name = 'plbl' + pName + pIdent;
document.getElementById(name).firstChild.nodeValue = pText;
}

function setElementStyle(pPrefix, pName, pIdent, pStyles)
{
name = pPrefix + pName + pIdent;
styles = pStyles.split(';');
styles.pop();
for (i = 0; i < styles.length; i++)
{
s = styles[i].split(':');
c = 'document.getElementById(name).style.' + s[0] + '="' + s[1] + '"';
eval(c);
}
}

function setRotaryCross(pIdent, pName)
{
name = 'plbl' + pName + pIdent;
cross = document.getElementById(name).firstChild.nodeValue;
switch(cross) {
case "--": cross = "\\\\"; break;
case "\\\\": cross = "|"; break;
case "|": cross = "/"; break;
default: cross = "--"; break;
}
document.getElementById(name).firstChild.nodeValue = cross;
}

Expected result:
----------------
The same scripts, but insted of
"name =..." there should be "var name = ..."

[2006-09-14 12:06 UTC] ipa at assis dot lt

It's to long to produce real example with HTML_Progress2 but i make a short one to ilustrate the problem which appears in the package using global name property:
index.html
====================
<html>
<body>
<iframe name="frameWithProgress" src=""></iframe>

<p><a href="http://www.google.com" target="frameWithProgress">Step 1. Shows that target works</a></p>

<p><a href="progress.html" target="frameWithProgress">Step 2. Loading a page with progress</a></p>

<p><a href="http://www.google.com" target="frameWithProgress">Step 3. Same as Step 1, A link must go to that iframe,
but doesn't in IE and Opera. FF seems to works</a></p>
</body>
</html>

progress.html
====================
<html>
<body>
<script>
// Function contents doesn't matter, just setting the global name property
function anyFunction()
{
name = 'anything';
}

// we need only to run it
anyFunction();
</script>
I'm an example to brake the target (by changing window.name property)

</body>
</html>