1(function () { 2 'use strict'; 3 4 angular 5 .module('app.pousadas') 6 .controller('PousadasController', PousadasController); 7 8 PousadasController.$inject = [ 9 '$state', '$filter', 10 'pousadaModels', 'googlemapModels', 11 'pousadaDataService', 'moment', 'common', 'bannerDataService' 12 ]; 13 14 function PousadasController($state, $filter, pousadaModels, googlemapModels, pousadaDataService, moment, common, bannerDataService) { 15 var vm = this; 16 17 var domLinkElement = document.getElementById("canonicalLink"); 18 domLinkElement.href = window.location.href; 19 document.title = "Pousadas de Portugal - Living History hotels, palaces, fortresses & estates" 20 21 //var keywords = document.getElementById('metaKeywords'); 22 //keywords.content = 'Pousadas de Portugal, Pousadas of Portugal, Pousadas, Pousada Porto, Pousada Lisboa, Pousada Evora, Pousada Obidos, Pousada Sagres, Pousada Estoi, Pousada Faro, Pousada Guimaraes, Pousada Viana do Castelo, Pousada Queluz'; 23 24 vm.title = 'Pousadas'; 25 vm.banner = ''; 26 vm.pousadas = []; 27 vm.featuredPousadas = []; 28 vm.promotions = []; 29 vm.categories = []; 30 31 var searchSettings = { 32 33 }; 34 var cachedSearch = common.storage.get('pousadas-search'); 35 36 if (cachedSearch) { 37 searchSettings.codeName = cachedSearch.codeName; 38 searchSettings.kids = cachedSearch.kids; 39 searchSettings.checkIn = cachedSearch.checkIn; 40 searchSettings.checkOut = cachedSearch.checkOut; 41 searchSettings.rooms = cachedSearch.rooms; 42 searchSettings.adults = cachedSearch.adults; 43 searchSettings.nights = cachedSearch.nights; 44 45 } 46 47 vm.search = new pousadaModels.Search(searchSettings); 48 49 //common.storage.set('pousadas-search', null); 50 51 vm.mapCenter = 52 vm.mapSettings = []; 53 54 vm.goToPousadaPriceView = goToPousadaPriceView; 55 vm.goToPousadaDetails = goToPousadaDetails; 56 vm.scrollToMap = scrollToMap; 57 58 59 activate();
60 /////////// 61 62 function activate() { 63 64 getPousadas() 65 .then(getFeaturedPousadas); 66 67 getPousadasBanner(); 68 getPousadasCategories(); 69 70 } 71 72 73 function getPousadas() { 74 75 return pousadaDataService.getPousadas() 76 .then(success); 77 78 function success(pousadas) { 79 80 var iconName = null; 81 var imageName = null; 82 var marker = null; 83 var markers = []; 84 85 pousadas 86 .forEach(function (p) { 87 88 p.starsWeight = p.stars / 5 * 100; 89 90 iconName = p.categoryIcon ? '/images/pousadas/categories/' + p.categoryIcon : null; 91 imageName = p.categoryIcon ? '/images/pousadas/' + p.imageName : null; 92 93 marker = new googlemapModels.Marker( 94 p.codeName, 95 p.gpsX, 96 p.gpsY, 97 iconName, 98 p.name, 99 imageName 100 ); 101 102 markers.push(marker); 103 }); 104 105 vm.pousadas = pousadas; 106 107 vm.mapSettings = { 108 center: new googlemapModels.Center(39.656835, -8.11054), //portugal 109 markers: markers, 110 zoom: 7 111 }; 112 113 return vm.pousadas; 114 } 115 } 116 117 function getFeaturedPousadas(pousadas) { 118 119 var featuredPousadas = common.storage.get('pousadas-featured'); 120 121 if (!featuredPousadas) { 122 123 featuredPousadas = $filter('where')(pousadas, { isFeatured: true }); 124 125 featuredPousadas.forEach(function (p) { 126 p.starsWeight = p.stars / 5 * 100; 127 }); 128 129 common.storage.set('pousadas-featured', featuredPousadas); 130 } 131 132 vm.featuredPousadas = featuredPousadas; 133 } 134 135 function getPousadasBanner() { 136 return bannerDataService.getSectionBanner("pousadas") 137 .then(success); 138 139 function success(data) { 140 vm.banner = data; 141 return vm.banner; 142 } 143 } 144 145 function getPousadasCategories() { 146 return pousadaDataService.getPousadasCategories() 147 .then(success); 148 149 function success(data) { 150 vm.categories = data; 151 return vm.columns; 152 } 153 } 154 155 function goToPousadaPriceView() { 156 157 var params = angular.copy(vm.search); 158 params.checkIn = moment(params.checkIn, 'MM/DD/YYYY').format('YYYY-MM-DD') 159 params.checkOut = moment(params.checkOut, 'MM/DD/YYYY').format('YYYY-MM-DD') 160 161 var cacheSearch = { 162 codeName: params.codeName, 163 checkIn: vm.search.checkIn, 164 checkOut: vm.search.checkOut, 165 rooms: params.rooms, 166 kids: params.kids, 167 adults: params.adults, 168 nights: params.nights 169 }; 170 171 common.storage.set('pousadas-search', cacheSearch); 172 173 $state.go('pousadas.price-view', params); 174 } 175 176 function goToPousadaDetails(codeName) { 177 $state.go('pousadas.details', { codeName: codeName }); 178 } 179 180 function scrollToMap() { 181 common.scrollToEle('map'); 182 } 183 } 184}());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.