printComponentTabs.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var strgURL = location.pathname; // path of current component
  2. // constuctor for the array of objects
  3. function tabElement(id, folderName, tabTxt ) {
  4. this.id = id; // elementID as needed in html;
  5. this.folderName = folderName; // folder name of the component
  6. this.tabTxt = tabTxt; // Text displayed as menu on the web
  7. this.currentListItem = '<li id="' + this.id + '" class="current"> <a href="../..' + this.folderName + 'index.html"><span>' + this.tabTxt + '</span></a></li>';
  8. this.listItem = '<li id="' + this.id + '"> <a href="../..' + this.folderName + 'index.html"><span>' + this.tabTxt + '</span></a></li>';
  9. };
  10. // array of objects
  11. var arr = [];
  12. // fill array
  13. arr.push( new tabElement( "GEN", "/General/html/", "General") );
  14. arr.push( new tabElement( "CORE_A", "/Core_A/html/", "Core(A)") );
  15. arr.push( new tabElement( "CORE_M", "/Core/html/", "Core(M)") );
  16. arr.push( new tabElement( "DRV", "/Driver/html/", "Driver") );
  17. arr.push( new tabElement( "DSP&ML", "/DSP/html/", "DSP") );
  18. arr.push( new tabElement( "NN", "/NN/html/", "NN") );
  19. arr.push( new tabElement( "RTOSv1", "/RTOS/html/", "RTOS v1") );
  20. arr.push( new tabElement( "RTOSv2", "/RTOS2/html/", "RTOS v2") );
  21. arr.push( new tabElement( "PACK", "/Pack/html/", "Pack") );
  22. arr.push( new tabElement( "Build", "/Build/html/", "Build") );
  23. arr.push( new tabElement( "SVD", "/SVD/html/", "SVD") );
  24. arr.push( new tabElement( "DAP", "/DAP/html/", "DAP") );
  25. arr.push( new tabElement( "ZONE", "/Zone/html/", "Zone") );
  26. // write tabs
  27. // called from the header file.
  28. function writeComponentTabs() {
  29. for ( var i=0; i < arr.length; i++ ) {
  30. if (strgURL.search(arr[i].folderName) > 0) { // if this is the current folder
  31. document.write(arr[i].currentListItem); // then print and hightlight the tab
  32. } else {
  33. document.write(arr[i].listItem); // else, print the tab
  34. }
  35. }
  36. };