/** * Widget to display tabbed oa widget * Required Attributes: * - app (which application to run) * - kind (which model to run) * * Example client call: *
* */ var oapartners = angular.module("oapartners", ['common', 'OAFactory', 'LocationsFactory', 'ngDialog']) .controller('Ctrl', function ($scope, $filter, $q, $http, $window, LocationsData, OAData, ngDialog) { //load evironment config -- this file is used to load the configuration object: /Affiliate Center/Avalon/widgets.bankrate.com-dev/js/services/envconfig.js $scope.$watch(function(){return $window.bankrateEnvConfig;}, function(){ $scope.bankrateEnvConfig = $window.bankrateEnvConfig; }); $scope.$watch('clientconfigid', function () { $scope.attr = config.tcfg[$scope.clientconfigid]; $scope.technicaldifficulties = false; //credit card dropdown $scope.ccprod = "/credit-cards/0-interest-apr-cards.aspx"; $scope.ccprodsoptions = { //by Card Types: "72": { name: "Airline Cards", url: "//www.bankrate.com/credit-cards/airline-miles-cards.aspx" }, "81": { name: "Student Cards", url: "//www.bankrate.com/credit-cards/student-cards.aspx" }, "82": { name: "Instant Approval Credit Cards", url: "" }, "83": { name: "Low Interest Cards", url: "//www.bankrate.com/credit-cards/low-interest-cards.aspx" }, "100": { name: "Reward Cards", url: "//www.bankrate.com/credit-cards/rewards-cards.aspx" }, "101": { name: "Cash Back Cards", url: "//www.bankrate.com/credit-cards/cash-back-cards.aspx" }, "102": { name: "Business Cards", url: "//www.bankrate.com/credit-cards/business-cards.aspx" }, "103": { name: "Prepaid & Debit Cards", url: "//www.bankrate.com/credit-cards/prepaid-debit-cards.aspx" }, "105": { name: "Balance Transfer Cards", url: "//www.bankrate.com/credit-cards/balance-transfer-cards.aspx" }, "232": { name: "Gas Cards", url: "//www.bankrate.com/credit-cards/gas-cards.aspx" }, "474": { name: "0% APR Cards", url: "////www.bankrate.com/credit-cards/0-interest-apr-cards.aspx" }, "507": { name: "Secured Cards", url: "//www.bankrate.com/credit-cards/secured-cards.aspx" }, "517": { name: "No Annual Fee Cards", url: "//www.bankrate.com/credit-cards/no-annual-fee-cards.aspx" }, "519": { name: "No Foreign Fransaction Fee Cards", url: "//www.bankrate.com/credit-cards/no-foreign-transaction-fee-cards.aspx" }, //by Creditd Types: "236": { name: "Excellent Credit", url: "//www.bankrate.com/credit-cards/excellent-credit-cards.aspx" }, "237": { name: "Good Credit", url: "//www.bankrate.com/credit-cards/good-credit-cards.aspx" }, "238": { name: "Fair Credit", url: "//www.bankrate.com/credit-cards/fair-credit-cards.aspx" }, "130": { name: "Bad Credit", url: "//www.bankrate.com/credit-cards/bad-credit-cards.aspx" }, //by Card Issuers: "107": { name: "American Express Credit Cards", url: "//www.bankrate.com/credit-cards/american-express-cards.aspx" }, "108": { name: "Bank of America Credit Cards", url: "//www.bankrate.com/credit-cards/bank-of-america-cards.aspx" }, "280": { name: "Barclaycard Cards", url: "//www.bankrate.com/credit-cards/barclaycard-cards.aspx" }, "137": { name: "Capital One Credit Cards", url: "//www.bankrate.com/credit-cards/capital-one-cards.aspx" }, "109": { name: "Chase Credit Cards", url: "//www.bankrate.com/credit-cards/chase-cards.aspx" }, "110": { name: "Citi Credit Cards", url: "//www.bankrate.com/credit-cards/citi-cards.aspx" }, "111": { name: "Discover Credit Cards", url: "//www.bankrate.com/credit-cards/discover-cards.aspx" }, "114": { name: "MasterCard Credit Cards", url: "//www.bankrate.com/credit-cards/mastercard-cards.aspx" }, "115": { name: "Visa Credit Cards", url: "//www.bankrate.com/credit-cards/visa-cards.aspx" }, //best credit card "11": { name: "Sports Cards", url: "//www.bankrate.com/credit-cards/best-credit-cards" }, "12": { name: "Charge Cards", url: "//www.bankrate.com/credit-cards/best-credit-cards" }, "18": { name: "Bad Credit", url: "//www.bankrate.com/credit-cards/bad-credit-cards.aspx" }, "26": { name: "HSBC Credit Cards", url: "//www.bankrate.com/credit-cards/best-credit-cards" } }; //cd dropdown options $scope.cdprod = ''; $scope.cdprodsoptions = { "": { name: "-- select --", slug: "", order: 0 }, "15": { name: "1 Yr CD", slug: "1_Yr_CD", order: 1 }, "24": { name: "1 Yr Jumbo CD", slug: "1_Yr_Jumbo", order: 2 }, "13": { name: "3 Mo. CD", slug: "3_Mo_CD", order: 3 }, "19": { name: "5 Yr CD", slug: "5_Yr_CD", order: 4 }, "14": { name: "6 Mo. CD", slug: "6_Mo_CD", order: 5 }, "33": { name: "MMA", slug: "MMA", order: 6 }, "37": { name: "MMA Jumbo", slug: "MMA_Jumbo", order: 7 } }; //widget width $scope.attr.widgetwidth = $scope.attr.widgetwidth || ''; //Template in use $scope.attr.template = $scope.attr.template|| "default"; /* override style, customizations */ //widget $scope.attr.footertemplate = $scope.attr.footertemplate || ''; $scope.attr.activetabstyle = $scope.attr.activetabstyle || ''; $scope.attr.cdzipinput = $scope.attr.cdzipinput || ''; $scope.attr.savzipinput = $scope.attr.savzipinput || ''; // Set showlocal to a string not matching false and they locals will show $scope.attr.showlocal = $scope.attr.showlocal || 'false'; $scope.attr.fontfamily = $scope.attr.fontfamily || ''; $scope.attr.backgroundcolor = $scope.attr.backgroundcolor || ''; $scope.attr.widgetWrapperStyle = {}; if ($scope.attr.fontfamily) { $scope.attr.widgetWrapperStyle['font-family'] = $scope.attr.fontfamily; } if ($scope.attr.backgroundcolor) { $scope.attr.widgetWrapperStyle['background-color'] = $scope.attr.backgroundcolor; } if ($scope.attr.color) { $scope.attr.widgetWrapperStyle['color'] = $scope.attr.color; } if ($scope.attr.border) { $scope.attr.widgetWrapperStyle['border'] = $scope.attr.border; } if ($scope.attr.fontsize) { $scope.attr.widgetWrapperStyle['font-size'] = $scope.attr.fontsize; } // Header Style of the widget $scope.widgetheader = $scope.attr.headertext || "Rates from Bankrate.com"; $scope.attr.headerStyle = {}; if ( $scope.attr.headerdisplay ) { $scope.attr.headerStyle['display'] = $scope.attr.headerdisplay; } if ( $scope.attr.headercolor ) { $scope.attr.headerStyle['color'] = $scope.attr.headercolor; } if ( $scope.attr.headerbackground ) { $scope.attr.headerStyle['background'] = $scope.attr.headerbackground; } if ( $scope.attr.headerpadding ) { $scope.attr.headerStyle['padding'] = $scope.attr.headerpadding; } if ( $scope.attr.headersize ) { $scope.attr.headerStyle['font-size'] = $scope.attr.headersize; } if ( $scope.attr.headerweight ) { $scope.attr.headerStyle['font-weight'] = $scope.attr.headerweight; } // Tabs list ul $scope.attr.ultabsStyle = {}; if ($scope.attr.ultabbgcolor) { $scope.attr.ultabsStyle['background-color'] = $scope.attr.ultabbgcolor; } //tabs $scope.attr.activetabtextcolor = $scope.attr.activetabtextcolor || ''; $scope.attr.activetabbackgroundcolor = $scope.attr.activetabbackgroundcolor || ''; var activeTabStyle = {}; if ($scope.attr.activetabtextcolor) { activeTabStyle['color'] = $scope.attr.activetabtextcolor; } if ($scope.attr.activetabbackgroundcolor) { activeTabStyle['background-color'] = $scope.attr.activetabbackgroundcolor; } if ($scope.attr.activetabfontsize) { activeTabStyle['font-size'] = $scope.attr.activetabfontsize; } if ($scope.attr.activetabborder) { activeTabStyle['border'] = $scope.attr.activetabborder; } if ($scope.attr.activetabpadding) { activeTabStyle['padding'] = $scope.attr.activetabpadding; } if ($scope.attr.activetabwidth) { activeTabStyle['width'] = $scope.attr.activetabwidth; } $scope.attr.offtabtextcolor = $scope.attr.offtabtextcolor || ''; $scope.attr.offtabbackgroundcolor = $scope.attr.offtabbackgroundcolor || ''; var offTabStyle = {}; if ($scope.attr.offtabtextcolor) { offTabStyle['color'] = $scope.attr.offtabtextcolor; } if ($scope.attr.offtabbackgroundcolor) { offTabStyle['background-color'] = $scope.attr.offtabbackgroundcolor; } if ($scope.attr.offtabfontsize) { offTabStyle['font-size'] = $scope.attr.offtabfontsize; } if ($scope.attr.offtabpadding) { offTabStyle['padding'] = $scope.attr.offtabpadding; } if ($scope.attr.offtabwidth) { offTabStyle['width'] = $scope.attr.offtabwidth; } if ($scope.attr.offtabtextalign) { offTabStyle['text-align'] = $scope.attr.offtabtextalign; } //Tab block style $scope.attr.tabblockStyle = {}; if ($scope.attr.tabblockpadding) { $scope.attr.tabblockStyle['padding'] = $scope.attr.tabblockpadding; } //Tab body Style $scope.attr.tabbodyStyle = {}; if ($scope.attr.tabbodyborder) { $scope.attr.tabbodyStyle['border'] = $scope.attr.tabbodyborder; } //title bar $scope.attr.titleBarStyle = {}; if ($scope.attr.titlebarbackgroundcolor) { $scope.attr.titleBarStyle['background-color'] = $scope.attr.titlebarbackgroundcolor; } if ($scope.attr.titlefontsize) { $scope.attr.titleBarStyle['font-size'] = $scope.attr.titlefontsize; } if ($scope.attr.titleborder) { $scope.attr.titleBarStyle['border'] = $scope.attr.titleborder; } if ($scope.attr.titlebartextcolor) { $scope.attr.titleBarStyle['color'] = $scope.attr.titlebartextcolor; } if ($scope.attr.titlemargin) { $scope.attr.titleBarStyle['margin'] = $scope.attr.titlemargin; } $scope.attr.lastupdatedtextStyle = {}; if ($scope.attr.lastupdatedtextcolor) { $scope.attr.lastupdatedtextStyle['color'] = $scope.attr.lastupdatedtextcolor; } if ($scope.attr.lastupdateddisplay) { $scope.attr.lastupdatedtextStyle['display'] = $scope.attr.lastupdateddisplay; } //Table header style $scope.attr.theaderStyle = {}; if ($scope.attr.theadercolor) { $scope.attr.theaderStyle['color'] = $scope.attr.theadercolor; } if ($scope.attr.theaderfont) { $scope.attr.theaderStyle['font-size'] = $scope.attr.theaderfont; } // The third column value style $scope.attr.changevalueStyle = {}; if ($scope.attr.changevaluedisplay) { $scope.attr.changevalueStyle['display'] = $scope.attr.changevaluedisplay; } $scope.attr.nextbuttonbackgroundcolor = $scope.attr.nextbuttonbackgroundcolor || ''; $scope.attr.nextbuttoncolor = $scope.attr.nextbuttoncolor || ''; $scope.attr.nextButtonStyle = {}; if ($scope.attr.nextbuttonbackgroundcolor) { $scope.attr.nextButtonStyle['background-color'] = $scope.attr.nextbuttonbackgroundcolor; } if ($scope.attr.nextbuttoncolor) { $scope.attr.nextButtonStyle['color'] = $scope.attr.nextbuttoncolor; } //Source div $scope.attr.sourcedivStyle = {}; if ($scope.attr.sourcedivmargin) { $scope.attr.sourcedivStyle['margin'] = $scope.attr.sourcedivmargin; } if ($scope.attr.sourcedivfloat) { $scope.attr.sourcedivStyle['float'] = $scope.attr.sourcedivfloat; } if ($scope.attr.sourcedivalign) { $scope.attr.sourcedivStyle['text-align'] = $scope.attr.sourcedivalign; } //Bankrate link $scope.attr.bankratelinkStyle = {}; if ($scope.attr.bankratelinkcolor) { $scope.attr.bankratelinkStyle['color'] = $scope.attr.bankratelinkcolor; } $scope.attr.linksStyle = {}; if ($scope.attr.linkscolor) { $scope.attr.linksStyle['color'] = $scope.attr.linkscolor; } if ($scope.attr.linkspadding) { $scope.attr.linksStyle['padding'] = $scope.attr.linkspadding; } if ($scope.attr.linksfontsize) { $scope.attr.linksStyle['font-size'] = $scope.attr.linksfontsize; } //Button Footer Style $scope.attr.buttonfooterStyle = {}; if ($scope.attr.buttonfooterminheight) { $scope.attr.buttonfooterStyle['min-height'] = $scope.attr.buttonfooterminheight; } $scope.attr.poweredby = $scope.attr.poweredby || "text"; $scope.attr.poweredbylogo = $scope.attr.poweredbylogo || "//www.bankrate.com/images/brm_logos/bankrate-logo.gif"; $scope.attr.poweredbylink = $scope.attr.poweredbylink || "//www.bankrate.com"; $scope.attr.poweredbytext = $scope.attr.poweredbytext || "Bankrate.com"; //set partner id and key $scope.attr.pid = $scope.attr.pid || ""; $scope.attr.pkey = $scope.attr.pkey || ""; $scope.attr.pid_add = $scope.attr.pid.length > 0 ? '?pid=' + $scope.attr.pid : ''; $scope.attr.pid_extend = $scope.attr.pid.length > 0 ? '&pid=' + $scope.attr.pid : ''; //set oa location type $scope.attr.oalocationtype = $scope.attr.oalocationtype || "national"; if ($scope.attr.oalocationtype == 'national') { $scope.nationaloabgcolor = "{ 'background-color': 'Blue' }"; $scope.localoabgcolor = "{ 'background-color': 'Grey' }"; } else { $scope.nationaloabgcolor = "{ 'background-color': 'Grey' }"; $scope.localoabgcolor = "{ 'background-color': 'Blue' }"; } //set default prods filter $scope.attr.autoprods = $scope.attr.autoprods || "73,74,39,42,40,41,311,278"; //others: 276,277; $scope.attr.cdprods = $scope.attr.cdprods || "18,14,15,19,24,147,13,16"; //other CD Ids: 17,20,21,22,23,25,26,27,28,29,30,33,34,35,36,37,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,76,77,78,79,80,145,159,160,162,163,164,208,439,440,441,442,499,500,501,502,516,517,518,519; $scope.attr.savprods = $scope.attr.savprods || "18,14,15,19,24,147,13,16"; $scope.attr.ccprods = $scope.attr.ccprods || "83,105,81,101,72,232,100,102,130,11,12,507,236,237,238,109,111,110,137,108,107,26,115,114"; $scope.attr.mtgprods = $scope.attr.mtgprods || "1,2,4,6,9,165,388,387,216,215,222,219,220,393,392"; //others: 5,8,389 390 391 447 449 459 460 461 462 463 508 565 566; $scope.attr.refinanceprods = $scope.attr.refinanceprods || "1,2,4,6,9,165,388,387,216,215,222,219,220,393,392"; //others: 217 218 221 223 224 265 394 425 426 448 450 479 480 481 482 483 512; // PID builder to append pids in the template if you need them. if ($scope.attr.pid.length > 0) { $scope.$watch(function () { return document.getElementById($scope.clientconfigid).getElementsByTagName('a').length; }, function () { var pidAnchors = document.getElementById($scope.clientconfigid).getElementsByTagName('a'); var pidUrlPattern = new RegExp('^(https?)://([^/?]+)(\\?*)'); var r = new RegExp('builder.html.*id=' + $scope.attr.frameid); for (var i = 0; i < pidAnchors.length; i++) { var anchor = pidAnchors[i]; if (r.test(anchor.href) || !pidUrlPattern.test(anchor.href)) { continue; } var m = pidUrlPattern.exec(anchor.href); if (typeof m[2] == 'undefined' || !m[2].match(/bankrate/)) { continue; } if (anchor.href.match(/pid=/)) { anchor.href = anchor.href.replace(/(pid=)[^&]+/, "pid=" + $scope.attr.pid); continue; } if (anchor.href.match(/%7B%7B(attr.pid_(extend|add))%7D%7D/)) { anchor.href.replace(/%7B%7B(attr.pid_(extend|add))%7D%7D/g, function () { return $scope.attr['pid_' + arguments[2]]; }); continue; } if (anchor.href.match(/\?/)) { anchor.href += $scope.attr.pid_extend; } else { anchor.href += $scope.attr.pid_add; } } }); } //set required tabs $scope.attr.tabs = $scope.attr.tabs || ["mortgage", "cd", "creditcard", "auto"]; if (typeof $scope.attr.tabs == "string") { $scope.attr.tabs = $scope.attr.tabs.split(','); } $scope.attr.tabs = angular.fromJson($scope.attr.tabs); //set initial default tab if (!$scope.attr.defaulttab || ($scope.attr.tabs && $scope.attr.tabs.indexOf($scope.attr.defaulttab) < 0)) { if ($scope.attr.tabs && $scope.attr.tabs.length > 0) { $scope.attr.defaulttab = $scope.attr.tabs[0]; } } //mortgage params/config $scope.attr.mtgtablabel = $scope.attr.mtgtablabel || 'Mortgage'; $scope.attr.mtgzipcode = parseInt($scope.attr.zipcode) || ''; $scope.attr.mtgnumrows = $scope.attr.mtgnumrows || '1000000'; $scope.attr.mtgtitlebar = $scope.attr.mtgtitlebar || 'Mortgage Rate Averages'; //cd params/config $scope.attr.cdtablabel = $scope.attr.cdtablabel || 'CDs'; /* $scope.attr.cdzipcode = $scope.attr.cdzipcode || '';*/ $scope.attr.cdnumrows = $scope.attr.cdnumrows || '1000000'; $scope.attr.cdtitlebar = $scope.attr.cdtitlebar || 'CD Rate Averages'; //savings params/config $scope.attr.savtablabel = $scope.attr.savtablabel || 'Savings'; /* $scope.attr.savzipcode = $scope.attr.savzipcode || '';*/ $scope.attr.savnumrows = $scope.attr.savnumrows || '1000000'; $scope.attr.savtitlebar = $scope.attr.savtitlebar || 'Savings Rate Averages'; //cc params/config $scope.attr.cctablabel = $scope.attr.cctablabel || 'Credit Cards'; $scope.attr.ccnumrows = $scope.attr.ccnumrows || '1000000'; //auto params/config $scope.attr.autotablabel = $scope.attr.autotablabel || 'Auto'; $scope.attr.autozipcode = $scope.attr.zipcode || ''; $scope.attr.autonumrows = $scope.attr.autonumrows || '1000000'; //refinance params/config $scope.attr.refinancetablabel = $scope.attr.refinancetablabel || 'Refinance'; $scope.attr.refinancezipcode = $scope.attr.zipcode || ''; $scope.attr.refinancenumrows = $scope.attr.refinancenumrows || '1000000'; //personal loans params/config $scope.attr.perloantablabel = $scope.attr.perloantablabel || 'Personal Loans'; $scope.errorStyle = "display:none;"; $scope.mtgzipcode = "Enter ZIP Code"; $scope.cdzipcode = "Enter ZIP Code"; $scope.savzipcode = "Enter ZIP Code"; $scope.cczipcode = "Enter ZIP Code"; $scope.autozipcode = "Enter ZIP Code"; $scope.refinancezipcode = "Enter ZIP Code"; $scope.onZipFieldClick = function () { switch ($scope.activeTab) { case 'mortgage': if (this.mtgzipcode == "Enter ZIP Code" || this.mtgzipcode == "Invalid Zip") { this.mtgzipcode = ""; } break; case 'cd': if (this.cdzipcode == "Enter ZIP Code" || this.cdzipcode == "Invalid Zip") { this.cdzipcode = ""; } break; case 'savings': if (this.savzipcode == "Enter ZIP Code" || this.savzipcode == "Invalid Zip") { this.savzipcode = ""; } break; case 'creditcard': if (this.cczipcode == "Enter ZIP Code" || this.cczipcode == "Invalid Zip") { this.cczipcode = ""; } break; case 'auto': if (this.autozipcode == "Enter ZIP Code" || this.autozipcode == "Invalid Zip") { this.autozipcode = ""; } break; case 'refinance': if (this.refinancezipcode == "Enter ZIP Code" || this.refinancezipcode == "Invalid Zip") { this.refinancezipcode = ""; } break; } } $scope.onLocalButtonClick = function () { //reset oa location type $scope.attr.oalocationtype = "local"; $scope.nationaloabgcolor = "{ 'background-color': 'Grey' }"; $scope.localoabgcolor = "{ 'background-color': 'Blue' }"; $scope.displayTabContent($scope.activeTab); } $scope.onNatioanlButtonClick = function () { //reset oa location type $scope.attr.oalocationtype = "national"; $scope.nationaloabgcolor = "{ 'background-color': 'Blue' }"; $scope.localoabgcolor = "{ 'background-color': 'Grey' }"; $scope.displayTabContent($scope.activeTab); } $scope.onNextButtonClick = function () { switch ($scope.activeTab) { case 'mortgage': if (this.isValidZipcode(this.mtgzipcode)) { var url = "prods=1&zip=" + this.mtgzipcode + "&pid=" + $scope.attr.pid + "&ic_id=OA_OvernightAverages_13_Mortgage__default.aspx_" + this.mtgzipcode; window.open("//www.bankrate.com/funnel/mortgages/mortgage-results.aspx?" + url); } else { this.mtgzipcode = "Invalid Zip"; } break; case 'cd': if (this.cdprod) { if (this.cdprod == "33" || this.cdprod == "37") { var url = "local=false&prods=" + this.cdprod + "&pid=" + $scope.attr.pid + "&tab=MMA&ic_id=OA_OvernightAverages_13_CDs_" + this.cdprod + "_" + $scope.cdprodsoptions[this.cdprod].slug + "_default.aspx_"; window.open("//www.bankrate.com/funnel/savings/savings-results.aspx?" + url); } else { var url = "local=false&prods=" + this.cdprod + "&pid=" + $scope.attr.pid + "&tab=CD&ic_id=OA_OvernightAverages_13_CDs_" + this.cdprod + "_" + $scope.cdprodsoptions[this.cdprod].slug + "_default.aspx_"; window.open("//www.bankrate.com/funnel/cd-investments/cd-investment-results.aspx?" + url); } } break; case 'savings': if (this.savprod) { if (this.savprod == "33" || this.savprod == "37") { var url = "local=false&prods=" + this.savprod + "&pid=" + $scope.attr.pid + "&tab=MMA&ic_id=OA_OvernightAverages_13_CDs_" + this.savprod + "_" + $scope.savprodsoptions[this.savprod].slug + "_default.aspx_"; window.open("//www.bankrate.com/funnel/savings/savings-results.aspx?" + url); } else { var url = "local=false&prods=" + this.savprod + "&pid=" + $scope.attr.pid + "&tab=SAVINGS&ic_id=OA_OvernightAverages_13_CDs_" + this.savprod + "_" + $scope.savprodsoptions[this.savprod].slug + "_default.aspx_"; window.open("//www.bankrate.com/funnel/cd-investments/cd-investment-results.aspx?" + url); } } break; case 'creditcard': window.open("//www.bankrate.com" + this.ccprod + "?pid=" + $scope.attr.pid); break; case 'auto': if (this.isValidZipcode(this.autozipcode)) { var url = "zip=" + this.autozipcode + "&pid=" + $scope.attr.pid + "&ic_id=OA_OvernightAverages_13_Auto__default.aspx_" + this.autozipcode; window.open("//www.bankrate.com/funnel/auto/auto-results.aspx?" + url); } else { this.autozipcode = "Invalid Zip"; } break; case 'refinance': if (this.isValidZipcode(this.refinancezipcode)) { var url = "prods=216&zip=" + this.refinancezipcode + "&pid=" + $scope.attr.pid + "&ic_id=OA_OvernightAverages_4_Mortgage__refinance.aspx_" + this.refinancezipcode; window.open("//www.bankrate.com/funnel/mortgages/mortgage-results.aspx?" + url); } else { this.refinancezipcode = "Invalid Zip"; } break; case 'personalloan': window.open("https://my.bankrate.com/get-started/personal-loans#/loan-profile/purpose?k=i559e&qls=BRC_GTPAWidg.021816PRSN"); break; } }; //validate entered zipcode $scope.isValidZipcode = function (zipcode) { if (zipcode != "" && zipcode.length == 5 && !isNaN(zipcode)) { return true; } return false; } //Handle tab click. And set tabs states and style on click/change of selected tab $scope.activeTab = $scope.attr.defaulttab; $scope.onTabClick = function (tab) { $scope.attr.cdTabStyle = offTabStyle; $scope.attr.savTabStyle = offTabStyle; $scope.attr.ccTabStyle = offTabStyle; $scope.attr.autoTabStyle = offTabStyle; $scope.attr.refinanceTabStyle = offTabStyle; $scope.attr.perloanTabStyle = offTabStyle; $scope.activeTab = tab; switch ($scope.activeTab) { case 'mortgage': $scope.attr.mtgTabStyle = activeTabStyle; break; case 'cd': $scope.attr.cdTabStyle = activeTabStyle; break; case 'savings': $scope.attr.savTabStyle = activeTabStyle; break; case 'creditcard': $scope.attr.ccTabStyle = activeTabStyle; break; case 'auto': $scope.attr.autoTabStyle = activeTabStyle; break; case 'refinance': $scope.attr.refinanceTabStyle = activeTabStyle; break; case 'personalloan': $scope.attr.perloanTabStyle = activeTabStyle; break; } //display the constent of the clicked tab $scope.displayTabContent(tab); } //handle next button click $scope.handleClick = function (data) { //cpc, name, position, pid handle_click(data.cpc, data.name, data.position + 1, $scope.attr.pid, $scope.attr.campaign); } //dialog box location change $scope.openConfirm = function () { ngDialog.openConfirm({ template: 'modalDialogId', className: 'ngdialog-theme-default' }).then(function (value) { $scope.mtgzipcode = parseInt(value); $scope.autozipcode = parseInt(value); $scope.displayTabContent($scope.activeTab); }, function (reason) { //console.log('Modal promise rejected. Reason: ', reason); }); }; //controls loader visibility $scope.attr.loadervisibility = {}; $scope.attr.loadervisibility['display'] = 'none'; //controls rates visibility $scope.attr.ratesvisibility = {}; $scope.attr.ratesvisibility['display'] = 'block'; if ($scope.attr.listpadding) { $scope.attr.ratesvisibility['padding'] = $scope.attr.listpadding; } if ($scope.attr.listborder) { $scope.attr.ratesvisibility['border'] = $scope.attr.listborder; } if ($scope.attr.listfontsize) { $scope.attr.ratesvisibility['font-size'] = $scope.attr.listfontsize; } $scope.mobileLocation = ""; //called on search button click. Performs rates search based on selected seach criteria $scope.search = function () { } //display tab content on load $scope.displayTabContent = function (tab) { $scope.noresults = false; $scope.attr.ratesvisibility['display'] = 'none'; $scope.attr.loadervisibility['display'] = 'block'; $scope.activetabstyle = $scope.attr.activetabstyle; if (($scope.attr.oalocationtype == 'local') && (typeof $scope.states == 'undefined')) { if (typeof LocationsData != 'undefined') { LocationsData.getAllItems($scope.attr) .then(function () { $scope.states = arguments[0].states; }); } } switch (tab) { case 'mortgage': //set api url and parsing method if ($scope.attr.oalocationtype == 'local') { $scope.attr.apiPath = '//' +$scope.bankrateEnvConfig.oaratesapidomain + '/oa/mortgage/1,2,6,216,215'; } else { $scope.attr.apiPath = '//' +$scope.bankrateEnvConfig.oaratesapidomain + '/oa/mortgage/national/1,2,6,216,215'; } if (($scope.mtgzipcode + '').length == 5) { $scope.attr.apiPath = '//' +$scope.bankrateEnvConfig.oaratesapidomain + '/oa/mortgage/region/1,2,6,216,215/' + $scope.mtgzipcode; } $scope.attr.apiPath = $scope.attr.apiPath + '?callback=JSON_CALLBACK'; if ($scope.bankrateEnvConfig.debug != 'undefined' && $scope.bankrateEnvConfig.debug == 'true') { $scope.attr.apiPath = $scope.attr.apiPath + '&msa=5602' } $scope.attr.apiAdapter = 'v1'; $scope.mtgvalidsearch = true; $scope.attr.cdTabStyle = offTabStyle; $scope.attr.savTabStyle = offTabStyle; $scope.attr.ccTabStyle = offTabStyle; $scope.attr.autoTabStyle = offTabStyle; $scope.attr.refinanceTabStyle = offTabStyle; $scope.attr.mtgTabStyle = activeTabStyle; var mtgpagesShown = 1; if (typeof OAData != 'undefined') { OAData.getAllItems($scope.attr) .then(function () { $scope.technicaldifficulties = false; $scope.oalocationtitle = ''; $scope.oadata = arguments[0]; if ($scope.oadata) { if (!isEmpty($scope.oadata.data)) { if ($scope.attr.oalocationtype == "local") { var stateAbb = GeteStateAbb($scope.oadata.data[0].state, $scope.states); $scope.oalocationtitle = $scope.oadata.data[0].cityname + ", " +stateAbb; } $scope.oadata = $scope.oadata.data; $scope.mtglastupdated = $scope.oadata[0].lastupdate; if ($scope.attr.mtgprods && $scope.attr.mtgprods.length > 0) { var mtgproducts = $scope.attr.mtgprods.split(','); var keepprods = new Array; for (var i = 0; i < mtgproducts.length; i++) { $scope.attr.currentmtgprodid = mtgproducts[i]; angular.forEach($scope.oadata, function (oa) { if (oa.productid == $scope.attr.currentmtgprodid) { keepprods.push(oa); } }); } $scope.oadata = keepprods; } if ($scope.oadata.length > 0) { $scope.attr.loadervisibility['display'] = 'none'; $scope.attr.ratesvisibility['display'] = 'block'; $scope.noresults = false; $scope.itemsLimit = function () { return $scope.attr.mtgnumrows * mtgpagesShown; }; $scope.hasMoreItemsToShow = function () { return mtgpagesShown < ($scope.oadata.length / $scope.attr.mtgnumrows); }; $scope.showMoreItems = function () { mtgpagesShown = mtgpagesShown + 1; }; } else { //no oadata.data returned $scope.noresults = true; } } else { $scope.noresults = true; } } else { $scope.noresults = true; $scope.errorStyle = "display:block;"; } }).catch(function(){ $scope.technicaldifficulties = true; $scope.mtgvalidsearch = false; }); } break; case 'cd': //local OA //if($scope.attr.oalocationtype == 'local') { // $scope.attr.apiPath = '//' +$scope.bankrateEnvConfig.oaratesapidomain + '/oa/deposit/' // // + '?callback=JSON_CALLBACK'; //} //present national data only $scope.attr.apiPath = '//' + $scope.bankrateEnvConfig.oaratesapidomain + '/oa/deposit/national/' + '13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,33,34,35,36,37,' + '53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,76,77,78,79,80,' + '145,147,159,160,162,163,164,208,439,440,441,442,499,500,501,502,516,517,518,519' + '?callback=JSON_CALLBACK'; $scope.attr.apiAdapter = 'v1'; $scope.cdvalidsearch = true; $scope.attr.mtgTabStyle = offTabStyle; $scope.attr.ccTabStyle = offTabStyle; $scope.attr.savTabStyle = offTabStyle; $scope.attr.autoTabStyle = offTabStyle; $scope.attr.refinanceTabStyle = offTabStyle; $scope.attr.cdTabStyle = activeTabStyle; var cdpagesShown = 1; if (typeof OAData != 'undefined') { OAData.getAllItems($scope.attr) .then(function () { $scope.technicaldifficulties = false; $scope.oalocationtitle = ''; $scope.stateAbb = ''; $scope.oadata = arguments[0]; if ($scope.oadata) { if (!isEmpty($scope.oadata.data)) { if ($scope.attr.oalocationtype == "local") { $scope.stateAbb = GeteStateAbb($scope.oadata.data[0].state, $scope.states); $scope.oalocationtitle = $scope.oadata.data[0].cityname + ", " + $scope.stateAbb; } $scope.oadata = $scope.oadata.data; $scope.cdlastupdated = $scope.oadata[0].lastupdate; //filter duplicate: national OA contains both of local and national data //CD OA support national only var nationalprods = new Array; angular.forEach($scope.oadata, function (oa) { if (oa.prodhyperlink.toString().match(/local=false/)) { nationalprods.push(oa); } }); $scope.oadata = nationalprods; //filter by cdprods setting if ($scope.attr.cdprods && $scope.attr.cdprods.length > 0) { var cdproducts = $scope.attr.cdprods.split(','); var keepprods = new Array; for (var i = 0; i < cdproducts.length; i++) { $scope.attr.currentcdprodid = cdproducts[i]; angular.forEach($scope.oadata, function (oa) { if (oa.productid == $scope.attr.currentcdprodid) { keepprods.push(oa); } }); } $scope.oadata = keepprods; } if ($scope.oadata.length > 0) { $scope.attr.loadervisibility['display'] = 'none'; $scope.attr.ratesvisibility['display'] = 'block'; $scope.noresults = false; $scope.itemsLimit = function () { return $scope.attr.cdnumrows * cdpagesShown; }; $scope.hasMoreItemsToShow = function () { return cdpagesShown < ($scope.oadata.length / $scope.attr.cdnumrows); }; $scope.showMoreItems = function () { cdpagesShown = cdpagesShown + 1; }; } else { $scope.noresults = true; } } else { $scope.noresults = true; } } else { $scope.noresults = true; $scope.errorStyle = "display:block;"; } }).catch(function() { $scope.technicaldifficulties = true; $scope.cdvalidsearch = false; }); } break; case 'savings': //local OA //if($scope.attr.oalocationtype == 'local') { // $scope.attr.apiPath = '//' +$scope.bankrateEnvConfig.oaratesapidomain + '/oa/deposit/' // // + '?callback=JSON_CALLBACK'; //} //present national data only $scope.attr.apiPath = '//' + $scope.bankrateEnvConfig.oaratesapidomain + '/oa/deposit/national/' + '13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,33,34,35,36,37,' + '53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,76,77,78,79,80,' + '145,147,159,160,162,163,164,208,439,440,441,442,499,500,501,502,516,517,518,519' + '?callback=JSON_CALLBACK'; $scope.attr.apiAdapter = 'v1'; $scope.savvalidsearch = true; $scope.attr.mtgTabStyle = offTabStyle; $scope.attr.ccTabStyle = offTabStyle; $scope.attr.autoTabStyle = offTabStyle; $scope.attr.refinanceTabStyle = offTabStyle; $scope.attr.savTabStyle = activeTabStyle; var savpagesShown = 1; if (typeof OAData != 'undefined') { OAData.getAllItems($scope.attr) .then(function () { $scope.technicaldifficulties = false; $scope.oalocationtitle = ''; $scope.stateAbb = ''; $scope.oadata = arguments[0]; if ($scope.oadata) { if (!isEmpty($scope.oadata.data)) { if ($scope.attr.oalocationtype == "local") { $scope.stateAbb = GeteStateAbb($scope.oadata.data[0].state, $scope.states); $scope.oalocationtitle = $scope.oadata.data[0].cityname + ", " + $scope.stateAbb; } $scope.oadata = $scope.oadata.data; $scope.savlastupdated = $scope.oadata[0].lastupdate; //filter duplicate: national OA contains both of local and national data //sav OA support national only var nationalprods = new Array; angular.forEach($scope.oadata, function (oa) { if (oa.prodhyperlink.toString().match(/local=false/)) { nationalprods.push(oa); } }); $scope.oadata = nationalprods; //filter by savprods setting if ($scope.attr.savprods && $scope.attr.savprods.length > 0) { var savproducts = $scope.attr.savprods.split(','); var keepprods = new Array; for (var i = 0; i < savproducts.length; i++) { $scope.attr.currentsavprodid = savproducts[i]; angular.forEach($scope.oadata, function (oa) { if (oa.productid == $scope.attr.currentsavprodid) { keepprods.push(oa); } }); } $scope.oadata = keepprods; } if ($scope.oadata.length > 0) { $scope.attr.loadervisibility['display'] = 'none'; $scope.attr.ratesvisibility['display'] = 'block'; $scope.noresults = false; $scope.itemsLimit = function () { return $scope.attr.savnumrows * savpagesShown; }; $scope.hasMoreItemsToShow = function () { return savpagesShown < ($scope.oadata.length / $scope.attr.savnumrows); }; $scope.showMoreItems = function () { savpagesShown = savpagesShown + 1; }; } else { $scope.noresults = true; } } else { $scope.noresults = true; } } else { $scope.noresults = true; $scope.errorStyle = "display:block;"; } }).catch(function() { $scope.technicaldifficulties = true; $scope.savvalidsearch = false; }); } break; case 'creditcard': //CreditCard ID mapping: /* (1) Keep old credit cards 11, 12, 18, 26 (Sports_Cards, Charge_Cards, Bad_Credit, HSBC Credit_Card); no data support, no id mapping (2) mapping old credit cards ids (come from Affiliate Center) to new ids (come from OA API document and production page ~/credit-cards.aspx) old: 2 3 4 5 6 7 8 9 10 13 15 16 17 18 19 20 21 22 23 24 28 29 new: 83 105 81 101 72 232 100 102 130 507 236 237 238 (130) 109 111 110 137 108 107 115 114 (3) add new Id (come from OA API document and production page ~/credit-cards.aspx): 103,280,474,517,519 */ $scope.attr.apiPath = '//' + $scope.bankrateEnvConfig.oaratesapidomain + '/oa/creditcard/' + '11,12,26' + ',72,81,83,100,101,102,105,107,108,109,110,111,114,115,130,137,232,236,237,238,507' + ',103,280,474,517,519' + '?callback=JSON_CALLBACK'; $scope.attr.apiAdapter = 'v1'; $scope.ccvalidsearch = true; $scope.attr.mtgTabStyle = offTabStyle; $scope.attr.cdTabStyle = offTabStyle; $scope.attr.savTabStyle = offTabStyle; $scope.attr.autoTabStyle = offTabStyle; $scope.attr.refinanceTabStyle = offTabStyle; $scope.attr.ccTabStyle = activeTabStyle; var ccpagesShown = 1; if (typeof OAData != 'undefined') { OAData.getAllItems($scope.attr) .then(function () { $scope.technicaldifficulties = false; $scope.oadata = arguments[0]; if ($scope.oadata) { if (!isEmpty($scope.oadata.data)) { $scope.oadata = $scope.oadata.data; //$scope.cclastupdated = $scope.oadata[0].lastupdate; //no data if ($scope.attr.ccprods && $scope.attr.ccprods.length > 0) { var ccproducts = $scope.attr.ccprods.split(','); //remapping ccproducts for (var k = 0; k < ccproducts.length; k++) { if (ccproducts[k] == 2) { ccproducts[k] = 83; } else if (ccproducts[k] == 3) { ccproducts[k] = 105; } else if (ccproducts[k] == 4) { ccproducts[k] = 81; } else if (ccproducts[k] == 5) { ccproducts[k] = 101; } else if (ccproducts[k] == 6) { ccproducts[k] = 72; } else if (ccproducts[k] == 7) { ccproducts[k] = 232; } else if (ccproducts[k] == 8) { ccproducts[k] = 100; } else if (ccproducts[k] == 9) { ccproducts[k] = 102; } else if (ccproducts[k] == 10) { ccproducts[k] = 130; } else if (ccproducts[k] == 13) { ccproducts[k] = 507; } else if (ccproducts[k] == 15) { ccproducts[k] = 236; } else if (ccproducts[k] == 16) { ccproducts[k] = 237; } else if (ccproducts[k] == 17) { ccproducts[k] = 238; } else if (ccproducts[k] == 18) { ccproducts[k] = 130; } else if (ccproducts[k] == 19) { ccproducts[k] = 109; } else if (ccproducts[k] == 20) { ccproducts[k] = 111; } else if (ccproducts[k] == 21) { ccproducts[k] = 110; } else if (ccproducts[k] == 22) { ccproducts[k] = 137; } else if (ccproducts[k] == 23) { ccproducts[k] = 108; } else if (ccproducts[k] == 24) { ccproducts[k] = 107; } else if (ccproducts[k] == 28) { ccproducts[k] = 115; } else if (ccproducts[k] == 29) { ccproducts[k] = 114; } } var keepprods = new Array; for (var i = 0; i < ccproducts.length; i++) { $scope.attr.currentccprodid = ccproducts[i]; angular.forEach($scope.oadata, function (oa) { if (oa.productid == $scope.attr.currentccprodid) { keepprods.push(oa); } }); } $scope.oadata = keepprods; } if ($scope.oadata.length > 0) { $scope.attr.loadervisibility['display'] = 'none'; $scope.attr.ratesvisibility['display'] = 'block'; $scope.noresults = false; $scope.itemsLimit = function () { return $scope.attr.ccnumrows * ccpagesShown; }; $scope.hasMoreItemsToShow = function () { return ccpagesShown < ($scope.oadata.length / $scope.attr.ccnumrows); }; $scope.showMoreItems = function () { ccpagesShown = ccpagesShown + 1; }; } else { //no oadata.data returned $scope.noresults = true; } } else { $scope.noresults = true; } } else { $scope.noresults = true; $scope.errorStyle = "display:block;"; } }).catch(function(){ $scope.technicaldifficulties = true; $scope.ccvalidsearch = false; }); } break; case 'auto': if ($scope.attr.oalocationtype == 'local') { $scope.attr.apiPath = '//' + $scope.bankrateEnvConfig.oaratesapidomain + '/oa/auto/39,40,41,42,73,74,276,277,278,311'; if (($scope.autozipcode + '').length == 5) { $scope.attr.apiPath = '//' + $scope.bankrateEnvConfig.oaratesapidomain + '/oa/auto/region/39,40,41,42,73,74,276,277,278,311/' + $scope.autozipcode; } } else { $scope.attr.apiPath = '//' + $scope.bankrateEnvConfig.oaratesapidomain + '/oa/auto/national/39,40,41,42,73,74,276,277,278,311'; } $scope.attr.apiPath = $scope.attr.apiPath + '?callback=JSON_CALLBACK'; if ($scope.bankrateEnvConfig.debug != 'undefined' && $scope.bankrateEnvConfig.debug == 'true') { $scope.attr.apiPath = $scope.attr.apiPath + '&msa=5602' } //console.log('here'); $scope.attr.apiAdapter = 'v1'; $scope.autovalidsearch = true; $scope.attr.mtgTabStyle = offTabStyle; $scope.attr.cdTabStyle = offTabStyle; $scope.attr.savTabStyle = offTabStyle; $scope.attr.ccTabStyle = offTabStyle; $scope.attr.refinanceTabStyle = offTabStyle; $scope.attr.autoTabStyle = activeTabStyle; var autopagesShown = 1; //console.log("$scope.attr.autonumrows: " +$scope.attr.autonumrows); if (typeof OAData != 'undefined') { OAData.getAllItems($scope.attr) .then(function () { $scope.technicaldifficulties = false; $scope.oadata = arguments[0]; $scope.oalocationtitle = ''; if ($scope.oadata) { if (!isEmpty($scope.oadata.data)) { if ($scope.attr.oalocationtype == "local") { var stateAbb = GeteStateAbb($scope.oadata.data[0].state, $scope.states); $scope.oalocationtitle = $scope.oadata.data[0].cityname + ", " + stateAbb; } $scope.oadata = $scope.oadata.data; $scope.autolastupdated = $scope.oadata[0].lastupdate; if ($scope.attr.autoprods && $scope.attr.autoprods.length > 0) { var autoproducts = $scope.attr.autoprods.split(','); var keepprods = new Array; for (var i = 0; i < autoproducts.length; i++) { $scope.attr.currentautoprodid = autoproducts[i]; angular.forEach($scope.oadata, function (oa) { if (oa.productid == $scope.attr.currentautoprodid) { keepprods.push(oa); } }); } $scope.oadata = keepprods; } if ($scope.oadata.length > 0) { $scope.attr.loadervisibility['display'] = 'none'; $scope.attr.ratesvisibility['display'] = 'block'; $scope.noresults = false; $scope.itemsLimit = function () { return $scope.attr.autonumrows * autopagesShown; }; $scope.hasMoreItemsToShow = function () { return autopagesShown < ($scope.oadata.length / $scope.attr.autonumrows); }; $scope.showMoreItems = function () { autopagesShown = autopagesShown +1; }; } else { $scope.noresults = true; } } else { //no oadata.data returned $scope.noresults = true; } } else { $scope.noresults = true; $scope.errorStyle = "display:block;"; } }).catch(function(){ $scope.technicaldifficulties = true; $scope.autovalidsearch = false; }); } break; case 'refinance': //refinance Ids: /* (1) mapping its '0-point’ prod Ids to all point prod Ids for Old: 225, 102, 229, 253, 241, 245, 413, 410 (come from Affiliate Center) New: 216, 215, 215, 222, 219, 220, 393, 392 (come from OA API) (2) add new Ids favaliable in OA API. */ if ($scope.attr.oalocationtype == 'local') { $scope.attr.apiPath = '//' +$scope.bankrateEnvConfig.oaratesapidomain + '/oa/mortgage/' + '215,216,217,218,219,220,221,222,223,224,265,392,393,394,425,426,448,450,479,480,481,482,483,512' + '?callback=JSON_CALLBACK'; } else { $scope.attr.apiPath = '//' +$scope.bankrateEnvConfig.oaratesapidomain + '/oa/mortgage/national/' + '215,216,217,218,219,220,221,222,223,224,265,392,393,394,425,426,448,450,479,480,481,482,483,512' + '?callback=JSON_CALLBACK'; } if ($scope.bankrateEnvConfig.debug != 'undefined' && $scope.bankrateEnvConfig.debug == 'true') { $scope.attr.apiPath = $scope.attr.apiPath + '&msa=5602' } $scope.attr.apiAdapter = 'v1'; $scope.refinancevalidsearch = true; $scope.attr.mtgTabStyle = offTabStyle; $scope.attr.cdTabStyle = offTabStyle; $scope.attr.savTabStyle = offTabStyle; $scope.attr.ccTabStyle = offTabStyle; $scope.attr.autoTabStyle = offTabStyle; $scope.attr.refinanceTabStyle = activeTabStyle; var refinancepagesShown = 1; if (typeof OAData != 'undefined') { OAData.getAllItems($scope.attr) .then(function () { $scope.technicaldifficulties = false; $scope.oalocationtitle = ''; $scope.oadata = arguments[0]; if ($scope.oadata) { if (!isEmpty($scope.oadata.data)) { if ($scope.attr.oalocationtype == "local") { var stateAbb = GeteStateAbb($scope.oadata.data[0].state, $scope.states); $scope.oalocationtitle = $scope.oadata.data[0].cityname + ", " +stateAbb; } $scope.oadata = $scope.oadata.data; $scope.refinancelastupdated = $scope.oadata[0].lastupdate; if ($scope.attr.refinanceprods && $scope.attr.refinanceprods.length > 0) { var refinanceproducts = $scope.attr.refinanceprods.split(','); //remapping refiproducts for (var k = 0; k < refinanceproducts.length; k++) { if (refinanceproducts[k] == 225) { refinanceproducts[k] = 216; } else if ((refinanceproducts[k] == 102 ) || (refinanceproducts[k] == 229 )) { refinanceproducts[k] = 215; } else if (refinanceproducts[k] == 253) { refinanceproducts[k] = 222; } else if (refinanceproducts[k] == 241) { refinanceproducts[k] = 219; } else if (refinanceproducts[k] == 245) { refinanceproducts[k] = 220; } else if (refinanceproducts[k] == 413) { refinanceproducts[k] = 393; } else if (refinanceproducts[k] == 410) { refinanceproducts[k] = 392; } } var keepprods = new Array; for (var i = 0; i < refinanceproducts.length; i++) { $scope.attr.currentrefimtgprodid = refinanceproducts[i]; angular.forEach($scope.oadata, function (oa) { if (oa.productid == $scope.attr.currentrefimtgprodid) { keepprods.push(oa); } }); } $scope.oadata = keepprods; } if ($scope.oadata.length > 0) { $scope.attr.loadervisibility['display'] = 'none'; $scope.attr.ratesvisibility['display'] = 'block'; $scope.noresults = false; $scope.itemsLimit = function () { return $scope.attr.refinancenumrows * refinancepagesShown; }; $scope.hasMoreItemsToShow = function () { return refinancepagesShown < ($scope.oadata.length / $scope.attr.refinancenumrows); }; $scope.showMoreItems = function () { refinancepagesShown = refinancepagesShown + 1; }; } else { //no oadata.data returned $scope.noresults = true; } } else { $scope.noresults = true; } } else { $scope.noresults = true; $scope.errorStyle = "display:block;"; } }).catch(function() { $scope.technicaldifficulties = true; $scope.refinancevalidsearch = false; }); } break; case 'personalloan': $scope.attr.ratesvisibility['display'] = 'block'; $scope.oadata = [ {rating:'Good/Excellent',score:'680 or above',rate:'5.49',link:'https://my.bankrate.com/financial-advice/personal-loans?creditBand=good&qls=BRC_GdEXWidg.021816PRSN'}, {rating:'Fair',score:'640 to 680',rate:'8.80',link:'https://my.bankrate.com/financial-advice/personal-loans?creditBand=fair&qls=BRC_FairWidg.021816PRSN'}, {rating:'Poor',score:'580 to 640',rate:'25.5',link:'https://my.bankrate.com/financial-advice/personal-loans?creditBand=poor&qls=BRC_PoorWidg.021816PRSN'} ]; break; } } $scope.$watch(function () { var innerDiv = document.getElementById($scope.clientconfigid); var height = 0; if (typeof window.getComputedStyle == 'function') { height = window.getComputedStyle(innerDiv).getPropertyValue("height"); } //add padding of 10px to widget height height = (parseInt(height.replace(/px/, "")) + 10) + "px"; return height; }, function () { var innerDiv = document.getElementById($scope.clientconfigid); var height = 0; if (typeof window.getComputedStyle == 'function') { height = window.getComputedStyle(innerDiv).getPropertyValue("height"); } //add padding of 10px to widget height height = (parseInt(height.replace(/px/, "")) + 10) + "px"; setTimeout(function () { callHome('setHeight', { args: [config.client.frameid, height] }); }, 700); }); $scope.setWidth = function (a) { callHome('setWidth', { args: [config.client.frameid, a] }); } setTimeout(function () { $scope.setWidth($scope.attr.widgetwidth); }, 700); $scope.setHeight = function (a) { callHome('setHeight', { args: [config.client.frameid, a] }); } window.addEventListener('resize', function () { var innerDiv = document.getElementById($scope.clientconfigid); var height = 0; if (typeof window.getComputedStyle == 'function') { height = window.getComputedStyle(innerDiv).getPropertyValue("height"); } //add padding of 10px to widget height height = (parseInt(height.replace(/px/, "")) + 10) + "px"; var timer = setTimeout(function () { $scope.setHeight(height); clearTimeout(timer); }, 700); }); //display the content of the default tab $scope.displayTabContent($scope.activeTab); }); }); oapartners.directive('tabs', function ($compile) { //Build tabs return { restrict: 'A', link: function (scope, element, attrs) { var tabs = scope.attr.tabs; tabs = angular.fromJson(tabs); if (tabs.length > 0) { for (var i = 0; i < tabs.length; i++) { var tabcustom = tabs[i].replace("mortgage", "mtg").replace("savings", "sav").replace("creditcard", "cc").replace("personalloan", "perloan"); var activeTabs = "