Let's begin by defining the structure of the JavaScript object that we will need to perform various tasks. Open the js/dashboard.js
file and write the following code:
$(document).ready(function() { var dashboard = { imageArr : [], init : function() { this.initPortlets(); this.initSharing(); this.initFlickr(); this.initReddit(); this.setupWeather(); this.setupImageSelector(); }, initPortlets : function() { }, initSharing : function() { }, initFlickr : function() { }, initReddit : function() { }, setupWeather : function() { }, setupImageSelector : function() { } } dashboard.init(); });
We start off by creating a dashboard object and defining an array named imageArr
and six methods. The imageArr
array will be populated when we create the fourth portlet and display images.
Among the methods, the first method is init
, which acts as...