В main.js найдите:
$(function () {
initVisitorDiscount($("#visitor_discount_value"));
});
function initVisitorDiscount(element){
jQuery(document).ready(function(){
var focus = true;
var del_timer = null;
var delay_time = 1;
var visitor_discount_max = 5000;
var visitor_discount_time = 3600;
var visitor_discount_diff = visitor_discount_max/visitor_discount_time;
var visitor_discount_start_val = $.cookie('visitor_discount')*1;
element.data('val', 0);
if (typeof visitor_discount_start_val != 'undefined'){
if(isNaN(visitor_discount_start_val)) visitor_discount_start_val = 0;
element.data('val', visitor_discount_start_val);
var n = Math.round(visitor_discount_start_val)/1000;
if(isNaN(n)) n = 0;
element.text(n+'%');
}
setInterval(function(){
var prev_val = element.data('val')*1;
var now = new Date();
if(focus){
if(prev_val<visitor_discount_max){
var vdv = prev_val+visitor_discount_diff;
if(vdv>visitor_discount_max){
vdv = visitor_discount_max;
$.cookie('visitor_discount_timemax', now.getTime(), { expires: 365, path: '/' });
}
element.data('val', vdv);
var expire_date = new Date();
expire_date.setTime(expire_date.getTime() + (delay_time * 1000));
$.cookie('visitor_discount', vdv, { expires: expire_date, path: '/' });
var n = Math.round(vdv)/1000;
if(isNaN(n)) n = 0;
element.text(n+'%');
}
else{
var visitor_discount_timemax = $.cookie('visitor_discount_timemax');
if (typeof visitor_discount_timemax == 'undefined'){
visitor_discount_timemax = now.getTime();
$.cookie('visitor_discount_timemax', visitor_discount_timemax, { expires: 365, path: '/' });
}
if(now.getTime()-visitor_discount_timemax >= 24*60*60*1000){
element.data('val', 0);
$.cookie('visitor_discount_timemax', now.getTime(), { expires: 365, path: '/' });
}
}
}
}, 250);
$(window).focus(function() {
if(del_timer)clearTimeout(del_timer);
focus = true;
});
$(window).blur(function() {
focus = false;
del_timer = setTimeout(function(){
element.data('val', 0);
}, delay_time*1000);
});
});
}
замените на:
$(function () {
initVisitorDiscount($("#visitor_discount_value"));
});
function initVisitorDiscount(element){
jQuery(document).ready(function(){
var focus = true;
var del_timer = null;
var delay_time = 10;
var visitor_discount_max = 5000;
var visitor_discount_time = 3600;
var visitor_discount_diff = visitor_discount_max/visitor_discount_time;
var visitor_discount_start_val = $.cookie('visitor_discount')*1;
element.data('val', 0);
if (typeof visitor_discount_start_val != 'undefined'){
if(isNaN(visitor_discount_start_val)) visitor_discount_start_val = 0;
element.data('val', visitor_discount_start_val);
var n = Math.round(visitor_discount_start_val)/1000;
if(isNaN(n)) n = 0;
element.text(n+'%');
}
setInterval(function(){
var prev_val = element.data('val')*1;
var now = new Date();
if(focus){
if(prev_val<visitor_discount_max){
var vdv = prev_val+visitor_discount_diff;
if(vdv>visitor_discount_max){
vdv = visitor_discount_max;
$.cookie('visitor_discount_timemax', now.getTime(), { expires: 365, path: '/' });
}
element.data('val', vdv);
var expire_date = new Date();
expire_date.setTime(expire_date.getTime() + (delay_time * 1000));
$.cookie('visitor_discount', vdv, { expires: expire_date, path: '/' });
var n = Math.round(vdv)/1000;
if(isNaN(n)) n = 0;
element.text(n+'%');
}
else{
var visitor_discount_timemax = $.cookie('visitor_discount_timemax');
if (typeof visitor_discount_timemax == 'undefined'){
visitor_discount_timemax = now.getTime();
$.cookie('visitor_discount_timemax', visitor_discount_timemax, { expires: 365, path: '/' });
}
if(now.getTime()-visitor_discount_timemax >= 24*60*60*1000){
element.data('val', 0);
$.cookie('visitor_discount_timemax', now.getTime(), { expires: 365, path: '/' });
}
}
}
}, 250);
$(window).focus(function() {
if(del_timer)clearTimeout(del_timer);
focus = true;
});
$(window).blur(function() {
focus = false;
del_timer = setTimeout(function(){
element.data('val', 0);
}, delay_time*1000);
});
});
}