var PLILPwindowObject = {
baseURL: '//fit-sport.by',
/*baseURL: '//slavianka.loc',*/
jquery: false,
oldJQ1: false,
oldJQ2: false,
timeout: false,
insrxsessid: "",
setCookie: function ( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name+'='+escape( value ) +
( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
( ( path ) ? ';path=' + path : '' ) +
( ( domain ) ? ';domain=' + domain : '' ) +
( ( secure ) ? ';secure' : '' );
},
getCookie: function (name) {
var matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
},
randomString: function(len, charSet) {
charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var randomString = '';
for (var i = 0; i < len; i++) {
var randomPoz = Math.floor(Math.random() * charSet.length);
randomString += charSet.substring(randomPoz,randomPoz+1);
}
return randomString;
},
initPLILPwindowinit: function () {
/*if (typeof $ == 'function') {
this.oldJQ1 = $
}
if (typeof jQuery == 'function') {
this.oldJQ2 = jQuery
}*/
this.insrxsessid = this.getCookie("insrxsessid");
if (!this.insrxsessid)
this.insrxsessid = this.randomString(32);
this.setCookie("insrxsessid", this.insrxsessid );
this.PLIPLcreatejs(this.baseURL + "/js/jquery-1.11.2.min.js");
this.PLIPLcreatestylesheet(this.baseURL + "/css/onlineconsultant_label.css?v=6");
this.PLIPLcreatestylesheet(this.baseURL + "/onlineconsultant_styles.php?cid=144");
this.PLIPLcreatestylesheet(this.baseURL + "/css/onlineconsultant_label_v2.css?v=2");
var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
if ( width < 600 )
{
this.PLIPLcreatestylesheet(this.baseURL + "/css/onlineconsultant_mobile.css?v=3");
this.PLIPLcreatestylesheet(this.baseURL + "/css/onlineconsultant_mobile_v2.css?v=3"); }
},
initPLILPwindowlabel: function () {
this.jquery = jQuery;
jQuery.noConflict(true);
/*if (this.oldJQ1)
$ = this.oldJQ1;
if (this.oldJQ2)
jQuery = this.oldJQ2;*/
obj = this.jquery('
');
obj.addClass('plilp_window_label');
obj.addClass('plilp_window_label_rightcenter'); obj.appendTo(this.jquery('body'));
objclose = this.jquery('');
objclose.addClass('plilp_window_label_close');
objclose.appendTo(obj);
obj2 = this.jquery('');
obj2.addClass('plilp_window_label_i');
obj2.appendTo(obj);
obj3 = this.jquery('');
obj3.addClass('plilp_window_label_click');
obj3.html('');
obj3.appendTo(obj2);
this.jquery(obj3).bind('click', {mainCLass: this}, this.PLILPwindow);
this.jquery(objclose).bind('click', {mainCLass: this}, this.PLILPwindowhide);
this.jquery('.plilp_window_label_click_manual').bind('click', {mainCLass: this}, this.PLILPwindow);
this.PLIPLplace(0);
this.jquery(window).bind('scroll', {mainCLass: this}, this.PLIPLplace);
this.jquery(window).bind('load', {mainCLass: this}, this.PLIPLplace);
this.jquery(window).bind('message', {mainCLass: this}, this.PLIPLmessage);
},
PLIPLmessage: function (event) {
if (event == 0)
Selfclass = this;
else
Selfclass = event.data.mainCLass;
data = event.originalEvent.data;
if (data == 'onlineconsultantalertmessage' && !Selfclass.jquery('.plilp_window_label_opened').size() )
{
//oldDocumentTitle = document.title;
//document.title = 'Вам сообщение';
//setTimeout(function () {document.title = oldDocumentTitle}, 2000);
Selfclass.PLILPwindow(event);
//alert('pokl');
}
},
PLIPLplace: function (event) {
return;
//alert('OPKL');
if (event == 0)
Selfclass = this;
else
Selfclass = event.data.mainCLass;
//Selfclass.jquery('.plilp_window_label').css({ top: pos + 'px', left: 0, right: 'auto' });
pos = parseInt(Selfclass.jquery(window).height() / 2) + Selfclass.jquery(window).scrollTop();
pos = pos - parseInt( Selfclass.jquery('.plilp_window_label').height() / 2);
Selfclass.jquery('.plilp_window_label').css({ top: pos + 'px', right: 0 });
/*width = Selfclass.jquery(window).width();
documentwidth = Selfclass.jquery(document).width();
if (documentwidth > width)
width = documentwidth;
left = width - Selfclass.jquery('.plilp_window_label').width()-1;
//alert(Selfclass.jquery('.plilp_window_label').width());
//alert(left);
Selfclass.jquery('.plilp_window_label').css({ top: pos + 'px', left: left + 'px', right: 'auto', opacity: 1 });*/
},
PLIPLcreatestylesheet: function (css) {
if (document.createStyleSheet) {
document.createStyleSheet(css);
} else {
var e = document.createElement("link");
e.setAttribute("rel", "stylesheet");
e.setAttribute("href", css);
document.body.appendChild(e)
}
},
PLIPLcreatejs: function (js) {
/*var e = document.createElement("script");
e.setAttribute("type", "text/javascript");
e.setAttribute("src", js);
document.body.appendChild(e)*/
var script = document.createElement('script');
script.setAttribute("type", "text/javascript");
if (script.readyState && false){ //IE
script.onreadystatechange = function(){
if (script.readyState == "loaded" ||
script.readyState == "complete"){
script.onreadystatechange = null;
this.initPLILPwindowlabel();
}
};
} else { //Others
var self = this
script.onload = function() {
self.initPLILPwindowlabel();
};
}
script.setAttribute("src", js);
document.body.appendChild(script);
},
PLILPwindow: function (event) {
if (event == 0)
{
Selfclass = this;
}
else
Selfclass = event.data.mainCLass;
Selfclass.setCookie('plilp_wnd_already_show', 1);
clearTimeout(Selfclass.timeout);
Selfclass.jquery('.plilp_window_label').addClass('plilp_window_label_opened');
Selfclass.jquery('.plilp_window_label_click').hide();
Selfclass.jquery('.plilp_window_label_close').show();
managerid = 0;
if (Selfclass.jquery('.template-land-managers-online-clicked').size())
{
managerid = Selfclass.jquery('.template-land-managers-online-clicked').attr('data-userid');
}
obj = Selfclass.jquery('');
obj.appendTo( Selfclass.jquery('.plilp_window_label_i') );
Selfclass.jquery('.plilp_window_label').addClass('plilp_window_label_isloading');
Selfclass.jquery(obj).ready(function () {
//Selfclass.jquery(obj).bind('load', {mainCLass: Selfclass}, Selfclass.PLIPLplace);
Selfclass.PLIPLplace();
//Selfclass.jquery('#onlineconsultant-alert-iframe').get(0).contentDocument.location.reload();
//document.getElementById('onlineconsultant-alert-iframe').contentDocument.location.reload(true);
src = Selfclass.jquery('#onlineconsultant-alert-iframe').attr('src');
Selfclass.jquery('#onlineconsultant-alert-iframe').attr('src', src);
//Selfclass.jquery(obj).bind('load', function () {
//Selfclass.jquery(this).bind('load', function () {
console.log('ready');
//Selfclass.jquery('.plilp_window_label_loading').remove();
//Selfclass.jquery('.plilp_window_label').removeClass('plilp_window_label_isloading');
//});
});
Selfclass.jquery(obj).load(function () {
console.log('load');
Selfclass.jquery('.plilp_window_label_loading').remove();
Selfclass.jquery('.plilp_window_label').removeClass('plilp_window_label_isloading');
});
},
PLILPwindowhide: function (event) {
event.data.mainCLass.jquery('.plilp_window_label_isloading').removeClass('plilp_window_label_isloading');
event.data.mainCLass.jquery('.plilp_window_label_loading').remove();
event.data.mainCLass.jquery('.plilp_window_label_click').show();
event.data.mainCLass.jquery('.plilp_window_label_close').hide();
event.data.mainCLass.jquery('.plilp_window_label_i .plilp_main_frame').remove();
event.data.mainCLass.PLIPLplace(0);
event.data.mainCLass.jquery('.plilp_window_label').removeClass('plilp_window_label_opened');
event.data.mainCLass.jquery('.plilp_window_label').removeClass('plilp_window_label_opened_centered');
}
}
PLILPwindowObject.initPLILPwindowinit();