Float Image
Float Image
new lex logo
Float Image

Turn Ideas inTO REALITY

Float Image
Float Image

<script>

document.addEventListener("DOMContentLoaded", function() {

if (localStorage.getItem("hasShared") === "true") return;

const popupHTML = `

<div id="share-popup" style="

display: none;

position: fixed;

top: 50%;

left: 50%;

transform: translate(-50%, -50%);

background: white;

padding: 30px;

border-radius: 10px;

box-shadow: 0 0 20px rgba(0,0,0,0.2);

z-index: 1000;

text-align: center;

max-width: 500px;

width: 90%;

">

<h2 style="

font-size: 1.5rem;

font-weight: 600;

color: #2c3e50;

margin-bottom: 1rem;

">Share this page to continue reading!</h2>

<p style="

font-size: 1rem;

line-height: 1.5;

color: #333;

margin-bottom: 1.5rem;

">Help us grow by sharing this content with your friends.</p>

<div style="

display: flex;

justify-content: center;

gap: 10px;

margin-bottom: 20px;

">

<button id="share-twitter" style="

padding: 10px 15px;

background: #1DA1F2;

color: white;

border: none;

border-radius: 5px;

cursor: pointer;

font-size: 1rem;

font-weight: 500;

">Twitter</button>

<button id="share-facebook" style="

padding: 10px 15px;

background: #4267B2;

color: white;

border: none;

border-radius: 5px;

cursor: pointer;

font-size: 1rem;

font-weight: 500;

">Facebook</button>

<button id="share-copy" style="

padding: 10px 15px;

background: #4CAF50;

color: white;

border: none;

border-radius: 5px;

cursor: pointer;

font-size: 1rem;

font-weight: 500;

">Copy Link</button>

</div>

<button id="continue-btn" style="

padding: 10px 20px;

background: #ff5722;

color: white;

border: none;

border-radius: 5px;

cursor: pointer;

opacity: 0.5;

pointer-events: none;

font-size: 1rem;

font-weight: 500;

">Continue Reading</button>

</div>

`;

document.body.insertAdjacentHTML('beforeend', popupHTML);

const popup = document.getElementById("share-popup");

const content = document.querySelector("body > *:not(#share-popup)");

let popupTriggered = false;

function showPopup() {

if (popupTriggered || localStorage.getItem("hasShared") === "true") return;

popupTriggered = true;

popup.style.display = "block";

document.body.style.overflow = "hidden";

content.style.filter = "blur(3px)";

content.style.pointerEvents = "none";

}

// Timeout trigger

setTimeout(showPopup, 6000);

// Scroll trigger

window.addEventListener("scroll", function() {

const scrollPercent = (window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100;

if (scrollPercent >= 25 && !popupTriggered) showPopup();

});

const shareActions = {

"share-twitter": https://twitter.com/intent/tweet?url=${encodeURIComponent(window.location.href)}&text=${encodeURIComponent(document.title)},

"share-facebook": https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(window.location.href)},

"share-copy": null

};

Object.keys(shareActions).forEach(id => {

document.getElementById(id).addEventListener("click", function() {

if (id === "share-copy") {

navigator.clipboard.writeText(window.location.href).then(() => {

alert("Link copied!");

markAsShared();

});

} else {

window.open(shareActions[id], "_blank");

markAsShared();

}

});

});

document.getElementById("continue-btn").addEventListener("click", function() {

if (localStorage.getItem("hasShared") === "true") {

closePopup();

}

});

function markAsShared() {

localStorage.setItem("hasShared", "true");

document.getElementById("continue-btn").style.opacity = "1";

document.getElementById("continue-btn").style.pointerEvents = "auto";

}

function closePopup() {

popup.style.display = "none";

content.style.filter = "none";

content.style.pointerEvents = "auto";

document.body.style.overflow = "auto";

}

});

</script>