From 1e3e238582aef7dbe49c684c583aea156f03c673 Mon Sep 17 00:00:00 2001 From: tfl Date: Sun, 10 Jul 2022 23:28:17 +0200 Subject: [PATCH] Added testing if client is running on a mobile phone (which might not work with this website due to some limitation) --- js/main.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/js/main.js b/js/main.js index c5fb494..4e76a01 100644 --- a/js/main.js +++ b/js/main.js @@ -1,3 +1,19 @@ +// Check if client is using a mobile phone +const getMobileOS = () => { + const ua = navigator.userAgent + if (/android/i.test(ua)) { + return "Android" + } + else if (/iPad|iPhone|iPod/.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) { + return "iOS" + } + return "Other" +} +const isRunningOn = getMobileOS(); +if (isRunningOn != 'Other') { + alert('Whoop, it seems that you attempt to access this website on a ' + isRunningOn + ' mobile/tablet, which might not work properly. You should better use a computer instead.'); +} + // Loads the Youtube IFrame Player API code asynchronously. let tag = document.createElement('script'); tag.src = 'https://www.youtube.com/iframe_api'; @@ -314,21 +330,9 @@ function newShootingStar() { }, duration); // setTimeout('newShootingStar()', duration + nextIn); } -// function endShootingStar(el) { -// el.remove(); -// console.log('removed!'); -// let nextIn = 4000; -// setTimeout('newShootingStar()', nextIn); -// } newShootingStar(); -hsnqK2yJ8D66haK - -// Enable/disable shooting stars -// let separatorSpan = document.createElement('span'); -// separatorSpan.innerHTML = ' - '; -// document.getElementById('shooting-stars-enable').after(separatorSpan); document.getElementById('shooting-stars-enable').innerHTML = '⭐️Disable shooting stars⭐️'; document.getElementById('shooting-stars-enable').addEventListener('click', () => {