PageSourceSearch

https://globalphotographyawards.com/js/cookie/load-v1.js

js globalphotographyawards.com collected 2026-10-08 12:10:16 UTC 7,562 bytes, 201 lines download raw bytes

1(function (window, undefined){
2	"use strict";
3
4	var document = window.document;
5
6	function log() {
7		if (window.console && window.console.log) {
8			for (var x in arguments) {
9				if (arguments.hasOwnProperty(x)) {
10					window.console.log(arguments[x]);
11				}
12			}
13		}
14	}
15
16	function AcceptCookie() {
17		if (!(this instanceof AcceptCookie)) {
18			return new AcceptCookie();
19		}
20
21		this.init.call(this);
22
23		return this;
24	}
25
26	AcceptCookie.prototype = {
27
28		init: function () {
29			var self = this;
30
31			if(self.readCookie('pjAcceptCookie') == null)
32			{
33				self.appendCss();
34				self.addCookieBar();
35			}
36
37			var clear_cookie_arr = self.getElementsByClass("pjClearCookie", null, "a");
38			if(clear_cookie_arr.length > 0)
39			{
40				self.addEvent(clear_cookie_arr[0], "click", function (e) {
41					if (e.preventDefault) {
42						e.preventDefault();
43					}
44					self.eraseCookie('pjAcceptCookie');
45					document.location.reload();
46					return false;
47				});
48			}
49		},
50		getElementsByClass: function (searchClass, node, tag) {
51			var classElements = new Array();
52			if (node == null) {
53				node = document;
54			}
55			if (tag == null) {
56				tag = '*';
57			}
58			var els = node.getElementsByTagName(tag);
59			var elsLen = els.length;
60			var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
61			for (var i = 0, j = 0; i < elsLen; i++) {
62				if (pattern.test(els[i].className)) {
63					classElements[j] = els[i];
64					j++;
65				}
66			}
67			return classElements;
68		},
69		addEvent: function (obj, type, fn) {
70			if (obj.addEventListener) {
71				obj.addEventListener(type, fn, false);
72			} else if (obj.attachEvent) {
73				obj["e" + type + fn] = fn;
74				obj[type + fn] = function() { obj["e" + type + fn](window.event); };
75				obj.attachEvent("on" + type, obj[type + fn]);
76			} else {
77				obj["on" + type] = obj["e" + type + fn];
78			}
79		},
80		createCookie: function (name, value, days){
81			var expires;
82		    if (days) {
83		        var date = new Date();
84		        date.setTime(date.getTime()+(days*24*60*60*1000));
85		        expires = "; expires="+date.toGMTString();
86		    } else {
87		        expires = "";
88		    }
89		    document.cookie = name+"="+value+expires+"; path=/";
90		},
91		readCookie: function (name) {
92		    var nameEQ = name + "=";
93		    var ca = document.cookie.split(';');
94		    for(var i=0;i < ca.length;i++) {
95		        var c = ca[i];
96		        while (c.charAt(0) === ' ') {
97		            c = c.substring(1,c.length);
98		        }
99		        if (c.indexOf(nameEQ) === 0) {
100		            return c.substring(nameEQ.length,c.length);
101		        }
102		    }
103		    return null;
104		},
105		eraseCookie: function (name) {
106			var self = this;
107			self.createCookie(name,"",-1);
108		},
109		appendCss: function()
110		{
111			var self = this;
112			var cssId = 'pjAcceptCookieCss';
113			if (!document.getElementById(cssId))
114			{
115			    var head  = document.getElementsByTagName('head')[0];
116			    var link  = document.createElement('link');
117			    link.id   = cssId;
118			    link.rel  = 'stylesheet';
119			    link.type = 'text/css';
120			    link.href = 'https://fonts.googleapis.com/css?family=Open+Sans';
121			    link.media = 'all';
122			    head.appendChild(link);
123			}
124
125			var cssCode = "";
126			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarBtn,";
127			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarBtn:after { -webkit-transition: all .5s ease-in-out; -moz-transition: all .5s ease-in-out; -ms-transition: all .5s ease-in-out; -o-transition: all .5s ease-in-out; transition: all .5s ease-in-out; }";
128			cssCode += "#pjAcceptCookieBar { position: fixed; bottom: 0; left: 0; z-index: 9999; overflow-x: hidden; overflow-y: auto; width: 100%; max-height: 100%; padding: 15px 0; background: #000; color:#FFF; font-family: 'Open Sans', sans-serif; text-align: center; }";
129			cssCode += "#pjAcceptCookieBar * { padding: 0; margin: 0; outline: 0; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }";
130			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarShell { width: 90%; margin: 0 auto; }";
131			cssCode += "#pjAcceptCookieBar a[href^=tel] { color: inherit; }";
132			cssCode += "#pjAcceptCookieBar a:focus,";
133			cssCode += "#pjAcceptCookieBar button:focus { outline: unset; outline: none; }";
134			cssCode += "#pjAcceptCookieBar p,  #pjAcceptCookieBar span{ font-size: 13px; line-height: 1.4; color: #fff; font-weight: 400; }";
135			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarActions { padding-top: 10px; }";
136			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarBtn { position: relative; display: inline-block; height: 25px; padding: 0 20px; border: 0; background: #000; border: 1px solid #D6D6D6;font-size: 13px; line-height: 20px; color: #fff; text-decoration: none; vertical-align: middle; cursor: pointer; border-radius: 0; -webkit-appearance: none; -webkit-border-radius: 0; -webkit-transform: translateZ(0); transform: translateZ(0); -webkit-backface-visibility: hidden; backface-visibility: hidden; -moz-osx-font-smoothing: grayscale; margin: 0px 5px;}";
137			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarBtn:hover,";
138			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarBtn:focus { text-decoration: none; }";
139			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarBtn:after { position: absolute; top: 0; right: 52%; bottom: 0; left: 52%; z-index: -1; border-bottom: 4px solid #5c001f; color:#fff; background: rgba(92,0,31, .3); content: ''; }";
140			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarBtn:hover:after,";
141			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarBtn:focus:after { right: 0; left: 0; }";
142			cssCode += "@media only screen and (max-width: 767px) {";
143			cssCode += "#pjAcceptCookieBar { padding: 15px 0; }";
144			cssCode += "#pjAcceptCookieBar .pjAcceptCookieBarShell { width: 96%; }";
145			cssCode += "#pjAcceptCookieBar p { font-size: 16px; }";
146			cssCode += "}";
147
148			var styleElement = document.createElement("style");
149			styleElement.type = "text/css";
150			if (styleElement.styleSheet) {
151			    styleElement.styleSheet.cssText = cssCode;
152			} else {
153				styleElement.appendChild(document.createTextNode(cssCode));
154			}
155			document.getElementsByTagName("head")[0].appendChild(styleElement);
156		},
157		addCookieBar: function(){
158			var self = this;
159			var htmlBar = '';
160
161			htmlBar += '<div class="pjAcceptCookieBarShell">';
162			htmlBar += '<form action="#" method="post">';
163			htmlBar += '<span>
163This site uses cookies to offer you a better browsing experience. Find out more on how we use cookies and how you can change your settings.</span>';
164			htmlBar += '<div class="pjAcceptCookieBarActions">';
165			htmlBar += '<button type="button" class="pjAcceptCookieBarBtn" onclick="updateConsent()">Accept &amp; Close</button>';
166			htmlBar += '<a href="https://globalphotographyawards.com/cookie-policy.php" target="_blank" class="pjAcceptCookieBarBtn">Cookie Policy</a>';
167			htmlBar += '</div>';
168			htmlBar += '</form>';
169			htmlBar += '</div>';
170
171			var barDiv = document.createElement('div');
172			barDiv.id = "pjAcceptCookieBar";
173			document.body.appendChild(barDiv);
174			barDiv.innerHTML = htmlBar;
175
176			self.bindCookieBar();
177		},
178		bindCookieBar: function(){
179			var self = this;
180			var btn_arr = self.getElementsByClass("pjAcceptCookieBarBtn", null, "button");
181			if(btn_arr.length > 0)
182			{
183				self.addEvent(btn_arr[0], "click", function (e) {
184					if (e.preventDefault) {
185						e.preventDefault();
186					}
187					self.createCookie('pjAcceptCookie', 'YES', 365);
188
189					document.getElementById("pjAcceptCookieBar").remove();
190					return false;
191				});
192			}
193		}
194	};
195
196	window.AcceptCookie = AcceptCookie;
197})(window);
198
199window.onload = function() {
200	AcceptCookie = AcceptCookie();
201}

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.