Skip to content

Commit 5ba157e

Browse files
LunCh-CECNLLunCh-CECNL
andauthored
Fix parameter naming conflict in js (#275)
Co-authored-by: LunCh-CECNL <[email protected]>
1 parent d59cbfe commit 5ba157e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/TemplateRender.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,8 +2452,10 @@ protected function drawJavascriptRandomPasswordAttribute($attribute) {
24522452

24532453
printf("\n<!-- %s -->\n",__METHOD__);
24542454
echo '<script type="text/javascript">'."\n";
2455-
echo 'var i = 0;'."\n";
2456-
printf('var component = document.getElementById(\'new_values_%s_\'+i);',$attribute->getName());
2455+
$index_name = $attribute->getName().'_index';
2456+
printf('var %s = 0;',$index_name);
2457+
echo "\n";
2458+
printf('var component = document.getElementById(\'new_values_%s_\'+%s);',$attribute->getName(),$index_name);
24572459
echo "\n";
24582460
echo 'while (component) {'."\n";
24592461
echo ' if (!component.value) {'."\n";
@@ -2462,11 +2464,8 @@ protected function drawJavascriptRandomPasswordAttribute($attribute) {
24622464
printf(' alert(\'%s:\n%s\');',_('A random password was generated for you'),$pwd);
24632465
echo "\n";
24642466
echo ' };'."\n";
2465-
echo ' i++;'."\n";
2466-
printf(' component = document.getElementById(\'new_values_%s_\'+i);',$attribute->getName());
2467-
echo "\n";
2468-
# It seems that JS gets stuck in a loop if there isnt a command here? - normally this alert isnt shown.
2469-
printf('alert("It seems another element was found, PLA hasnt been configured for this situation Component: "+component.value+" I:"+i);',$attribute->getName());
2467+
printf(' %s++;'."\n", $index_name);
2468+
printf(' component = document.getElementById(\'new_values_%s_\'+%s);',$attribute->getName(),$index_name);
24702469
echo "\n";
24712470
echo '}'."\n";
24722471
echo '</script>';

0 commit comments

Comments
 (0)