(function($){
//Build #1004
$.fn.ubook = function(options){
//console.log(options);
var build = '#1004';
var id = $(this).prop('id');
var _self = this;
var _overlay = this;
var _parstl = 0;
var processor_url = domainname+'widget/'+options.orientation;
var search_list_url = options.search_list_url;
var load_bootstrap_js = (typeof $().emulateTransitionEnd == 'function');
var browser_supported = browser_test();
var settings = $.extend({
search_type : 'subpage',
}, options);
if(options.lang=="auto"){
var language="tr";
}else{
var language=options.lang;
}
this.initialize = function() {
console.info('online reservation widget installed! : '+build);
$(document).on('click', 'div.ubkdpckr--nav-action, div.ubkdpckr--nav-title, div.ubkdpckr--cell', function (e) {
e.stopPropagation();
});
setInterval(function(){ keepAlive(); },50000);
return this;
};
//alert(domainname);
$('head').append('');
/* Bootstrap */
$('head').append('');
/* Moment */
if (!(typeof moment == 'function')) { $('head').append(''); }
$('head').append('');
$('head').append('');
$('head').append('');
var phonewhatsasppcontent='';
$('body').append(phonewhatsasppcontent);
/*
if(className != 'ubook_containers'){
console.warn('Ubook container class name "'+className+'" must be "ubook_container".');
settings.text = 'Please check errors in console.';
}
else
{
*/
$(_self).append(
'
');
_self = $("#ubook_content");
_overlay = $("#ubook_overlay");
/* } */
if(!browser_supported){
$(".ubook_container").html('Your browser out dated!
Please update your browser to see this app.
');
}
if(id=='undefined')
if(id.length==0){ console.warn('Ubook container must have a id!'); settings.text = 'Please check errors in console.';}
if ( settings.color ) {
$(".ubook_container_cell").css( 'background-color', settings.color );
}
if ( settings.overlay_color ) {
$(".ubook_overlay").css( 'background-color', settings.overlay_color );
}
if ( settings.padding ) {
$(".ubook_container_cell").css( 'padding', settings.padding );
}
if ( settings.text ) {
$(this).html( settings.text );
}
this.getUrlParams = function(){
return getParams();
}
function getParams() {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
return urlParams;
}
function getParamsSerialized() {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
urlParams = "&ubk_showcur="+(settings.currencies?1:0)+"&ubk_showlang="+(settings.languages?1:0)+(!hasParam('ubk_language')?'&ubk_language='+settings.language:'')+(!hasParam('ubk_hotel')?'&ubk_hotel='+settings.hotel:'');
while (match = search.exec(query))
urlParams += '&'+decode(match[1])+'=' + decode(match[2]);
return urlParams;
}
function hasParam(prn){
var match,
pl = /\+/g,
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
while (match = search.exec(query))
{
if(decode(match[1])==prn)
return true;
}
}
this.box_search = function(){
var params = {
checkin : $("#ubk_checkin").val(),
lang : $("#ubk_langcode").val(),
checkout : $("#ubk_checkout").val(),
adults : $("#ubk_adults").val(),
childs : $("#ubk_childs").val(),
c1age : $("#ubk_c1age").attr('type')=='select-one'?$("#ubk_c1age option:selected").val():$("#ubk_c1age").val(),
c2age : $("#ubk_c2age").attr('type')=='select-one'?$("#ubk_c2age option:selected").val():$("#ubk_c2age").val(),
c3age : $("#ubk_c3age").attr('type')=='select-one'?$("#ubk_c3age option:selected").val():$("#ubk_c3age").val(),
hotel : $("#ubk_hotelcode").val(),
};
$("#ubook_overlay").show(100);
if(params.hotel==""){
alert("Lütfen Otel Seçiniz");
}else{
//document.location = search_list_url + applyParamsAndGetUrl(params);
window.open(search_list_url + applyParamsAndGetUrl(params), "_blank")
}
}
this.box_search_mobile = function(){
var params = {
checkin : $("#ubk_checkin_mobil").val(),
lang : $("#ubk_langcode_mobil").val(),
checkout : $("#ubk_checkout_mobil").val(),
adults : $("#ubk_adults_mobil").val(),
childs : $("#ubk_childsel_mobil").val(),
c1age : $("#ubk_c_mobil1age").attr('type')=='select-one'?$("#ubk_c_mobil1age option:selected").val():$("#ubk_c_mobil1age").val(),
c2age : $("#ubk_c_mobil2age").attr('type')=='select-one'?$("#ubk_c_mobil2age option:selected").val():$("#ubk_c_mobil2age").val(),
c3age : $("#ubk_c_mobil3age").attr('type')=='select-one'?$("#ubk_c_mobil3age option:selected").val():$("#ubk_c_mobil3age").val(),
hotel : $("#ubk_hotelcode_mobil").val(),
};
$("#ubook_overlay").show(100);
// console.log(params.hotel);
if(params.hotel==""){
alert("Lütfen Otel Seçiniz");
}else{
//document.location = search_list_url + applyParamsAndGetUrl(params);
window.open(search_list_url + applyParamsAndGetUrl(params), "_blank")
}
}
function applyParamsAndGetUrl(params){
console.log(params.hotel);
var cpar = getParams();
var url = params.lang+"?";
if(params.adults!=null) url += 'hotelCode='+btoa(params.hotel);
if(params.checkin!=null) url += '&checkinDate='+params.checkin;
if(params.checkout!=null) url += '&checkoutDate='+params.checkout;
//hotelcode
if(params.adults!=null) url += '&Adult='+params.adults;
if(params.childs!=null) url += '&Child='+params.childs;
var ages="";
if(params.c1age!=undefined) ages +='&childAges1='+params.c1age;
if(params.c2age!=undefined) ages +='&childAges2='+params.c2age;
if(params.c3age!=undefined) ages +='&childAges3='+params.c3age;
//console.log(ages);
if(ages.length>=1){ url += ages; }
console.log(url);
return url;
}
this.keep_alive = function(){
}
function keepAlive(){
/*
$.post(processor_url+"?u="+Math.random(1000), '&ubk_process=keepalive',
function(data,status){
console.log(processor_url+'--- Keep Alive -- ' + Math.random(1000));
});
*/
}
this.send_post = function(){
postSend('',getParamsSerialized()+'&ubk_search_type='+settings.search_type+'&ubk_orientation='+settings.orientation);
}
function postSend(qdata,pdata){
$(_overlay).fadeIn(100);
// console.log(processor_url+"?widget_container="+settings.widget_container+"&lang="+settings.lang+"&u="+Math.random(1000)+qdata);
$.post(processor_url+"?widget_container="+settings.widget_container+"&lang="+settings.lang+"&u="+Math.random(1000)+qdata, pdata,
function(data,status){
try {
var dt = data.split('|||');
settings.token = dt[2];
//console.log(settings.token);
eval_at_out(dt[0],false);
if(document.readyState==='complete')
{
eval_at_out(dt[1],true);
}
else
{
$(window).bind("load",function() {
eval_at_out(dt[1],true);
});
}
}
catch(err) {
$(_self).html('Error#1032:');
console.log(err);
$(_overlay).fadeOut(300);
}
});
}
return this.initialize();
}
})(jQuery);
var tt;
function eval_at_out(data,jsmi){
try{
moveScreenAuto();
}
catch(err){}
if(jsmi)
setTimeout(eval(data),100);
else
{
eval(data);
checkInsurance();
}
}
function checkInsurance(){
if(document.readyState==='complete'&&$("#ubook_overlay").is(':visible'))
{
$(window).trigger('load');
//$(window).load();
}
else
{
clearTimeout(tt);
tt = setTimeout('checkInsurance()',1000);
}
}
function ra(find, replace, str) {
return str.replace(new RegExp(find, 'g'), replace);
}
function hashchanged()
{
console.log('Adres değişti');
}
function browser_test(){
navigator.browser= (function(){
var ua= navigator.userAgent, tem,
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE '+(tem[1] || '');
}
if(M[1]=== 'Chrome'){
tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
}
M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
return M.join(' ');
})();
var gelen = navigator.browser.replace(/\s/g, ''),
tarayici = gelen.replace(/\d+/g, ''),
version = gelen.replace(/[^0-9]/gi, '');
if (tarayici == "Opera" && version > 20 || tarayici == "Chrome" && version > 20 || tarayici == "IE" && version > 8 || tarayici == "MSIE" && version > 8 || tarayici == "Firefox" && version > 29 || tarayici == "Safari" && version > 4 || tarayici == "Edge"){
return true;
}
}