var d8018d6852bc49e3b3e655364cf1439c = { toggle: function (expandable) { var expParent = expandable.parentNode; var img = expParent.querySelector('img'); if (img !== null) { img.addEventListener('click', function (event) { event.stopPropagation(); }); } var target = expParent.querySelector('.content'); if (target !== null) { target.addEventListener('click', function (event) { event.stopPropagation(); }); } var arrow = expParent.querySelector('span.arrow'); if (arrow !== null && target !== null) { if (target.style.display === 'block') { target.style.display = 'none'; arrow.innerHTML = '\u25BA'; } else { target.style.display = 'block'; arrow.innerHTML = '\u25BC'; } } }, showAtLink: function (ele) { if (ele.nextSibling.style.display === 'block') { ele.nextSibling.style.display = 'none'; } else { ele.nextSibling.style.display = 'block'; } }, toggleImg: function (ele) { if (ele.style.maxHeight === 'none') { ele.style.maxHeight = '4em'; } else { ele.style.maxHeight = 'none'; } }, reorderEntryHead: function() { var entryHeads = document.querySelectorAll('.entryhead'); for (var i = 0; i < entryHeads.length; i++) { var head = entryHeads[i]; // Specifically target elements only within this .entryhead var ame = head.querySelector('a[href*="english/ame"], a[href*="hwd/ame"]'); var bre = head.querySelector('a[href*="english/bre"], a[href*="hwd/bre"]'); var hyphenation = head.querySelector('.hyphenation'); // Use child selector to only get .pos that belong to .entryhead var posElements = head.querySelectorAll('.pos'); var directPos = []; for (var k = 0; k < posElements.length; k++) { if (posElements[k].parentNode === head) { directPos.push(posElements[k]); } } // 1. Move direct .pos elements to the very front // Loop backwards to maintain original order (POS 1, POS 2...) for (var j = directPos.length - 1; j >= 0; j--) { head.insertBefore(directPos[j], head.firstChild); } // 2. Place audio links in front of .hyphenation if (hyphenation) { if (bre) head.insertBefore(bre, hyphenation); if (ame) head.insertBefore(ame, bre || hyphenation); } else { // If no hyphenation, place them after the last moved POS element var insertPoint = directPos.length > 0 ? directPos[directPos.length - 1].nextSibling : head.firstChild; if (ame) head.insertBefore(ame, insertPoint); if (bre) head.insertBefore(bre, insertPoint); } } } }; document.addEventListener('DOMContentLoaded', function() { d8018d6852bc49e3b3e655364cf1439c.reorderEntryHead(); });