| Server IP : 27.254.66.5 / Your IP : 216.73.217.39 Web Server : Apache/2 System : Linux cs82.hostneverdie.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : technic2 ( 1951) PHP Version : 7.4.30 Disable Function : apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd,exec, fp, fput, highlight_file, ini_alter, ini_restore, inject_code, passthru,phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid,posix_setuid, posix_setuid, posix_uname,proc_open,proc_close, proc_get_status, proc_nice, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,sleep,pcntl_exec,virtual,suexec,dbmopen,dl,symlink,disk_free_space,diskfreespace,leak MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/technic2/domains/technicrayong.ac.th/public_html/rytc/tobe/assets/js/ |
Upload File : |
document.addEventListener('DOMContentLoaded', function () {
var navbar = document.querySelector('.navbar-main');
var navbarCollapse = document.querySelector('#navbarMenu');
var clickableLinks = document.querySelectorAll(
'a[href="#services"], a[href="#consult"], a[href="#eq"], a[href="#creative"], a[href="#home"], ' +
'a[href="index.php#services"], a[href="index.php#consult"], a[href="index.php#eq"], a[href="index.php#creative"], a[href="index.php#home"]'
);
function getNavbarOffset() {
return (navbar ? navbar.getBoundingClientRect().height : 0) + 16;
}
function normalizePath(pathname) {
return pathname.replace(/\/index\.php$/, '/');
}
function easeInOutCubic(t) {
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
}
function animateScrollTo(targetY, duration) {
var startY = window.pageYOffset;
var distance = targetY - startY;
var startTime = null;
function step(currentTime) {
if (startTime === null) startTime = currentTime;
var elapsed = currentTime - startTime;
var progress = Math.min(elapsed / duration, 1);
var eased = easeInOutCubic(progress);
window.scrollTo(0, startY + distance * eased);
if (progress < 1) {
window.requestAnimationFrame(step);
}
}
window.requestAnimationFrame(step);
}
function scrollToSection(hash, updateUrl) {
if (!hash || hash === '#') return;
var target = document.querySelector(hash);
if (!target) return;
var targetY = target.getBoundingClientRect().top + window.pageYOffset - getNavbarOffset();
targetY = Math.max(targetY, 0);
animateScrollTo(targetY, 900);
if (updateUrl) {
history.pushState(null, '', hash);
}
}
clickableLinks.forEach(function (link) {
link.addEventListener('click', function (event) {
var href = link.getAttribute('href');
var url = new URL(href, window.location.href);
var samePage = normalizePath(url.pathname) === normalizePath(window.location.pathname);
if (!samePage || !url.hash) return;
event.preventDefault();
if (navbarCollapse && navbarCollapse.classList.contains('show')) {
bootstrap.Collapse.getOrCreateInstance(navbarCollapse).hide();
}
scrollToSection(url.hash, true);
});
});
if (window.location.hash) {
setTimeout(function () {
scrollToSection(window.location.hash, false);
}, 250);
}
var sections = Array.prototype.slice.call(document.querySelectorAll('#home, #services, #consult, #eq, #creative'));
var navLinks = Array.prototype.slice.call(document.querySelectorAll('.navbar-main .nav-link[href^="#"], .navbar-main .nav-link[href^="index.php#"]'));
function setActiveMenu() {
var current = 'home';
var offset = getNavbarOffset() + 80;
sections.forEach(function (section) {
if (window.pageYOffset >= section.offsetTop - offset) {
current = section.id;
}
});
navLinks.forEach(function (link) {
var linkHash = new URL(link.getAttribute('href'), window.location.href).hash;
link.classList.toggle('active', linkHash === '#' + current);
});
}
window.addEventListener('scroll', setActiveMenu, { passive: true });
setActiveMenu();
});