Created
May 2, 2014 22:57
-
-
Save QuincyLarson/6d6f45e28061b023c1a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomCallback(success, content) { | |
if (success) { | |
for (var i = 0; i < content.hits.length; ++i) { | |
window.location.assign("/?id=" + content.hits[0].id); | |
} | |
} | |
} | |
$('#random_button').click(function(e) { | |
var index = client.initIndex('#{Clip.index_name}') | |
var random_page = (Math.floor(Math.random() * 999) + 1); | |
index.search('', randomCallback, { "hitsPerPage": 1, "page": random_page}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment