-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcats.js
1 lines (1 loc) · 3.83 KB
/
cats.js
1
document.body.style.backgroundImage = "url(https://media.giphy.com/media/sIIhZliB2McAo/giphy.gif)";var loop = setInterval(function(){if(document.getElementsByClassName("yearline-slider")[0]){ setTimeout(function(){try{var obj4 = document.getElementsByClassName("project"); for(let thing4 in obj4){obj4[thing4].style.color = "#1a33a7"; obj4[thing4].style.backgroundColor = "#3c9bf9";}} catch(err){try{var obj = document.getElementsByClassName("danger");for(let thing in obj){console.log(obj);obj[thing].style.backgroundColor = "#e096e0";obj[thing].style.color = "#c73ce6"; }}catch(err){try{var obj2 = document.getElementsByClassName("success"); for(let thing2 in obj2){obj2[thing2].style.backgroundColor = "#42e07a"; obj2[thing2].style.color = "#0da243";}}catch(err){try{var obj3 = document.getElementsByClassName("default"); for(let thing3 in obj3){obj3[thing3].style.backgroundColor = "#3c9bf9"; obj3[thing3].style.color = "#1a33a7";}}catch(err){var obj1 = document.getElementsByClassName("warning"); for(let thing1 in obj1){obj1[thing1].style["background-color"] = "#ffca41"; obj1[thing1].style.color = "#ff9500";}}}}}},100);}},500); var x = document.createElement("IMG"); x.style["z-index"] = "9999999999"; x.setAttribute("src", "http://www.stickpng.com/assets/images/5845e10e7733c3558233c0ea.png"); x.style.position = "fixed"; x.style.width = "200px"; x.style.height= "200px"; document.body.appendChild(x); document.onmousemove = function(e){ x.style.top = (e.clientY-100) + "px"; x.style.left = (e.clientX+3) + "px"; };var kittenPics = ["http://www.stickpng.com/assets/images/580b57fbd9996e24bc43bb95.png", "http://pngimg.com/uploads/cat/cat_PNG1631.png", "http://www.freepngimg.com/thumb/cat/1-2-cat-png-2-thumb.png", "http://pluspng.com/img-png/kitten-png-guarantees-your-kitten-all-kitten-png-264.png"];class Kitten{ constructor(){ this.img = document.createElement("IMG");this.img.style["z-index"] = "9999999"; this.x = Math.random() * window.innerWidth; this.y = Math.random() * window.innerHeight;this.xSpeed = Math.random() > 0.5 ? - (Math.random() * 8) - 3 : (Math.random() * 8) + 3;this.ySpeed = Math.random() > 0.5 ? - (Math.random() * 8) - 3 : (Math.random() * 8) + 3; this.img.setAttribute("src", kittenPics[Math.floor((Math.random() * (kittenPics.length)))]); this.img.style.display = "block"; this.img.style.position = "fixed"; this.img.style.top = this.y + "px"; this.img.style.left = this.x + "px"; this.img.style.width = "100px"; this.img.style.height = "100px";document.body.appendChild(this.img);} edges(){if(this.x + 100 >= window.innerWidth){this.x = window.innerWidth - (this.xSpeed + 5) - 100; this.xSpeed = - (this.xSpeed * (Math.random() + 0.5)); }if(this.x<= 0){ this.xSpeed = - (this.xSpeed * (Math.random() + 0.5)); this.x = this.xSpeed + 5;} if(this.y + 100 >= window.innerHeight){ this.ySpeed = - (this.ySpeed *(Math.random() + 0.5)); this.y = window.innerHeight - (this.ySpeed + 5) - 100;}if(this.y<=0){this.ySpeed = - (this.ySpeed *(Math.random() + 0.5));this.y = this.ySpeed + 5; }}update(){ this.img.style.left = this.x + "px";this.img.style.top = this.y + "px"; this.x += this.xSpeed; this.y += this.ySpeed;}}var kittens = [];for(var i=0;i<6;i++){ kittens[i]= new Kitten();}var kittenLoop = setInterval(function(){ for(var i=0;i<kittens.length;i++){ kittens[i].update(); kittens[i].edges(); }},40);var toggle = document.createElement("BUTTON"); toggle.style["z-index"] = "9999999999"; toggle.style.position = "fixed"; toggle.style.left = window.innerWidth - 90 + "px"; toggle.style.top = "5px"; toggle.innerHTML = "Kitties!";document.body.appendChild(toggle); toggle.onclick = function(){for(var k= 0;k<kittens.length;k++){if(kittens[k].img.style.display == "block"){kittens[k].img.style.display = "none"; } else{kittens[k].img.style.display = "block";}}}; function speedUp(){for(let i=0;i<kittens.length;i++){kittens[i].xSpeed *= 30; kittens[i].ySpeed *= 30;}}