window.onbeforeunload = function() {
window.scrollTo(0, 0);
};
var isSectionLocked = true; // Menyimpan status kunci tampilan section
// Mengunci tampilan section pertama saat halaman dimuat
window.addEventListener('DOMContentLoaded', function() {
lockSection();
});
// Fungsi untuk mengunci tampilan section
function lockSection() {
if (isSectionLocked) {
disableScrolling();
document.body.style.position = "fixed";
document.body.style.overflowY = "scroll";
document.body.style.height = "100vh";
document.getElementById("section-cover").style.width = "100vw"; // Menambahkan gaya untuk membuat cover full width
}
}
// Fungsi untuk membuka tampilan section
function unlockSection() {
enableScrolling();
document.body.style.position = "";
document.body.style.overflowY = "";
document.getElementById("section-cover").style.width = ""; // Menghapus gaya untuk mengembalikan lebar cover ke nilai aslinya
document.getElementById("tombol-buka").style.display = "none"; // Menyembunyikan tombol "tombol-buka"
}
document.getElementById("tombol-buka").onclick = function() {
unlockSection();
playAudio();
};
function disableScrolling() {
var x = window.scrollX;
var y = window.scrollY;
window.onscroll = function() {
window.scrollTo(x, y);
};
}
function enableScrolling() {
window.onscroll = null;
}
function playAudio(){
var isYT = false;
if(document.body.contains(document.getElementById("song"))) {
document.getElementById("song").play();
isYT = false;
} else {
isYT = true;
player.playVideo();
}
}
//Script Custom Nama Tamu by Andy dari WeddingPress
var urlParams = new URLSearchParams(window.location.search);
if (urlParams) {
var textElement = document.getElementById('namatamu');
var defaultText = textElement.innerHTML;
var newText = defaultText;
if (urlParams.has('to')) {
var toValue = urlParams.get('to');
newText = newText.replace(/Tamu Undangan/g, toValue);
}
if (urlParams.has('dear')) {
var dearValue = urlParams.get('dear');
newText = newText.replace(/Tamu Undangan/g, dearValue);
}
if (urlParams.has('kepada')) {
var kepadaValue = urlParams.get('kepada');
newText = newText.replace(/Tamu Undangan/g, kepadaValue);
}
textElement.innerHTML = newText;
}