UNPKG

ih-portal

Version:

A project for connecting interaction hub services with catalyst-ui components

33 lines (28 loc) 923 B
/** * [parsePortalTabs description] * @param {[type]} pthomepagetabs [description] * @return {object} tab array and selected tab */ export default function parsePortalTabs() { let tabItems; let selectedIndex = -1; // look for tabs and add href and title to tabItems const pthomepagetabs = document.getElementById('pthomepagetabs'); if (pthomepagetabs !== null) { const listItems = pthomepagetabs.getElementsByTagName('li'); if (listItems !== null) { tabItems = Array.prototype.map.call(listItems, function mapTabList(obj, rank) { const aLink = obj.getElementsByTagName('a'); const aSpanLink = aLink[0].getElementsByTagName('span'); if (obj.id === 'selected') { selectedIndex = rank; } return ({ url: aLink[0].href, title: aSpanLink[0].innerHTML, }); }); } } return ({ tabItems, selectedIndex }); }