MediaWiki:Common.js: Difference between revisions
From Riverview Legal Group
Access restrictions were established for this page. If you see this message, you have no access to this page.
m (Replaced content with "→Any JavaScript here will be loaded for all users on every page load.: ") Tag: Replaced |
mNo edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
$(document).ready(function () { | |||
let interactionCount = localStorage.getItem("interactionCount") || 0; | |||
let popupShown = localStorage.getItem("popupShown"); | |||
function incrementInteraction() { | |||
interactionCount++; | |||
localStorage.setItem("interactionCount", interactionCount); | |||
// Show popup after 5 interactions | |||
if (interactionCount >= 5 && !popupShown) { | |||
showPopup(); | |||
} | |||
} | |||
function showPopup() { | |||
let popup = $(` | |||
<div id="popup-overlay"> | |||
<div id="popup-box"> | |||
<h2>Need Tenant Legal Help?</h2> | |||
<p>We specialize in helping tenants at the Landlord and Tenant Board.</p> | |||
<a href="https://riverview.legal" target="_blank" class="popup-button">Book a Consultation</a> | |||
<span id="popup-close">×</span> | |||
</div> | |||
</div> | |||
`); | |||
$("body").append(popup); | |||
localStorage.setItem("popupShown", "true"); | |||
// Close popup on click | |||
$("#popup-close").click(function () { | |||
$("#popup-overlay").fadeOut(); | |||
}); | |||
} | |||
// Track user interactions | |||
$(document).on("click scroll keypress", function () { | |||
incrementInteraction(); | |||
}); | |||
}); | |||
// CSS Styling | |||
mw.util.addCSS(` | |||
#popup-overlay { | |||
position: fixed; | |||
top: 0; | |||
left: 0; | |||
width: 100%; | |||
height: 100%; | |||
background: rgba(0, 0, 0, 0.6); | |||
display: flex; | |||
justify-content: center; | |||
align-items: center; | |||
z-index: 9999; | |||
} | |||
#popup-box { | |||
background: white; | |||
padding: 20px; | |||
border-radius: 10px; | |||
text-align: center; | |||
width: 300px; | |||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); | |||
position: relative; | |||
} | |||
.popup-button { | |||
display: inline-block; | |||
background: #007bff; | |||
color: white; | |||
padding: 10px; | |||
text-decoration: none; | |||
border-radius: 5px; | |||
margin-top: 10px; | |||
} | |||
#popup-close { | |||
position: absolute; | |||
top: 10px; | |||
right: 15px; | |||
cursor: pointer; | |||
font-size: 20px; | |||
} | |||
`); |
Revision as of 04:43, 18 February 2025
/* Any JavaScript here will be loaded for all users on every page load. */ $(document).ready(function () { let interactionCount = localStorage.getItem("interactionCount") || 0; let popupShown = localStorage.getItem("popupShown"); function incrementInteraction() { interactionCount++; localStorage.setItem("interactionCount", interactionCount); // Show popup after 5 interactions if (interactionCount >= 5 && !popupShown) { showPopup(); } } function showPopup() { let popup = $(` <div id="popup-overlay"> <div id="popup-box"> <h2>Need Tenant Legal Help?</h2> <p>We specialize in helping tenants at the Landlord and Tenant Board.</p> <a href="https://riverview.legal" target="_blank" class="popup-button">Book a Consultation</a> <span id="popup-close">×</span> </div> </div> `); $("body").append(popup); localStorage.setItem("popupShown", "true"); // Close popup on click $("#popup-close").click(function () { $("#popup-overlay").fadeOut(); }); } // Track user interactions $(document).on("click scroll keypress", function () { incrementInteraction(); }); }); // CSS Styling mw.util.addCSS(` #popup-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; z-index: 9999; } #popup-box { background: white; padding: 20px; border-radius: 10px; text-align: center; width: 300px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); position: relative; } .popup-button { display: inline-block; background: #007bff; color: white; padding: 10px; text-decoration: none; border-radius: 5px; margin-top: 10px; } #popup-close { position: absolute; top: 10px; right: 15px; cursor: pointer; font-size: 20px; } `);