;(function(LuckyLocation, _, session){ /** * @class Change password form * @requiresDOM .notificationsContainer * @requires portalGGA.utils.globalErrorNotifier * @author Siva.Nanduri@gtechg2.com * @author Tomek.Wytrebowicz@gtech.com * @author Michal.Kunikowski@gtech.com * @extends {Backbone.View} * @view */ portalGGA.views.NewsWinner= Backbone.View.extend( /** @lends portalGGA.views.ForgotPassword.prototype */{ /** * [constructor description] * @param {Object} [options] (see {@link Backbone.View.constructor}) * @param {portalGGA.models.player.ForgottenPassword} [options.forgottenPassword] If none given, `new portalGGA.models.player.ForgottenPassword` will be used. * @param {portalGGA.models.player.SecurityQuestions} [options.securityQuestions] If none given, `new portalGGA.models.player.SecurityQuestions` will be used. * @param {Object} [options.dictionary] Dictionary to map back-end security questions' names. */ constructor: function NewsWinner(options) { Backbone.View.apply(this, arguments); this.el=options.el; this._displayWinner(); }, _displayWinner: function _displayWinner(){ var self = this; var todayDate = new Date(); var fileDate= sessionStorage.getItem("fileDate"); var yesterdayDate = todayDate.setDate(todayDate.getDate() - 1); // var yesterdayTime = yesterdayDate.getTime(); var zoneVal = "America/New_York"; var yesterday = moment.tz(parseInt(yesterdayDate), zoneVal).format("L"); var day = yesterday.split("/")[1]; var month = yesterday.split("/")[0]; var year = yesterday.split("/")[2]; self.fulldate = year+month+day; var csvData; // if(fileDate != self.fulldate ){ self.csvUrl = "/content/dam/portal/csv/winner_info_lws_nj.csv?"+self.fulldate; var urlExistBool=self.urlExist(self.csvUrl); // } }, urlExist : function urlExist(urlData){ var exist =false; var self = this; //file exists exist = true; $.ajax({ type: "GET", url: self.csvUrl, dataType: "text", success: function(data) { if(data.indexOf("html") == -1){ self.processData(data); } } }); return exist; }, processData: function processData(dataVal){ var productId = []; var count =[]; var amount = []; if(dataVal != null){ var splitData = dataVal.split(/\r?\n|\r/); var commaSeperator = ","; if(splitData.indexOf("|")!= -1) commaSeperator = "|"; for (var singleRow = 0; singleRow < splitData.length; singleRow++) { var rowCells = splitData[singleRow].split(commaSeperator); if(rowCells[0]) productId.push(rowCells[0]); if(rowCells[1]) count.push(rowCells[1]); if(rowCells[2]) amount.push(rowCells[2]); } $('.news-winner').html(newsWinnerTemplate({winAmt:amount,winnerTotal:count,productId:productId})); } } }); }(portalGGA.models.LuckyLocation, _, portalGGA.utils.session))