Team:NCKU Tainan/js/T--NCKU Tainan--common js

function addImgEventlistener(){var e=document.querySelectorAll(".content img");e.forEach(function(e){e.addEventListener("click",onClickImg)}),document.body.addEventListener("click",function(){activeImg&&activeImg.classList.remove("clicked")})}function onClickImg(){var e=this;e.classList.contains("clicked")||setTimeout(function(){e.classList.add("clicked"),activeImg=e},100)}function updateColsHeight(e,t){var n=e.offsetHeight,o=t.offsetHeight;o>n?e.style.height=o:t.style.height=n}function onScroll(){submenu&&updateSubMenu(),sidemenu&&updateSideMenu()}function getDropNum(){var e=window.location.href;e=e.split("/"),e=""==e[e.length-1]?e[e.length-2]:e[e.length-1];var t=-1,n={0:["Project","Description","Result","Model","Part"],1:["Hardware","Software","Demo"],2:["Medal","Safety"],3:["Team","Attribution","Acknowledgement","Collaboration"],4:["Human","Practice","Engagement"],5:["Construction","Functional","Design","Protocols"]};for(var o in n)for(var i=0;i<n[o].length;++i)-1!==e.toLowerCase().indexOf(n[o][i].toLowerCase())&&-1===e.indexOf("Team:NCKU")&&(t=o);return t}function updateSubMenu(){var e=document.getElementsByTagName("nav")[0];if(window.scrollY>=10){var t=document.getElementsByClassName("open")[0];t&&t.classList.remove("open"),submenu.parentElement.classList.add("open"),e.classList.add("fixed")}else e.classList.remove("fixed")}function updateSideMenu(){var e=sidemenu.offsetWidth,t=sidemenu.parentElement.getBoundingClientRect().top;0>=t?(sidemenu.style.position="fixed",sidemenu.style.width=e,sidemenu.style.top="71px"):(sidemenu.style.position="relative",sidemenu.style.top="")}function toEvent(e){var t=$("#"+e).offset().top-66;return $("html, body").animate({scrollTop:t+"px"},1e3,updateSubMenu),!1}var activeImg,submenu,submenuWidth,sidemenu;document.onscroll=onScroll,$(window).on("load",function(){addImgEventlistener(),sidemenu=document.getElementById("sidemenu");var e=getDropNum();-1!==e&&(submenu=document.getElementsByClassName("dropdown-menu")[e],submenu.parentElement.classList.add("open"),submenuWidth=submenu.offsetWidth);var t=document.getElementsByClassName("content")[0];if(t){var n=t.getElementsByClassName("col-md-9")[0],o=t.getElementsByClassName("col-md-3")[0];void 0!==n&&void 0!==o&&updateColsHeight(n,o)}var i=document.getElementById("HQ_page");i&&(i.id="")});