Skip to content

Instantly share code, notes, and snippets.

@holtbp
Created April 2, 2012 20:56
Show Gist options
  • Save holtbp/2287149 to your computer and use it in GitHub Desktop.
Save holtbp/2287149 to your computer and use it in GitHub Desktop.
Turntable (In Progress) - Attempt to make a closure without using the TTFM API
ttfm = {
awesome: null,
lame: null,
setButtons: function() {
var awesome, lame;
$('div.roomView > div > a').each(function() {
if ($(this).css('top') === '555px') {
if ($(this).css('left') === '370px') {
this.awesome = $(this);
} else {
this.lame = $(this);
}
}
});
},
autoAwesome: function() {
setTimeout(this.simulateClick(this.awesome), 30000);
},
autoLame: function() {
setTimeout(this.simulateClick(this.lame), 30000);
},
reset: function() {
this.awesome = null;
this.lame = null;
},
simulateClick: function(element) {
var offset = element.offset(),
event = $.extend($.Event("mousedown"), {
which: 1,
pageX: offset.left,
pageY: offset.top
});
element.trigger(event);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment