Skip to content
(function () {
"use strict";
var STORAGE_KEY = "minhThuan_introPlayed";
function readSessionFlag() {
try {
return window.sessionStorage.getItem(STORAGE_KEY) === "1";
} catch (error) {
return false;
}
}
function saveSessionFlag() {
try {
window.sessionStorage.setItem(STORAGE_KEY, "1");
} catch (error) {}
}
function makeElement(tagName, className) {
var element = document.createElement(tagName);
element.className = className;
return element;
}
function clearPageState() {
document.body.classList.remove("mt-intro-active", "mt-intro-revealing");
}
function initIntro() {
var body = document.body;
if (!body || document.getElementById("minh-thuan-intro")) {
return;
}
var isHomepage = body.classList.contains("home");
var reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
if (!isHomepage || readSessionFlag()) {
clearPageState();
return;
}
if (reduceMotion) {
clearPageState();
saveSessionFlag();
return;
}
var isMobile = window.matchMedia("(max-width: 768px)").matches;
var revealAt = isMobile ? 1050 : 1800;
var removeLinesAt = isMobile ? 1000 : 1750;
var finishAt = isMobile ? 2000 : 3200;
body.classList.add("mt-intro-active");
var intro = document.createElement("div");
intro.id = "minh-thuan-intro";
intro.setAttribute("aria-hidden", "true");
intro.setAttribute("role", "presentation");
intro.appendChild(makeElement("div", "mt-intro-panel mt-intro-panel--upper"));
intro.appendChild(makeElement("div", "mt-intro-panel mt-intro-panel--lower"));
for (var shardIndex = 0; shardIndex < 6; shardIndex += 1) {
intro.appendChild(makeElement("div", "mt-light-shard"));
}
var speedLineCount = isMobile ? 8 : 11;
var speedLines = [];
for (var lineIndex = 0; lineIndex < speedLineCount; lineIndex += 1) {
var line = makeElement("div", "mt-speed-line");
var topPosition = 8 + Math.random() * 84;
var lineWidth = 24 + Math.random() * 52;
var delay = (isMobile ? 180 : 420) + lineIndex * 50;
line.style.top = topPosition.toFixed(2) + "%";
line.style.width = lineWidth.toFixed(2) + "vw";
line.style.animationDelay = delay + "ms";
if (lineIndex % 3 === 0) {
line.style.left = 20 + Math.random() * 35 + "%";
}
speedLines.push(line);
intro.appendChild(line);
}
var brand = makeElement("p", "mt-intro-brand");
brand.textContent = "GƯƠNG XE MINH THUẬN";
intro.appendChild(brand);
intro.appendChild(makeElement("div", "mt-intro-glare"));
intro.appendChild(makeElement("div", "mt-intro-cut"));
body.appendChild(intro);
window.setTimeout(function () {
speedLines.forEach(function (line) {
if (line.parentNode) {
line.parentNode.removeChild(line);
}
});
speedLines.length = 0;
}, removeLinesAt);
window.setTimeout(function () {
body.classList.remove("mt-intro-active");
body.classList.add("mt-intro-revealing");
}, revealAt);
window.setTimeout(function () {
if (intro.parentNode) {
intro.parentNode.removeChild(intro);
}
clearPageState();
saveSessionFlag();
}, finishAt);
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initIntro, { once: true });
} else {
initIntro();
}
})();