defaults : { answerstopic : [], startCount: '1', endCount : '5', ex : 1, currentState: 'popular', skn : 'condition', t:'', st:'See What Others Are Asking', v: 1 },
// will be merged defaults and passed in params params : {},
init : function(params) {
// merging defaults with params that are passed in this.params = $.extend({}, this.defaults, params);
// a parse url function will go here to provide these from the xsl this.parseUrlParams();
// override api data for testing - commented out for now // this.params.skn = '' // this.params.cfg = 'hp'; // this.params.t = ''; // this.params.st = 0; // this.params.btn = 1; // this.params.v = 0; // this.params.ex = 1;
if (this.params.apiState == 'most_recent') { this.params.currentState = 'recent'; this.params.mostRecentData = this.params.cachedData; this.params.mostRecentSuccess = true; } else if (this.params.apiState == 'helpful') { this.params.currentState = 'popular'; this.params.mostPopularData = this.params.cachedData; this.params.mostPopularSuccess = true; }
// render this.render(); this.params.mostPopularData = null; this.params.mostRecentData = null; },
parseUrlParams : function() { var urlParts = this.params.rssUrl.split('?'), self = this; // save this info from the baseURL var baseUrlParts = urlParts[0].split('/'); self.params.apiType = baseUrlParts[7]; self.params.apiState = baseUrlParts[9]; self.params.startCount = baseUrlParts[10]; self.params.endCount = baseUrlParts[11]; self.params.apiAnswerTopics = baseUrlParts[12];
// save query string params var secondPair = urlParts[1].split('/'); $.each(secondPair,