1 | function initMenu(relPath,searchEnabled,serverSide,searchPage,search) { |
||
2 | function makeTree(data,relPath) { |
||
3 | var result=''; |
||
4 | if ('children' in data) { |
||
5 | result+='<ul>'; |
||
6 | for (var i in data.children) { |
||
0 ignored issues
–
show
|
|||
7 | result+='<li><a href="'+relPath+data.children[i].url+'">'+ |
||
8 | data.children[i].text+'</a>'+ |
||
9 | makeTree(data.children[i],relPath)+'</li>'; |
||
10 | } |
||
11 | result+='</ul>'; |
||
12 | } |
||
13 | return result; |
||
14 | } |
||
15 | |||
16 | $('#main-nav').append(makeTree(menudata,relPath)); |
||
0 ignored issues
–
show
The variable
menudata seems to be never declared. If this is a global, consider adding a /** global: menudata */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. ![]() |
|||
17 | $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu'); |
||
18 | if (searchEnabled) { |
||
19 | if (serverSide) { |
||
20 | $('#main-menu').append('<li style="float:right"><div id="MSearchBox" class="MSearchBoxInactive"><div class="left"><form id="FSearchBox" action="'+searchPage+'" method="get"><img id="MSearchSelect" src="'+relPath+'search/mag.png" alt=""/><input type="text" id="MSearchField" name="query" value="'+search+'" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)"></form></div><div class="right"></div></div></li>'); |
||
21 | } else { |
||
22 | $('#main-menu').append('<li style="float:right"><div id="MSearchBox" class="MSearchBoxInactive"><span class="left"><img id="MSearchSelect" src="'+relPath+'search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/><input type="text" id="MSearchField" value="'+search+'" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/></span><span class="right"><a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="'+relPath+'search/close.png" alt=""/></a></span></div></li>'); |
||
23 | } |
||
24 | } |
||
25 | $('#main-menu').smartmenus(); |
||
26 | } |
||
27 |
When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically: