//puush-roulette.com auto spinner //async too //Made by Sean McClenaghan var spinningForYou = false; var failCounter = 0; var highScore = 0; var desktopNotify = false; var rotateTimer; var degree = 0; $("form").replaceWith( ""); if(Notification) { $("#spinbutton").after("
") } function enableDesktopNotifications() { Notification.requestPermission(function(){ if(Notification.permission == 'granted' || webkitNotifications.checkPermission() == '0') { $('#dnotifyBtn').replaceWith(""); desktopNotify = true; } }); } function disableDesktopNotifications() { $('#dnotifyBtn').replaceWith(""); desktopNotify = false; } function spinforme() { $('#spinbutton').before("
") degree = 0; rotate($("#star")) failCounter = 0; if($(".thumbnail")[0]) { $(".thumbnail").remove(); } spinningForYou = true; $("#spinbutton").replaceWith(""); spin(); } function spin() { if(!spinningForYou) { return; } if(!($("#failCounter")[0])) { $("#star").after("

Current Score: 0 Failures"); $("#failCounter").after(" High Score: "+highScore+" Failures

"); } else { $("#failCounter").html("Current Score: " + failCounter + " Failures"+""); } if(failCounter > highScore) { highScore = failCounter; $("#highScore").html("High Score: "+highScore+" Failures"); } $.post("/", { roll : "1" }).done(function (data) { if($(".thumbnail", $(data))[0]) { if(desktopNotify) { var notification = new Notification('YOU ARE WINNER!', { body: "Puush Roulette found a new puush!", icon: "http://osx.iusethis.com/icon/osx/puush.png"}); setTimeout(function() { notification.close(); }, 5000) } stopspinning(); $(".page-header").after($(".thumbnail", $(data))); } else { failCounter++; spin(); } }); } function stopspinning() { spinningForYou = false; $("#spinbutton").replaceWith(""); $("#star").remove(); clearTimeout(rotateTimer); $("#highScore").remove(); $("#failCounter").remove(); } function rotate(thing) { thing.css({ WebkitTransform: 'rotate(' + degree + 'deg)'}); thing.css({ '-moz-transform': 'rotate(' + degree + 'deg)'}); rotateTimer = setTimeout(function() { ++degree; rotate(thing); }, 3); }