%PDF- %PDF-
Direktori : /home/t/r/a/tradesc/www/relax/wp-content/cache/wpfc-minified/dsid6pqn/ |
Current File : /home/t/r/a/tradesc/www/relax/wp-content/cache/wpfc-minified/dsid6pqn/ho1c1.js |
(function ($){ "use strict"; $.fn.pi_notification_runner=function (){ var settings=$.extend({ first_popup: 100, interval_between_popup: 1000, how_long_to_show: 1000, animation: "fadeIn", closing_animation: "fadeOut", close: true, close_image: "", dismiss: false, loop: true, counter: 0, mobile: true, max_notification_count:0 }, window.pi_notification_runner_setting); this.maxNotificationReached=function (){ var count=parseInt(sessionStorage.getItem('pisol_sn_counter')); if(count==null){ return false; } if(settings.max_notification_count==0||settings.max_notification_count==undefined) return false; if(count >=parseInt(settings.max_notification_count)){ return true; } return false; } this.getOrders=function (){ var parent=this; var action='pisol_live_orders'; if(parent.maxNotificationReached(parent)){ console.log('Max Sales Notification Count Reached'); return; } jQuery.ajax({ type: 'POST', dataType: "json", data: { action: 'pisol_live_orders' }, url: settings.wc_ajax_url.toString().replace('%%endpoint%%', action), success: function (msg){ parent.popups=shuffle(msg); if(parent.popups.length > 0){ parent.startFirstTimer(parent); }} }) } this.startFirstTimer=function (obj){ setTimeout(function (obj){ var popup=obj.makingPopup(obj); setTimeout(function (popup){ popup.close(popup); settings.counter++; }, settings.how_long_to_show, popup); obj.startLoop(obj); }, settings.first_popup, obj); } this.startLoop=function (obj){ var interval=parseInt(settings.interval_between_popup) + parseInt(settings.how_long_to_show); setInterval(function (obj){ var popup=obj.makingPopup(obj); if(popup!=undefined){ setTimeout(function (popup){ popup.close(popup); settings.counter++; }, settings.how_long_to_show, popup); }}, interval, obj); } this.makingPopup=function (obj){ settings.content=obj.popups[settings.counter]; var popup; if(settings.content!=undefined){ var popup=$(window).pi_notification(settings); }else{ if(settings.loop){ settings.counter=0; }} return popup; } this.getOrders(); } jQuery(function ($){ $(window).pi_notification_runner(); }) function shuffle(array){ var currentIndex=array.length, temporaryValue, randomIndex; while (0!==currentIndex){ randomIndex=Math.floor(Math.random() * currentIndex); currentIndex -=1; temporaryValue=array[currentIndex]; array[currentIndex]=array[randomIndex]; array[randomIndex]=temporaryValue; } return array; }})(jQuery);