var OShotTourVars = {"getDataUrl":"https:\/\/export.otpusk.com\/api\/tours\/hot\/","getBlocksUrl":"https:\/\/export.otpusk.com\/api\/tours\/hotBlock\/","getToursUrl":"https:\/\/export.otpusk.com\/api\/tours\/hotTour\/","blockId":6141,"timestamp":1492312782}; // document.write('
'); // console.log(OShotTourVars); /*! * accounting.js v0.4.1, copyright 2014 Open Exchange Rates, MIT license, http://openexchangerates.github.io/accounting.js */ (function(p,z){function q(a){return!!(""===a||a&&a.charCodeAt&&a.substr)}function m(a){return u?u(a):"[object Array]"===v.call(a)}function r(a){return"[object Object]"===v.call(a)}function s(a,b){var d,a=a||{},b=b||{};for(d in b)b.hasOwnProperty(d)&&null==a[d]&&(a[d]=b[d]);return a}function j(a,b,d){var c=[],e,h;if(!a)return c;if(w&&a.map===w)return a.map(b,d);for(e=0,h=a.length;ea?"-":"",g=parseInt(y(Math.abs(a||0),h),10)+"",l=3a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal))};c.formatColumn=function(a,b,d,i,e,h){if(!a)return[];var f=s(r(b)?b:{symbol:b,precision:d,thousand:i,decimal:e,format:h},c.settings.currency),g=x(f.format),l=g.pos.indexOf("%s")a?g.neg:g.zero).replace("%s",f.symbol).replace("%v",t(Math.abs(a),n(f.precision),f.thousand,f.decimal));if(a.length>k)k=a.length;return a});return j(a,function(a){return q(a)&&a.length135){ self.view.$.find(" .hot-otp-price-count").css({'text-align':'left'}); }else{ self.view.$.find(" .hot-otp-price-count").css({'text-align':'right'}); self.view.$.find(" .hot-price-block").width('80'); } } if(!self.view.$.hasClass('hot-block_string')){ //console.log(self.view.$); if (self.view.$.width()<=410){ self.view.$.addClass(column_block).removeClass(list_block).removeClass(table_block); } if(self.view.$.hasClass(column_block) && self.view.$.width()>473){ self.view.$.addClass(list_block).removeClass(column_block); self.view.$.find(tour_block).width('auto'); } if(self.view.$.width()<790){ if(self.view.$.hasClass(table_block)){ self.view.$.addClass(list_block).removeClass(table_block); } }else{ if(self.view.$.hasClass(list_block)){ self.view.$.addClass(table_block).removeClass(list_block); } } if(self.view.$.hasClass(column_block) || self.view.$.hasClass(table_block)){ var imgWidth = self.view.$.find(".hot-otp-img").width(), imgHeight = self.view.$.find(".hot-otp-img").height(); if (imgWidth<200) {imgWidth = 200;} } if(self.view.$.hasClass(list_block) || self.view.$.hasClass(block_string)){ self.view.$.find(tour_block).width('auto'); } self.view.$.find(tour_block).width(imgWidth); if(self.view.$.hasClass(table_block)){ self.view.$.find(' .hot-otp-form-wrap').each(function(){ var infoHeight = $jq(this).find('.hot-otp-info_place').height(), hotelHeight = $jq(this).find('.hot-otp-description').height(), TopCity = (imgHeight + 30 + infoHeight), TopCountry = (imgHeight + 55 + infoHeight); $jq(this).find(".hot-otp-departure-city").css('top',-TopCity); $jq(this).find(".hot-country").css('top',-TopCountry); $jq(this).find('.hot-otp-description').css('margin-top',infoHeight+5); $jq(this).find('.hot-otp-info_place').css('margin-top',-(hotelHeight+infoHeight+9)); $jq(this).find('.hot-price-block').css('margin-top',hotelHeight+10); }); } } } }; /** * Run widget */ var startFunction = function() { // load block data self.getHotBlocks(function(block){ self.data = block; var tours = []; var $block = $jq('#otpusk_onsite_hot' + params.blockId); $block.empty(); if (!block.error) { $block.append($jq('').append(block.css)); if (typeof block.block.view_type === 'undefined') { block.block.view_type = 'string'; } var $hotWrapper; $block.append( self.view.$ = $jq('
') .addClass('hot-otp-content hot-block_' + block.block.view_type) .append( $hotWrapper = $jq('
') .addClass('hot-wrapper') ) ); // render empty tours $jq.each(block.tours, function(i, tourId){ self.renderTour($hotWrapper, tourId, block.block.view_type); // render empty tour }); // refresh block tours var hotelIds = []; $jq.each(block.tours, function(i, tourId){ self.getHotTours(tourId, function(tour){ // #11909 unique hotel if(typeof tour.searchedTour === 'object' && typeof tour.searchedTour.offers === 'object') { $jq.each(tour.searchedTour.offers, function(j, offer){ tour.searchedTour.data_view = false; if(hotelIds.indexOf(+offer.hotelId) == -1) { hotelIds.push(+offer.hotelId); tour.searchedTour.data_view = offer; return false; } }); } // update offer data self.refreshTour($block, tour, tourId, block); // run callback #11093 if(typeof window.otpRefreshTour === 'function') { window.otpRefreshTour($block, tour, tourId, block); } // set callback /* tours.push(tour); if((i+1) == block.tours.length) { if(typeof window.otpHotToursRendered === 'function') { window.otpHotToursRendered(tours); } } */ self.resize(); }); }); $block.find('a').on('click', function() { if(self.isIE()) { window.location.href = $jq(this).attr('href'); } else { window.location.href = $jq(this).attr('href'); window.location.reload(); } }); } else { // #10162 if(block.message.indexOf('No active hot module') != -1) { $block.html('Модуль горящих туров отключен. Для восстановления работы модуля обратитесь в поддержку'); } } }); $jq(function () { $jq(window).resize(function () { self.resize(); }); }); }; /** * Refresh tour * @param $block * @param tour * @param tourId * @param block * @returns {boolean} */ this.refreshTour = function($block, tour, tourId, block){ var $tour = $block.find('.os-hot-tour-'+ tourId); if(tour.error || (tour.searchedTour && !tour.searchedTour.data_view)) { // #11078 if(tour.searchedTour.data_view === false) { if(window.location.href.indexOf('export.otpusk.com/hot_view.php') != -1) { $tour.find('span.hot-otp-description').text('Тур не найден'); } else { $tour.remove(); } } return false; } // get tour link var link; if(typeof tour.searchedTour !== 'undefined') { link = tour.searchedTour.data_view.tourLink; var currPage = typeof osTarget !== 'undefined'? osTarget: document.location.href.replace(document.location.hash, ''); var siteName = currPage.replace(document.location.pathname, ''); if (typeof osBlockTarget != 'undefined') { if (osBlockTarget != '') { var tmp = osBlockTarget; if (tmp[0] != '/') tmp = '/' + tmp; if (osBlockTarget.indexOf('http') == -1) { link = siteName + tmp + link; } else { link = osBlockTarget + link; } } else { link = currPage + link; } } else { link = currPage + link; } } else { link = tour.tour.m_link; } switch(block.block.view_type){ /*** Table type ***/ case 'table': if(typeof tour.searchedTour === 'undefined') { // manual // image if(tour.tour.m_image_id && tour.tour.m_image_url) { $tour.find('div.hot-otp-img').find('img').attr('src', 'https://newimg.otpusk.com/5/800x600/'+ tour.tour.m_image_url); } // image link $tour.find('div.hot-otp-img').find('a').attr('href', tour.tour.m_link); // tour hotel $tour.find('div.hot-otp-tour-block').find('a') .attr('href', link); // description $tour.find('div.hot-otp-place').append( $jq('
') .addClass('hot-country') .text(tour.tour.m_caption) ).append(tour.tour.m_short_desc); // tour price $tour.find('div.hot-otp-price').append( $jq('') .attr('href', link) .text(tour.tour.m_price) ); $tour.find('div.hot-otp-price-count').on('init', function(){ var currencyTxt; switch (tour.tour.m_currency) { case 'eur': currencyTxt = self._('евро'); break; case 'usd': currencyTxt = 'дол.'; break; case 'rub': currencyTxt = 'руб.'; break; default: currencyTxt = 'грн'; break; } $jq(this).append(currencyTxt); $jq(this).append( $jq('') .attr('title', +block.block.price_type == 1? self._('за одного'): self._('за двоих')) .text(+block.block.price_type == 1? self._('за одного'): self._('за двоих')) ); }).trigger('init'); $tour.find('div.hot-otp-departure').hide(); $tour.find('span.hot-otp-description').text(' '); } else { // auto $tour.find('div.hot-otp-img') .find('a').attr('href', link); // tour image $tour.find('div.hot-otp-img').find('img').attr('src', tour.searchedTour.data_view.imgSrc); // tour hotel $tour.find('div.hot-otp-tour-block').find('a') .attr('href', link) .find('span.hot-otp-description') .text(tour.searchedTour.data_view.fullHotelName); // hotel name // tour country $tour.find('div.hot-otp-place').append( $jq('
') .addClass('hot-country') .text(tour.searchedTour.data_view.countryName) ).append(tour.searchedTour.data_view.resortName +', '+ tour.searchedTour.data_view.dateDurationString); // tour transport $tour.find('div.hot-otp-departure-city').text(tour.searchedTour.data_view.locationFromString); // tour food $tour.find('div.hot-otp-departure') .show() .text(tour.searchedTour.data_view.foodString); // tour price $tour.find('div.hot-otp-price').find('a') .attr('href', link) .html(+block.block.price_type == 1? tour.searchedTour.data_view.priceUahOne: tour.searchedTour.data_view.priceUah) $tour.find('div.hot-otp-price-count').append( 'грн' ).append( $jq('') .attr('title', +block.block.price_type == 1? self._('за одного'): self._('за двоих')) .text(+block.block.price_type == 1? self._('за одного'): self._('за двоих')) ); } break; /*** Tiles type ***/ case 'tiles': if(typeof tour.searchedTour === 'undefined') { // manual // link $tour.find('a.hot-otp-tour-block') .attr('href', tour.tour.m_link) .find('a').attr('href', tour.tour.m_link); // image if(tour.tour.m_image_id && tour.tour.m_image_url) { $tour.find('div.hot-otp-img').find('img').attr('src', 'https://newimg.otpusk.com/5/800x600/'+ tour.tour.m_image_url); } // image link $tour.find('div.hot-otp-img').find('a').attr('href', tour.tour.m_link); // title $tour.find('span.hot-otp-description').text(tour.tour.m_caption); // description $tour.find('div.hot-otp-tour-info').text(tour.tour.m_short_desc); // tour price $tour.find('div.hot-otp-price').append( $jq('') .attr('href', link) .text(tour.tour.m_price) ); $tour.find('div.hot-otp-price-count').on('init', function(){ var currencyTxt; switch (tour.tour.m_currency) { case 'eur': currencyTxt = self._('евро'); break; case 'usd': currencyTxt = 'дол.'; break; case 'rub': currencyTxt = 'руб.'; break; default: currencyTxt = 'грн'; break; } $jq(this).append(currencyTxt); $jq(this).append( $jq('') .attr('title', +block.block.price_type == 1? self._('за одного'): self._('за двоих')) .text(+block.block.price_type == 1? self._('за одного'): self._('за двоих')) ); }).trigger('init'); } else { // auto $tour.find('div.hot-otp-img').find('a').attr('href', link); // tour image $tour.find('div.hot-otp-img').find('img').attr('src', tour.searchedTour.data_view.imgSrc); // tour link $tour.find('a.hot-otp-tour-block') .attr('href', link) .find('a') .attr('href', link) .find('span.hot-otp-description') .text(tour.searchedTour.data_view.countryName); // country name // hotel name and city $tour.find('div.hot-otp-place').on('init', function(){ var title = tour.searchedTour.data_view.fullHotelName; if(title.length > 3) { // #7631 var parts = title.split(' '); if(parts.length > 0) { var stars = parts[parts.length-1]; stars = ''+ stars +''; } parts[parts.length-1] = stars; title = parts.join(' '); } $jq(this).append( $jq('') .addClass('hot-otp-hotel-name') .append(title) ); $jq(this).append($jq('').addClass('hot-otp-coma').text(', ')); $jq(this).append(tour.searchedTour.data_view.resortName); }).trigger('init'); // tour info $tour.find('div.hot-otp-tour-info').on('init', function(){ var parts = $jq.trim(tour.searchedTour.data_view.dateDurationString).split(' '); // date $jq(this).append( $jq('') .addClass('hot-otp-date-bl') .attr('data-date', parts[0] +' '+ parts[1]) .text(parts[0] +' '+ parts[1]) ); // length parts[0] = ''; parts[1] = ''; $jq(this).append( $jq('') .addClass('hot-otp-dur-bl') .attr('data-dur', parts.join(' ')) .append( $jq('') .text(parts.join(' ')) ) ); // transport $jq(this) .append(', ') .append( $jq('') .addClass('hot-otp-transp-bl hot-otp-transp-'+ tour.searchedTour.data_view.transport) .attr('title', tour.searchedTour.data_view.locationFromString) .text(tour.searchedTour.data_view.locationFromString) ); // food $jq(this) .append(', ') .append( $jq('') .addClass('hot-otp-food-bl hot-otp-food-'+ tour.searchedTour.data_view.food) .attr('title', tour.searchedTour.data_view.foodString) .text(tour.searchedTour.data_view.foodString) ); }).trigger('init'); // tour price $tour.find('div.hot-otp-price').append( $jq('') .attr('href', link) .text(+block.block.price_type == 1? tour.searchedTour.data_view.priceUahOne: tour.searchedTour.data_view.priceUah) ); $tour.find('div.hot-otp-price-count').append( 'грн' ).append( $jq('') .attr('title', +block.block.price_type == 1? self._('за одного'): self._('за двоих')) .text(+block.block.price_type == 1? self._('за одного'): self._('за двоих')) ); } break; /*** String type ***/ case 'string': if(typeof tour.searchedTour === 'undefined') { // manual // link $tour.find('a.hot-otp-tour-block') .attr('href', tour.tour.m_link) .find('a').attr('href', tour.tour.m_link); // title $tour.find('span.hot-otp-description').text(tour.tour.m_caption); // description $tour.find('div.hot-otp-place').text(tour.tour.m_short_desc); // tour price $tour.find('div.hot-otp-price').append( $jq('') .attr('href', link) .text(tour.tour.m_price) ); $tour.find('div.hot-otp-price-count').on('init', function(){ var currencyTxt; switch (tour.tour.m_currency) { case 'eur': currencyTxt = self._('евро'); break; case 'usd': currencyTxt = 'дол.'; break; case 'rub': currencyTxt = 'руб.'; break; default: currencyTxt = 'грн'; break; } $jq(this).append(currencyTxt); $jq(this).append( $jq('') .attr('title', +block.block.price_type == 1? self._('за одного'): self._('за двоих')) .text(+block.block.price_type == 1? self._('за одного'): self._('за двоих')) ); }).trigger('init'); } else { // auto // tour link $tour.find('div.hot-otp-tour-block').find('a') .attr('href', link) .find('span.hot-otp-description') .text(tour.searchedTour.data_view.fullHotelName); // hotel name // hotel name and city $tour.find('div.hot-otp-place').on('init', function(){ $jq(this).append( $jq('
') .addClass('hot-country') .append(tour.searchedTour.data_view.countryName) ).append( tour.searchedTour.data_view.resortName +', '+ tour.searchedTour.data_view.dateDurationString ); }).trigger('init'); // tour price $tour.find('div.hot-otp-price').append( $jq('') .attr('href', link) .text(+block.block.price_type == 1? tour.searchedTour.data_view.priceUahOne: tour.searchedTour.data_view.priceUah) ); $tour.find('div.hot-otp-price-count').append( 'грн' ).append( $jq('') .attr('title', +block.block.price_type == 1? self._('за одного'): self._('за двоих')) .text(+block.block.price_type == 1? self._('за одного'): self._('за двоих')) ); } break; } }; /** * Render empty tour * @param $block * @param tourId * @param blockType */ this.renderTour = function($block, tourId, blockType){ switch(blockType) { /*** Table type ***/ case 'table': $jq('
') .addClass('hot-otp-form-wrap') .addClass('os-hot-tour-'+ tourId) .append( $jq('
') .addClass('hot-otp-img') .append( $jq('').append( $jq('') .attr('src', 'https://export.otpusk.com/ehot/templates/css/images/grey.png') ) ) ).append( $jq('
') .addClass('hot-otp-tour-block no_tour') .append( $jq('').append( $jq('') .addClass('hot-otp-description') .text(self._('Идет обновление')) ) ).append( $jq('
') .addClass('hot-otp-info_place') .append( $jq('
') .addClass('hot-otp-place') ).append( $jq('
') .addClass('hot-otp-departure-city') ).append( $jq('
') .addClass('hot-otp-departure') .hide() ) ).append( $jq('
') .addClass('hot-price-block') .append( $jq('
') .addClass('hot-otp-price') .append( $jq('') ) ).append( $jq('
') .addClass('hot-otp-price-count') ) ) ).appendTo($block); break; /*** String type ***/ case 'string': $jq('
') .addClass('hot-otp-form-wrap') .addClass('os-hot-tour-'+ tourId) .append( $jq('
') .addClass('hot-otp-tour-block no_tour') .append( $jq('').append( $jq('') .addClass('hot-otp-description') .text(self._('Идет обновление')) ) ).append( $jq('
') .addClass('hot-otp-info_place') .append( $jq('
') .addClass('hot-otp-place') ) ).append( $jq('
') .addClass('hot-price-block') .append( $jq('
') .addClass('hot-otp-price') .append( $jq('') ) ).append( $jq('
') .addClass('hot-otp-price-count') ) ) ).appendTo($block); break; /*** Tiles type ***/ case 'tiles': $jq('
') .addClass('hot-otp-form-wrap') .addClass('os-hot-tour-'+ tourId) .append( $jq('
') .addClass('hot-otp-img') .append( $jq('').append( $jq('') .attr('src', 'https://export.otpusk.com/ehot/templates/css/images/grey.png') ) ) ).append( $jq('') .addClass('hot-otp-tour-block no_tour') .append( $jq('').append( $jq('') .addClass('hot-otp-description') .text(self._('Идет обновление')) ) ).append( $jq('
') .addClass('hot-otp-info_place') .append( $jq('
') .addClass('hot-otp-place') ) .append( $jq('
') .addClass('hot-otp-tour-info') ) ).append( $jq('
') .addClass('hot-price-block') .append( $jq('
') .addClass('hot-otp-price') .append( $jq('') ) ).append( $jq('
') .addClass('hot-otp-price-count') ) ) ).appendTo($block); break; } }; // Run application this.checkScripts(startFunction); /** * local && session storage #11195 */ this.storage = new function(){ /** * Is supported local storage * @returns {boolean} */ this.is_support = function(){ try { localStorage.setItem('test', 'test'); localStorage.removeItem('test'); return true; } catch(e) { return false; } }; /** * Get object from storage * @param key * @param type (dict || list) * @param ts * @param cached_days * @param cached_hours * @param cached_minutes * @returns {*} * * @example o.storage.get('key', '{}', 'session', 7) */ this.get = function(key, type, ts, cached_days, cached_hours, cached_minutes) { type = type || []; // list type default if(this.is_support() && key) { if(ts === 'session') { return JSON.parse(sessionStorage.getItem(key) || type); } else { // cached var now = new Date(); if(+localStorage.getItem(key +'-date') < now.getTime()) { var days = +cached_days? cached_days: (+cached_hours? 0: 2); // 2 day default var hours = +cached_hours? cached_hours: 0; var minutes = +cached_minutes? cached_minutes: 0; if(days) { // cached days this.set(key +'-date', now.getTime()+(+days*24*60*60*1000)); } else if(hours) { // cached hours this.set(key +'-date', now.getTime()+(+hours*60*60*1000)); } else { this.set(key +'-date', now.getTime()+(+minutes*60*1000)); } // remove cache localStorage.removeItem(key); } return JSON.parse(localStorage.getItem(key) || type); } } }; /** * Set object to storage * @param key * @param value * @param ts * * @example o.storage.set('key', 123) */ this.set = function(key, value, ts){ if(this.is_support() && key && value) { if(ts === 'session') { sessionStorage.setItem(key, JSON.stringify(value)); } else { localStorage.setItem(key, JSON.stringify(value)); } } }; }; }; new osHotTourWidgetClass(OShotTourVars, apiKey);