var currentSimDate; var currentLanguage; var selectedLevel; var selectedCode; var lineCount; var footnotes; var chapterfootnotes; var innerDate; function getClient() { var xmlhttp=null; try { xmlhttp = new XMLHttpRequest(); } catch (e) {} if (xmlhttp != null) return xmlhttp; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {} if (xmlhttp != null) return xmlhttp; try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) {} return xmlhttp; } /** * MEthod called by the including page. * It is not sure that the level in relation with a code is selecting a node (in case the * user typed directly the prefix of a code or if he modified the code) */ function selectTaricCode(lang, code, level, simDate, descrLang, selectedCodes,textSearch) { innerDate = simDate; resetCounterFootnotes(); selectedLevel = ""; selectedCode = "" var dateChanged = (currentSimDate == null || simDate != currentSimDate); var langChanged = (currentLanguage == null || lang != currentLanguage); if (descrLang == null || descrLang == "") descrLang = lang; if (dateChanged || langChanged) { loadSection(lang, simDate); chaptertree = null; currentSimDate=simDate; currentLanguage=lang; } if (code.length >=2) { while (code.length < 10) code += '0'; var chapterCode = code.substring(0,2)+"00000000"; if (!isChapterLoaded(chapterCode)) { var client = getClient(); client.open("GET", "nomenclaturetree/nomenclaturetree_"+currentLanguage+"_"+currentSimDate+"_"+code.substr(0,2)+"_"+descrLang+".js", false); client.send(null); eval(client.responseText); } var codeObj = getCodeObject(chaptertree, code, level); // Research the code object matching best the code entered by the user while (codeObj == null && code.length >= 2) { codeObj = getCodeObject(chaptertree, code); code = code.substring(0, code.length - 2); } // If really the code entered by the user does not exist (the first two digits does // not correspond to a chapter number if (codeObj == null) updateVisibility(null, null,null,false); else { selectedLevel = codeObj[1]; selectedCode = codeObj[2]; if (level == "-1"){ updateVisibility(codeObj[1], codeObj[2], null,true); } else { updateVisibility(codeObj[1], codeObj[2],selectedCodes,false); } } } else updateVisibility(null, null, null,false); refreshFootnotesToDisplay(); highlightOnLoad(textSearch); } function refreshFootnotesToDisplay() { if(footnotes==null) return; var spans = document.getElementsByTagName("span"); if(spans==null) return; var fn; var parent; for(var i=0; i0); } return false; } function getFootnoteDesc(footnoteRef) { if(footnoteRef==null) return ""; if(footnotes==null) return ""; var array; for(var i=0; i 0 && sectiontree[i][3][0][0] == "false") return "true" else return false; } } return false; } function isChapterCollapsed() { for (var i=0; i= startCode) if (code== null || code != item[2]) codes.push(item[2]); getCodeRangeObject(item[7],item[2], startCode, endCode, codes); }; } return codes; } function getParentObject(list, code, level) { if (list == null) return null; var res = null; for (var i=0; i/i); for (var i = 0 ; i < divs.length; i++) { divs[i] += ""; if (divSection == null) divSection = divs[i].match(//i); if (divCollapseButton == null) divCollapseButton = divs[i].match(//i); if (divChapter == null) divChapter = divs[i].match(//i); if (divLeaf == null) divLeaf = divs[i].match(//i); if (divExpanded == null) divExpanded = divs[i].match(//i); if (divCollapsed == null) divCollapsed = divs[i].match(//i); if (divErnCode == null) divErnCode = divs[i].match(//i); } divSection = divSection[0]; divChapter = divChapter[0]; if (divCollapseButton != null){ divCollapseButton = divCollapseButton[0]; } divLeaf = divLeaf[0]; divExpanded = divExpanded[0]; divCollapsed = divCollapsed[0]; divErnCode = divErnCode[0]; } } /** * Make the section div visible or not */ function enableSectionDiv(flag) { if (flag) { var x=document.getElementById("chapterhierarchy"); x.style.cssText = "visibility:hidden"; var x=document.getElementById("sectionhierarchy"); x.style.cssText = "visibility:visible"; } else { var x=document.getElementById("chapterhierarchy"); x.style.cssText = "visibility:visible"; var x=document.getElementById("sectionhierarchy"); x.style.cssText = "visibility:hidden"; } } /** * Remove all generated DHTML data */ function removeGeneratedHTML() { lineCount = 0; x=document.getElementById("chapterhierarchy"); var cont = true; while (cont) { cont = false; var list = x.childNodes; for (var i=0; i0) { footnoteTable.deleteRow(0); } } /** * Update the chapterhierarchy DIV. Display the section and chapter inforamtion */ function refresh_headers() { for (var i=0; i0) { for (var i = 0 ; i < node[12].length; i++){ ernNode = node[12][i]; if (ernNode !=null){ ernCopy = divErnCode; ernCopy = ernCopy.replace(/visibility:\s*hidden/i, "visibility: visible"); ernCopy = ernCopy.replace(/id\s*=\s*\S+/i, ""); // Delete the id ernCopy = ernCopy.replace(/sid/, "id"); // move sid attribute to id ernCopy = ernReplace(ernCopy, ernNode[0], getErnIndents(ernNode), ernNode[2], ernNode[3], ernNode[4]); ernCopy = addFootnoteToNode(ernNode[5], ernCopy); divContent += ernCopy; } } } } function addFootnoteToNode(node, copy) { if(node == null || node.length <= 0) { if(copy!=null) copy = copy.replace(/\$footnotes\$/g,""); return copy; } var fnModel = document.getElementById("footnote_parenthesis_model"); if(fnModel==null) { copy = copy.replace(/\$footnotes\$/g,""); return copy; } var fnNode = null; var footnoteString = ""; for (var i = 0 ; i < node.length; i++) { fnNode = node[i]; var footnote = fnModel.cloneNode(true); footnoteString += " "+ footnote.innerHTML.replace(/\$footnote_number\$/g,fnNode[1]+fnNode[2]); footnoteString = footnoteString.replace(/\$footnote_ref\$/g,fnNode[1]+fnNode[2]); } copy = copy.replace(/display:\s*none/gi, "display: inline"); copy = copy.replace(/\$footnotes\$/g,footnoteString); return copy; } /** * Parse the node (attributes and children recursively) and replace all occurrence of a placeholder ($level$, * $code$, $indent$, $label$, $description$, $isLeaf$, $trimedCode$, $codeLevel$, $class$, $parentCode$, * $parentLevel$) by * their value in parameters. If present, the sid attribute replaces the id attribute. * Trimed code is the taric code where additional spaces have been added after the fourth, sixth and eighth digit. * codeLevel is the number of significant digits in the code. */ function replacePlaceholders(node, level, code, indent, label, description, isLeaf, trimedCode, codeLevel, clazz, parentCode, parentLevel) { if (node == null) return; switch(node.nodeType) { case 1: // Element var idAttr = node.getAttributeNode('id'); var sidAttr = node.getAttributeNode('sid'); if (sidAttr != null) { if (idAttr != null) node.removeAttributeNode(idAttr); node.setAttribute("id", sidAttr.nodeValue); node.removeAttributeNode(sidAttr); } var children = node.childNodes; for (var i=0; i 8) res = res.substring(0,8)+" " + res.substr(8); if (res.length > 6) res = res.substring(0,6)+" " + res.substr(6); if (res.length > 4) res = res.substring(0,4)+" " + res.substr(4); return res; } function getIndents(node) { var res = ""; for (var i=0; i"; break; case 2: // Attribute if (node.nodeValue != null) res += node.nodeName + "=" + node.nodeValue; break; case 3: // Text res += node.nodeValue; break; case 8: // Comment case 9: // Document } return res; } function nomenclatureBrowserClick(taricCode, anchor, level, expand, callbackUri) { var url = callbackUri + "?Lang="+currentLanguage.toLowerCase(); if(taricCode!=null) url += "&Taric="+taricCode; if(expand==true) url += "&Expand=true"; var area = selectCountry(); if(area!=null) url+= "&Area="+area; if(level!=null) url+= "&Level="+level; if(innerDate!=null) url+="&SimDate="+innerDate; if (document.getElementById("goods_radio").checked) url+="&GoodsText="+document.getElementById("textSearch").value; else url+="&MeasText="+document.getElementById("textSearch").value; url+="&OrderNum="+document.getElementById("OrderNum").value; var date = validateDateFormat(document.getElementById("measStartDat").value); if(date!=null) document.taric_form.StartPub.value = formatDateParam(date); else document.taric_form.StartPub.value = ""; url+="&StartPub="+document.taric_form.StartPub.value; var date = validateDateFormat(document.getElementById("measEndDat").value); if(date!=null) document.taric_form.EndPub.value = formatDateParam(date); else document.taric_form.EndPub.value = ""; url+="&EndPub="+document.taric_form.EndPub.value; url+="&Regulation="+document.getElementById("regulation").value; var measTyp = selectMeasType(); if (measTyp!=null && measTyp.length>0) { url+="&MeasType="+measTyp; } //TODO retrieve the current selected code url+="&LastSelectedCode="+getRecSelectedCodes() if(anchor!=null) url+=anchor; window.location.href = url; } function getRecSelectedCodes(){ var selectedCodes=new Array(); if (chaptertree!= null){ for (var i=0; i