/* * PennyArcade - a template to display the past days of penny arcade comics. * * Optional params: * * (int) numDays: number of past days to display. Penny Arcade isn't published on a daily basis, * so it might make sense to set this to a few days. (default: 4) (maximum: 8) * */ function PennyArcade(comicData) { this.data = comicData; this.id = this.data.guid; this.numDays = (this.data.days) ? this.data.days : 4 this.months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; } PennyArcade.prototype.init = function() { dNow = new Date(); for (i = 0; i < this.numDays && i < 8; i++) { d = new Date(dNow.getTime() - (i * 1000 * 60 * 60 * 24)); this.showComic(d); } } PennyArcade.prototype.showComic = function(date) { var year = date.getUTCFullYear(); var month = this.months[date.getUTCMonth()]; var day = (date.getUTCDate() < 10) ? '0' + date.getUTCDate().toString() : date.getUTCDate(); var img = ''; img += '<a target="_blank" href="http://www.penny-arcade.com/comic/' + year + '/' + month + '/' + day + '">' + '<img src="http://www.penny-arcade.com/images/'; img += year + '/' + year + month + day; img += '.jpg"></a>'; $(this.id).innerHTML += img; $A($(this.id).getElementsByTagName('img')).each(function(img) { img.style.display = 'none'; }); $A($(this.id).getElementsByTagName('img')).each(function(img) { img.onload = function() { this.style.display = 'inline'; }; }); };