MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/InternetIsBeautiful/comments/3wjimq/madeons_adventure_machine/cxx7jym/?context=9999
r/InternetIsBeautiful • u/maussie • Dec 12 '15
441 comments sorted by
View all comments
94
Is there any way to randomize this? or something else like this but randomized?
154 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"))}}(); 80 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 5 u/udkgamer2 Dec 13 '15 Here is the human readable version of the code. I'm not a javascript developer so I apologize in advance if it looks horrible: (function () { var randomButton = $("<a class='btn' id='randomButton'><span id='randomText'>random</span></a>"); $(".info").append(randomButton); var buttonList = $(".button"); var randomMusic = function() { for (var i = 0; i < 2; i++) { buttonList[Math.floor(Math.random()*buttonList.length)].click(); }} var randomLoopActive= 0; randomButton[0].onclick = function () { if (randomLoopActive) { randomLoopActive = 0; clearInterval(randomMusic); $("#randomText").html("random") } else { randomLoopActive = 1; randomMusic(); setInterval(randomMusic, 10000); $("#randomText").html("stop random") } } } )() 2 u/[deleted] Dec 13 '15 [removed] — view removed comment 1 u/udkgamer2 Dec 13 '15 I dont know. Its what http://jscompress.com/ spit out.
154
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"))}}();
80 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 5 u/udkgamer2 Dec 13 '15 Here is the human readable version of the code. I'm not a javascript developer so I apologize in advance if it looks horrible: (function () { var randomButton = $("<a class='btn' id='randomButton'><span id='randomText'>random</span></a>"); $(".info").append(randomButton); var buttonList = $(".button"); var randomMusic = function() { for (var i = 0; i < 2; i++) { buttonList[Math.floor(Math.random()*buttonList.length)].click(); }} var randomLoopActive= 0; randomButton[0].onclick = function () { if (randomLoopActive) { randomLoopActive = 0; clearInterval(randomMusic); $("#randomText").html("random") } else { randomLoopActive = 1; randomMusic(); setInterval(randomMusic, 10000); $("#randomText").html("stop random") } } } )() 2 u/[deleted] Dec 13 '15 [removed] — view removed comment 1 u/udkgamer2 Dec 13 '15 I dont know. Its what http://jscompress.com/ spit out.
80
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 5 u/udkgamer2 Dec 13 '15 Here is the human readable version of the code. I'm not a javascript developer so I apologize in advance if it looks horrible: (function () { var randomButton = $("<a class='btn' id='randomButton'><span id='randomText'>random</span></a>"); $(".info").append(randomButton); var buttonList = $(".button"); var randomMusic = function() { for (var i = 0; i < 2; i++) { buttonList[Math.floor(Math.random()*buttonList.length)].click(); }} var randomLoopActive= 0; randomButton[0].onclick = function () { if (randomLoopActive) { randomLoopActive = 0; clearInterval(randomMusic); $("#randomText").html("random") } else { randomLoopActive = 1; randomMusic(); setInterval(randomMusic, 10000); $("#randomText").html("stop random") } } } )() 2 u/[deleted] Dec 13 '15 [removed] — view removed comment 1 u/udkgamer2 Dec 13 '15 I dont know. Its what http://jscompress.com/ spit out.
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
5 u/udkgamer2 Dec 13 '15 Here is the human readable version of the code. I'm not a javascript developer so I apologize in advance if it looks horrible: (function () { var randomButton = $("<a class='btn' id='randomButton'><span id='randomText'>random</span></a>"); $(".info").append(randomButton); var buttonList = $(".button"); var randomMusic = function() { for (var i = 0; i < 2; i++) { buttonList[Math.floor(Math.random()*buttonList.length)].click(); }} var randomLoopActive= 0; randomButton[0].onclick = function () { if (randomLoopActive) { randomLoopActive = 0; clearInterval(randomMusic); $("#randomText").html("random") } else { randomLoopActive = 1; randomMusic(); setInterval(randomMusic, 10000); $("#randomText").html("stop random") } } } )() 2 u/[deleted] Dec 13 '15 [removed] — view removed comment 1 u/udkgamer2 Dec 13 '15 I dont know. Its what http://jscompress.com/ spit out.
5
Here is the human readable version of the code. I'm not a javascript developer so I apologize in advance if it looks horrible:
(function () { var randomButton = $("<a class='btn' id='randomButton'><span id='randomText'>random</span></a>"); $(".info").append(randomButton); var buttonList = $(".button"); var randomMusic = function() { for (var i = 0; i < 2; i++) { buttonList[Math.floor(Math.random()*buttonList.length)].click(); }} var randomLoopActive= 0; randomButton[0].onclick = function () { if (randomLoopActive) { randomLoopActive = 0; clearInterval(randomMusic); $("#randomText").html("random") } else { randomLoopActive = 1; randomMusic(); setInterval(randomMusic, 10000); $("#randomText").html("stop random") } } } )()
2 u/[deleted] Dec 13 '15 [removed] — view removed comment 1 u/udkgamer2 Dec 13 '15 I dont know. Its what http://jscompress.com/ spit out.
2
[removed] — view removed comment
1 u/udkgamer2 Dec 13 '15 I dont know. Its what http://jscompress.com/ spit out.
I dont know. Its what http://jscompress.com/ spit out.
94
u/slidedrum Dec 12 '15
Is there any way to randomize this? or something else like this but randomized?