PageSourceSearch

https://www.coheedandcambria.com/wp-content/plugins/umg-grand-roya…/js/shortcodes/popup/popup.js?ver=3.5.9

js coheedandcambria.com collected 2026-10-02 04:48:21 UTC 6,050 bytes, 179 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    $(document).ready(function () {
5
6        //wait for splash page to be closed if it's open before firing popup
7        var splash_interval = setInterval(function() {
8            if(!jQuery('#umggr-splash').is(':visible')) {
9                UMGGR_Popup_Shortcode.run_popup(1);
10                clearInterval(splash_interval);
11            }
12        }, 1000);
13
14
15
16    });
17
18    /**
19    * Execute fancybox on given popup if ready to show
20    */
21    UMGGR_Popup_Shortcode.run_popup = function(id) {
22        var $container = $('#umggr-popup-' + id);
23        if($container.length && UMGGR_Popup_Shortcode.can_show_popup($container)) {
24
25            //check if popup can only be shown after X numbner of seconds, until then wait
26            var show_after = parseInt($container.data('show-after'));
27            if(show_after > 0) {
28                var start_time = UMGGR_Popup_Shortcode.get_site_visit_start_time($container);
29
30                var wait_interval = setInterval(function() {
31                    var current_time = new Date();
32                    var seconds_on_site = Math.abs((current_time.getTime() - start_time.getTime()) / 1000);
33
34                    if(seconds_on_site >= show_after) {
35                        UMGGR_Popup_Shortcode.run_fancybox($container);
36                        UMGGR_Popup_Shortcode.reset_site_visit_start_time($container);
37                        clearInterval(wait_interval);
38                    }
39                }, 1000);
40            } else if(UMGGR_Popup_Shortcode.is_front_page === '1') {
41
42                //only show Popup on front-page unless we are showing it after X seconds of browsing
43                UMGGR_Popup_Shortcode.run_fancybox($container);
44            }
45        }
46    };
47
48    /**
49    * Execute fancybox on given popup if ready to show
50    */
51    UMGGR_Popup_Shortcode.run_fancybox = function(container) {
52        $.fancybox.open({
53            src: '#' + container.attr('id'),
54            buttons: false,
55            baseClass:'fancy-popup-embed',
56            afterClose: function() {
57                var show_frequency = container.data('show-repeat');
58                var record_visits = show_frequency !== 'every_time';
59                UMGGR_Popup_Shortcode.set_popup_last_shown(container, record_visits);
60            }
61        });
62    };
63
64    /**
65    * Check if Popup is ready to be shown depending on Show Frequency, Nth Visits and Time visiting site
66    *
67    * @return boolean
68    */
69    UMGGR_Popup_Shortcode.can_show_popup = function(container) {
70        var show_frequency = container.data('show-repeat');
71        var last_shown = UMGGR_Popup_Shortcode.get_popup_last_shown(container);
72
73        switch(show_frequency) {
74            case 'every_time':
75                return true;
76
77            case 'first_time':
78                //if any storage set then this is not the first time
79                if(!UMGGR_Popup_Shortcode.get_popup_last_shown(container)) {
80                    return true;
81                }
82            break;
83            case 'nth_time':
84                UMGGR_Popup_Shortcode.increment_popup_visits(container);
85
86                var nth_visit = container.data('nth-visit');
87                var visit_count = UMGGR_Popup_Shortcode.get_popup_visits(container);
88
89                if(visit_count === 0 || visit_count % nth_visit === 0) {
90                    return true;
91                }
92            break;
93        }
94
95        return false;
96    };
97
98    /**
99    * Get last time the given popup has been shown
100    *
101    * @return float - UNIX timestamp
102    */
103    UMGGR_Popup_Shortcode.get_popup_last_shown = function(container) {
104        var last_shown = false;
105        if(typeof(Storage) !== 'undefined') {
106            last_shown = localStorage.getItem(container.attr('id') + '_last_shown');
107        }
108        return last_shown;
109    };
110
111    /**
112    * Get number of popup visits
113    *
114    * @return int
115    */
116    UMGGR_Popup_Shortcode.get_popup_visits = function(container) {
117        var visit_count = false;
118        if(typeof(Storage) !== 'undefined') {
119            visit_count = parseInt(localStorage.getItem(container.attr('id') + '_visit_count'));
120            if(!visit_count) {
121                visit_count = 0;
122            }
123        }
124        return visit_count;
125    };
126
127    /**
128    * Increment number of visits
129    */
130    UMGGR_Popup_Shortcode.increment_popup_visits = function(container) {
131        if(typeof(Storage) !== 'undefined') {
132            var visit_count = parseInt(localStorage.getItem(container.attr('id') + '_visit_count'));
133            if(!visit_count) {
134                visit_count = 0;
135            }
136            localStorage.setItem(container.attr('id') + '_visit_count', visit_count + 1);
137        }
138    };
139
140    /**
141    * Set when popup was last shown
142    */
143    UMGGR_Popup_Shortcode.set_popup_last_shown = function(container, record_visits) {
144        if(typeof(Storage) !== 'undefined') {
145            localStorage.setItem(container.attr('id') + '_last_shown', new Date());
146
147            //if not recording visits then clear count
148            if(!record_visits) {
149                localStorage.removeItem(container.attr('id') + '_visit_count');
150            }
151        }
152    };
153
154    /**
155    * Get start time of when user came onto the site initially
156    */
157    UMGGR_Popup_Shortcode.get_site_visit_start_time = function(container) {
158        if(typeof(Storage) !== 'undefined') {
159            var start_time = localStorage.getItem(container.attr('id') + '_start_time');
160            if(!start_time) {
161                localStorage.setItem(container.attr('id') + '_start_time', new Date());
162                start_time = new Date();
163            } else {
164                start_time = new Date(start_time);
165            }
166        }
167        return new Date();
168    };
169
170    /**
171    * Reset start time
172    */
173    UMGGR_Popup_Shortcode.reset_site_visit_start_time = function(container) {
174        if(typeof(Storage) !== 'undefined') {
175            localStorage.removeItem(container.attr('id') + '_start_time');
176        }
177    }
178
179})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.