PageSourceSearch

https://erostock.net/wp-content/plugins/itro-popup/scripts/itro-scripts.js

js erostock.net collected 2026-10-05 11:34:43 UTC 5,067 bytes, 185 lines download raw bytes

1/*
2 This file is part of ITRO Popup Plugin. (email : [email protected])
3 */
4
5/* init variables */
6var itro_is_preview;
7var itro_cookie_expiration;
8var itro_age_restriction;
9
10/**
11 * Manage popup appearing
12 * 
13 *
14 * @since 1.0
15 *
16 */
17function itro_enter_anim(auto_margin)
18{
19    if (document.cookie.indexOf("popup_cookie") == -1 || itro_is_preview === true)
20    {
21	//align the popup before fadein
22	if (auto_margin == 'yes') {
23	    itro_margin_refresh(50);
24	}
25
26	jQuery("#itro_popup").css('display', 'none');
27	jQuery("#itro_popup").css('opacity', 1);
28	jQuery("#itro_popup").css('visibility', 'visible');
29
30	jQuery("#itro_opaco").fadeIn(function ()
31	{
32	    jQuery("#itro_popup").fadeIn();
33	    if (itro_age_restriction === false)
34	    {
35		itro_set_cookie("popup_cookie", "one_time_popup", itro_cookie_expiration);
36	    }
37	    // refresh every 0.5 second the popup top margin (needed for browser window resizeing)
38	    if (auto_margin == 'yes') {
39		setInterval(function () {
40		    itro_margin_refresh();
41		}, 500);
42	    }
43	});
44    } else {
45	jQuery("#itro_popup").css('display', 'none');
46    }
47
48}
49
50/**
51 * Manage popup closing
52 * 
53 *
54 * @since 1.0
55 *
56 */
57function itro_exit_anim() {
58    jQuery('#itro_popup').fadeOut(function () {
59	jQuery('#popup_content').remove();
60	jQuery('#itro_opaco').fadeOut();
61    });
62}
63
64
65/**
66 * Center the popup vertically
67 * 
68 * @param {int} speed : the milesec speed fo the alignment animation
69 *
70 * @since 1.0
71 *
72 */
73function itro_margin_refresh(speed) {
74    if (typeof (speed) == undefined) {
75	speed = 200;
76    }
77
78    if (typeof (window.innerWidth) == 'number')
79    {
80	/* Non-IE */
81	browserWidth = window.innerWidth;
82	browserHeight = window.innerHeight;
83    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
84    {
85	/* IE 6+ in 'standards compliant mode' */
86	browserWidth = document.documentElement.clientWidth;
87	browserHeight = document.documentElement.clientHeight;
88    } else if (document.body && (document.body.clientWidth || document.body.clientHeight))
89    {
90	/* IE 4 compatible */
91	browserWidth = document.body.clientWidth;
92	browserHeight = document.body.clientHeight;
93    }
94    popupHeight = document.getElementById('itro_popup').offsetHeight;	//get the px size of popup div
95    parentOffset = jQuery('#itro_popup').position().top;
96    docOffset = jQuery('#itro_popup').offset().top;
97
98    desTopWindowMargin = Math.round((browserHeight - popupHeight) / 2); 		//desired top margin of popup (window related)
99    desTopWindowMargin = desTopWindowMargin < 0 ? 0 : desTopWindowMargin; 	//avoid that negative top position will hide the popup 
100    popupTopMargin = desTopWindowMargin - docOffset + parentOffset;
101
102    if (jQuery('#itro_popup').css('position') == 'absolute') {
103	//set a tollerance to avoid flickering
104	if (Math.abs(popupTopMargin - parentOffset) > 2) {
105	    jQuery('#itro_popup').animate({top: popupTopMargin}, speed);
106	}
107    } else {
108	if (Math.abs(popupTopMargin - parentOffset) > 2) {
109	    jQuery('#itro_popup').animate({top: desTopWindowMargin}, speed);
110	}
111    }
112
113}
114
115/**
116 * Invert an hex color with the # char
117 * 
118 * @param string hexTripletColor: the hex string
119 *
120 * @since 4.9
121 *
122 */
123function itro_invert_color(hexTripletColor) {
124    var color = hexTripletColor;
125    color = color.substring(1);           // remove #
126    color = parseInt(color, 16);          // convert to integer
127    color = 0xFFFFFF ^ color;             // invert three bytes
128    color = color.toString(16);           // convert to hex
129    color = "#" + color;                  // prepend #
130    return color;
131}
132
133/**
134 * Convert an rgb string like rgb(255, 255, 255) to an hex code
135 * 
136 * @param string rgbString: the rgb string
137 *
138 * @since 4.9
139 *
140 */
141function itro_rgb2hex(rgbString) {
142    var parts = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
143    delete (parts[0]);
144    for (var i = 1; i <= 3; ++i) {
145	parts[i] = parseInt(parts[i]).toString(16);
146	if (parts[i].length == 1)
147	    parts[i] = '0' + parts[i];
148    }
149    return '#' + parts.join('').toUpperCase();
150}
151
152/* function for countdown to show popup when the delay is set */
153function popup_delay(auto_margin) {
154    delay--;
155    if (delay <= 0)
156    {
157	clearInterval(interval_id_delay);
158	itro_enter_anim(auto_margin);
159    }
160}
161
162
163/**
164 * Countdown for automatic closing
165 *
166 * @since 1.0
167 *
168 */
169function popTimer() {
170    if (popTime > 0) {
171	document.getElementById("timer").innerHTML = popTime;
172	popTime--;
173    } else {
174	clearInterval(interval_id);
175	itro_exit_anim();
176    }
177}
178
179/* function use to set the cookie for next visualization time */
180function itro_set_cookie(c_name, value, exhours) {
181    var exdate = new Date();
182    exdate.setTime(exdate.getTime() + (exhours * 3600 * 1000));
183    var c_value = escape(value) + ((exhours == null) ? "" : "; expires=" + exdate.toUTCString());
184    document.cookie = c_name + "=" + c_value + "; path=/";
185}

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.