add homebutton script to main site

This commit is contained in:
jumping283 2023-01-23 09:43:56 -08:00 committed by GitHub
parent df7de5a6d7
commit 947efb4f45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

20
sheep/3.js Normal file
View File

@ -0,0 +1,20 @@
document.addEventListener("DOMContentLoaded", function(e) {
var homeButton = document.createElement("sheep-btn");
homeButton.setAttribute('tabindex', 0);
homeButton.setAttribute('aria-label', 'Go to SheepTester directory');
homeButton.setAttribute('role', 'button');
homeButton.addEventListener('click', function(e) {
document.body.classList.add('sheep-blockscreen');
homeButton.addEventListener('transitionend', function(e) {
window.requestAnimationFrame(function() {
// Try forcing repaint
homeButton.getBoundingClientRect();
window.location = 'https://andrewsapps.netlify.app/?from=sheep3';
});
});
});
homeButton.addEventListener('keydown', function(e) {
if (e.keyCode === 13) homeButton.click();
});
document.body.appendChild(homeButton);
}, {once: true});