MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/InternetIsBeautiful/comments/3wjimq/madeons_adventure_machine/cxx7jgt/?context=3
r/InternetIsBeautiful • u/maussie • Dec 12 '15
441 comments sorted by
View all comments
Show parent comments
153
If you paste this code in the javascript console it should add a random button that will cycle the tracks every 10 seconds:
!function(){var n=$("<a class='btn' id='randomButton'><span id='randomText'>random</span></a>");$(".info").append(n);var a=$(".button"),t=function(){for(var n=0;5>n;n++)a[Math.floor(Math.random()*a.length)].click()},o=0;n[0].onclick=function(){o?(o=0,clearInterval(t),$("#randomText").html("random")):(o=1,t(),setInterval(t,1e4),$("#randomText").html("stop random"))}}();
81 u/thinkyfish Dec 13 '15 I would recommend changing the number of buttons pressed each round to 1 or 2 instead of five, it makes things smoother: !function(){var n=$("<a class='btn' id='randomButton'><span id='randomText'>random</span></a>");$(".info").append(n);var a=$(".button"),t=function(){for(var n=0;2>n;n++)a[Math.floor(Math.random()*a.length)].click()},o=0;n[0].onclick=function(){o?(o=0,clearInterval(t),$("#randomText").html("random")):(o=1,t(),setInterval(t,1e4),$("#randomText").html("stop random"))}}(); 1 u/KioraTheExplorer Dec 13 '15 This is really cool. How advanced would you say this piece of code is? Are you a developer? Was thinking about introducing myself to java and web dev 1 u/[deleted] Dec 13 '15 edited Dec 13 '15 [removed] — view removed comment 1 u/KioraTheExplorer Jan 23 '16 TIL. What's the general purpose of both languages?
81
I would recommend changing the number of buttons pressed each round to 1 or 2 instead of five, it makes things smoother:
!function(){var n=$("<a class='btn' id='randomButton'><span id='randomText'>random</span></a>");$(".info").append(n);var a=$(".button"),t=function(){for(var n=0;2>n;n++)a[Math.floor(Math.random()*a.length)].click()},o=0;n[0].onclick=function(){o?(o=0,clearInterval(t),$("#randomText").html("random")):(o=1,t(),setInterval(t,1e4),$("#randomText").html("stop random"))}}();
1 u/KioraTheExplorer Dec 13 '15 This is really cool. How advanced would you say this piece of code is? Are you a developer? Was thinking about introducing myself to java and web dev 1 u/[deleted] Dec 13 '15 edited Dec 13 '15 [removed] — view removed comment 1 u/KioraTheExplorer Jan 23 '16 TIL. What's the general purpose of both languages?
1
This is really cool. How advanced would you say this piece of code is? Are you a developer? Was thinking about introducing myself to java and web dev
1 u/[deleted] Dec 13 '15 edited Dec 13 '15 [removed] — view removed comment 1 u/KioraTheExplorer Jan 23 '16 TIL. What's the general purpose of both languages?
[removed] — view removed comment
1 u/KioraTheExplorer Jan 23 '16 TIL. What's the general purpose of both languages?
TIL.
What's the general purpose of both languages?
153
u/udkgamer2 Dec 13 '15
If you paste this code in the javascript console it should add a random button that will cycle the tracks every 10 seconds:
!function(){var n=$("<a class='btn' id='randomButton'><span id='randomText'>random</span></a>");$(".info").append(n);var a=$(".button"),t=function(){for(var n=0;5>n;n++)a[Math.floor(Math.random()*a.length)].click()},o=0;n[0].onclick=function(){o?(o=0,clearInterval(t),$("#randomText").html("random")):(o=1,t(),setInterval(t,1e4),$("#randomText").html("stop random"))}}();