Great new script for you Chuck Norris lovers - the plugin that will freak you out! Do you want your developers to log into Fogbugz more often? Well, this will give them a real reason. Introducing the "Chuck Norris Jokes Rotator"!!
Enjoy!
name: Chuck Norris Jokes Rotator
description: Adds some Chuck Norris jokes on top
author: Gal Segal
version: 1.0.0.0
js:
(function($){
$.fn.chuckIt = function(options) {
var plugin = function(container) {
this.container = container;
this.container.css({
color: '#000',
position:'absolute',
top:'0',
left:'10px',
display:'inline'
});
this.options = $.extend({}, this.defaults, options);
};
plugin.prototype = {
updateInterval:undefined,
container:undefined,
defaults: {
interval:10000
},
start: function() {
var self = this;
$.ajax({
url: "http://code.icndb.com/jquery.icndb.min.js",
dataType: "script",
success: function(d) {
self.setInterval();
self.updateJoke();
}
});
},
setInterval: function () {
this.updateInterval = setInterval($.proxy(this.updateJoke, this), this.options.interval);
},
clearInterval: function() {
clearInterval(this.updateInterval);
},
updateJoke: function() {
var self = this;
this.clearInterval();
$.icndb.getRandomJoke({
success:function(joke){
console.log(self);
self.container.fadeOut(500, function(){
self.container.html(joke.joke)
.fadeIn(500);
});
self.setInterval();
}
});
}
};
$(this).each(function(i, v) {
var pluginInstance = new plugin($(v));
pluginInstance.start();
});
};
})(jQuery);
$(document).ready(function(){
$('<div id="joke"></div>').appendTo('#banner').chuckIt();
});