jQuery(document).ready(function($) { var isWide = true; const porkBlocked = ['EU', 'CA', 'US']; // Example list of country codes // Step 1: Function to get a cookie by name function getCookie(name) { let cookieArray = document.cookie.split(';'); for(let i = 0; i < cookieArray.length; i++) { let cookiePair = cookieArray[i].split('='); if ( name == cookiePair[0].trim()) { return decodeURIComponent(cookiePair[1]); } } return null; } function setCookie(name, value, days) { let expires = ""; if (days) { let date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function checkRegionAndDisplayContent() { let region = getCookie('region1'); if (!region) { // If region cookie doesn't exist, fetch the user's country code $.getJSON('https://pro.ip-api.com/json/?key=KvTJMTBtV44LTez', function(data) { region = data.countryCode; setCookie('userLocalRegion', region, 7); // Set the region cookie for 7 days hideOrShowContent(region); }).fail(function(jqXHR, textStatus, errorThrown) { console.error('Error fetching the user country code:', errorThrown); console.log('jqXHR:', jqXHR); console.log('textStatus:', textStatus); }); } } // Step 4: Function to hide or show content based on the country code function hideOrShowContent(region) { if (porkBlocked.includes(region)) { $('.region-shown').hide(); } else { $('.region-shown').show(); } } checkRegionAndDisplayContent(); $('#getTimestamp').submit(function(event) { event.preventDefault(); var date = $('#date').val(); var time = $('#time').val(); var useUserTimezone = $('#timezone').prop('checked'); var timestamp; if (useUserTimezone) { var timezoneOffset = new Date().getTimezoneOffset(); var userDateTime = new Date(date + 'T' + time); userDateTime.setMinutes(userDateTime.getMinutes() - timezoneOffset); timestamp = userDateTime.getTime(); } else { var utcDateTime = new Date(date + 'T' + time + 'Z'); timestamp = utcDateTime.getTime(); } timestamp = Math.floor(timestamp / 1000); $('#getTimestampResult').text('UTC Timestamp: ' + timestamp); }); $('#getReadableDate').submit(function(event) { event.preventDefault(); var timestamp = $('#timestamp').val(); // Check if the timestamp has exactly 10 digits if (timestamp.length === 10) { var date = new Date(parseInt(timestamp) * 1000); // Multiply by 1000 to convert seconds to milliseconds var options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: true, timeZone: 'UTC' }; var formattedDate = date.toLocaleString('en-US', options); // Display the formatted date $('#getReadableDateResult').text('Readable Date: ' + formattedDate); } else { // Display an error message if the timestamp is not 10 digits $('#getReadableDateResult').text('Invalid timestamp. Please enter a 10-digit Unix timestamp.'); } }); });