Skip to content

Instantly share code, notes, and snippets.

@ophentis
Last active July 7, 2021 07:26
Show Gist options
  • Save ophentis/7a0e8079f7f66cdb9c1e to your computer and use it in GitHub Desktop.
Save ophentis/7a0e8079f7f66cdb9c1e to your computer and use it in GitHub Desktop.
!function go() {
return $('#grid div')
.get()
.map(function(div) { return {v:div.innerText|0,div:div} })
.filter(function(box) { return box.v })
.sort(function(a,b) { return a.v - b.v })
.reduce(function(p,box) {
return p.then(function() {
return new Promise(function(resolve, reject) {
$(box.div).trigger('tap')
setTimeout(resolve.bind(null,box))
});
})
},Promise.resolve())
.then(function(more) {
return more && go()
})
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment