Created
October 18, 2014 21:04
-
-
Save DarrenCattle/fb70c19f83f2dcf0ba2c 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
var jq = document.createElement('script'); | |
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
var square = (function () { | |
var sp = {}; | |
sp.draw = function() { | |
console.log('hi dcat'); | |
//place matrix single click in the grid | |
var self = this; | |
this.post = []; | |
var delay = 400; | |
for(var a = 0; a < this.list.length; a++) { | |
setTimeout( | |
(function(a) { | |
return function() { | |
if($('.col_' + self.list[a].y + '_' + self.list[a].x).style.backgroundColor) { | |
self.post.push({"x": self.list[a].x, "y": self.list[a].y}); | |
$('.col_' + self.list[a].y + '_' + self.list[a].x).click();} | |
$('.col_' + self.list[a].y + '_' + self.list[a].x).click(); | |
console.log("coordinates: " + self.list[a].x + " , " + self.list[a].y); | |
} | |
})(a), delay); | |
delay += 400; | |
} | |
}; | |
sp.finish = function () { | |
//run separately to fill spaces of array | |
var delay=400; | |
var self = this; | |
for(var a = this.post.length-1; a >= 0; a--) { | |
setTimeout( | |
(function(a) { | |
return function() { | |
$('.col_' + self.post[a].y + '_' + self.post[a].x).click(); | |
console.log("coordinates: " + self.post[a].x + " , " + self.post[a].y); | |
} | |
})(a), delay); | |
delay += 400; | |
} | |
}; | |
sp.init = function(ix,iy,len) { | |
this.ix = ix; this.iy = iy; this.len = len; | |
var lastx = this.ix; var lasty = this.iy; | |
this.list = []; | |
//matrix calculation of spiral | |
for (var a = 0; a < len; a++) { | |
for (var b = 0; b < len; b++) { | |
this.list.push({"x": lastx+a,"y": lasty+b}); | |
} | |
} | |
this.draw(); | |
}; | |
return sp; | |
})(); | |
//usage | |
//square.init(x,y,size); | |
//square.finish(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment