Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- const currentDate = new Date();
- const player = window.GetPlayer ? GetPlayer() : null;
- if (!player) {
- console.error('GetPlayer function not found');
- return;
- }
- const courseExpiryDate = player.GetVar("ExpiryDate");
- if (!courseExpiryDate || typeof courseExpiryDate !== 'string') {
- console.error('Invalid expiry date');
- return;
- }
- const [day, month, year] = courseExpiryDate.split('-').map(Number);
- const finalCourseExpiryDate = new Date(year, month - 1, day);
- if (isNaN(finalCourseExpiryDate.getTime())) {
- console.error('Invalid date format');
- return;
- }
- if (currentDate > finalCourseExpiryDate) {
- showExpiryModal();
- }
- function showExpiryModal() {
- const overlay = document.createElement('div');
- Object.assign(overlay.style, {
- width: '100%',
- height: '100%',
- background: 'rgba(0, 0, 0, 0.5)',
- position: 'fixed',
- top: '0',
- left: '0',
- zIndex: '9999',
- display: 'flex',
- justifyContent: 'center',
- alignItems: 'center'
- });
- document.body.style.overflow = 'hidden';
- const modalDiv = document.createElement('div');
- Object.assign(modalDiv.style, {
- width: '400px',
- background: '#fff',
- color: '#000',
- padding: '20px',
- borderRadius: '8px',
- boxShadow: '0px 0px 15px rgba(0,0,0,0.2)'
- });
- const p = document.createElement('p');
- p.textContent = 'This course has expired.';
- Object.assign(p.style, {
- fontSize: '18px',
- textAlign: 'center'
- });
- const button = document.createElement('button');
- button.textContent = 'Close';
- Object.assign(button.style, {
- display: 'block',
- width: '100%',
- padding: '10px',
- marginTop: '20px',
- border: 'none',
- background: '#3498db',
- color: '#fff',
- fontSize: '18px',
- cursor: 'pointer',
- borderRadius: '5px'
- });
- button.addEventListener('click', () => {
- document.body.style.overflow = 'auto';
- overlay.remove();
- if (window.close) {
- window.close();
- }
- });
- modalDiv.appendChild(p);
- modalDiv.appendChild(button);
- overlay.appendChild(modalDiv);
- document.body.appendChild(overlay);
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement