/* index.js */ var NewsPreviews = new Class({ Implements: [Options], options: {}, buildNewsPreviews: function(x) { var self = this; x.each(function(item,index,array) { index = index + 1; if (index <= 4) { var iconDiv = new Element('div', { 'class': item.icon, 'id': "newsIcon_" + index }); var textDiv = new Element('div', { 'class': "newsTexts", 'id': "newsText_" + index }); var headerLink = new Element('a', { 'href': "pressRoom.php", 'class': "smallText textWhite" }); var header = new Element('h2', { html: item.head }); var body = new Element('p', { html: item.body.slice(0,item.body.lastIndexOf(" ",57))+"..." }) headerLink.adopt(header); textDiv.adopt(headerLink, body); $('boxesRight').adopt(iconDiv, textDiv); } }); }, retrieveNewsData: function() { var self = this; var myRequest = new Request.JSON({ url: '../../backend/retrieveNewsData.py', onSuccess: function(responseJSON, responseText) { self.buildNewsPreviews(responseJSON) } }).send(); }, initialize: function() { this.setOptions(); this.retrieveNewsData(); } }); window.addEvent('domready', function() { var indexOne = new NewsPreviews(); });