1// Generated by CoffeeScript 2.7.0 2(function() { 3 // Place all the behaviors and hooks related to the matching controller here. 4 // All this logic will automatically be available in application.js. 5 // You can use CoffeeScript in this file: http://coffeescript.org/ 6 var COOKIENAME, click_agree, click_deny, default_opts, each_link, getCookie, get_website, submit_response; 7 8 COOKIENAME = "privacy_consent_v00001"; 9 10 this.body_margin = "0px"; 11 12 default_opts = function(options) { 13 14 //options: 15 16 options = $.extend({ 17 privacy_domain: '', 18 ssl: true, 19 title: "", 20 question: "This site uses cookies.", 21 footer: null, 22 agree_text: "OK", 23 width: "100%", 24 height: "50px", 25 links_size: "6pt", 26 links_right: [], 27 links_left: [], 28 more_info_text: null, 29 more_info_link: null, 30 disagree_text: null, 31 disagree_link: null, 32 background_color: "red", 33 text_color: "white", 34 link_color: 'white', 35 top_bar_height: 'auto' 36 }, options); 37 return options; 38 }; 39 40 this.privacy_consent = function(options) { 41 var button, consent_box, consent_div, footer, footerdiv, j, k, len, len1, link, margin, morebutton, no_cookie, no_cookie_link, question, questiondiv, ref, ref1, right_aligned, title, titlediv, website, wrapper; 42 options = default_opts(options); 43 if (getCookie(COOKIENAME)) { 44 45 //first check cookie consent 46 return true; 47 } 48 49 //not found continue on 50 website = get_website(); 51 console.log(website); 52 //create the holding div and align to center 53 consent_div = document.createElement("div"); 54 consent_div.id = "privacy_consent"; 55 $(consent_div).attr("class", "privacy_consent"); 56 $(consent_div).css({ 57 'position': 'fixed', 58 'bottom': '0px', 59 'left': '0px', 60 'width': '100%', 61 'height': options["top_bar_height"], 62 'box-sizing': 'border-box', 63 'overflow': 'auto', 64 'z-index': 9999 65 }); 66 //create the white background div and align to center 67 consent_box = document.createElement("div"); 68 $(consent_box).attr("class", "privacy_consent_box"); 69 $(consent_box).css({ 70 'margin': 'auto', 71 'position': 'relative', 72 'bottom': '0px', 73 'width': '100%', 74 'height': options["top_bar_height"], 75 'background': 'rgba(255,255,255,0.8)', 76 'color': options["text_color"], 77 'overflow': 'auto', 78 'box-sizing': 'border-box' 79 }); 80 81 //right aligned section 82 right_aligned = document.createElement("div"); 83 $(right_aligned).attr("class", "privacy_consent_right_aligned"); 84 $(right_aligned).css({ 85 position: 'relative', 86 'padding-bottom': '10px' 87 }); 88 89 //create the button 90 button = document.createElement("button"); 91 $(button).attr("class", "privacy_consent_button"); 92 $(button).css({ 93 cursor: 'pointer' 94 }); 95 $(button).attr("type", "button"); 96 button.innerHTML = options["agree_text"]; 97 $(button).on('click', function() { 98 return click_agree(options['privacy_domain'], options['ssl']); 99 }); 100 if (options['more_info_text'] !== null) { 101 morebutton = document.createElement("button"); 102 $(morebutton).attr("class", "privacy_consent_more_button"); 103 $(morebutton).css({ 104 cursor: 'pointer' 105 }); 106 $(morebutton).attr("type", "button"); 107 morebutton.innerHTML = options["more_info_text"]; 108 $(morebutton).on('click', function() { 109 return window.open(options["more_info_link"], '_blank'); 110 }); 111 } 112 113 //create the deny link 114 //if typeof(options["disagree_text"]) != 'undefined' && typeof(options["disagree_text"]) != 'null' 115 no_cookie = document.createElement("div"); 116 no_cookie_link = document.createElement("a"); 117 $(no_cookie).attr("class", "privacy_consent_deny"); 118 $(no_cookie).css({ 119 'float': 'left' 120 }); 121 $(no_cookie_link).attr("class", "privacy_consent_deny_link"); 122 $(no_cookie_link).css({ 123 'color': options['link_color'] 124 }); 125 $(no_cookie_link).attr("href", options["disagree_link"]); 126 no_cookie_link.innerHTML = options["disagree_text"]; 127 $(no_cookie_link).on('click', function() {
128 click_deny(options['privacy_domain'], options['ssl']); 129 setTimeout(function() { 130 return window.location = $(no_cookie_link).attr("href"); 131 }, 2000); 132 return false; 133 }); 134 no_cookie.appendChild(no_cookie_link); 135 ref = options["links_right"]; 136 for (j = 0, len = ref.length; j < len; j++) { 137 link = ref[j]; 138 139 //loop through links for more info on the right 140 each_link(link, right_aligned, options); 141 } 142 if (no_cookie_link.innerHTML !== '') { 143 right_aligned.appendChild(no_cookie); 144 } 145 if (typeof morebutton !== "undefined") { 146 right_aligned.appendChild(morebutton); 147 } 148 right_aligned.appendChild(button); 149 150 //ask the question 151 titlediv = document.createElement("div"); 152 $(titlediv).attr("class", "privacy_consent_title"); 153 title = document.createElement("h2"); 154 $(title).attr("class", "privacy_consent_title_h3"); 155 questiondiv = document.createElement("div"); 156 $(questiondiv).attr("class", "privacy_consent_question"); 157 question = document.createElement("p"); 158 $(question).attr("class", "privacy_consent_question_p"); 159 question.innerHTML = options["question"]; 160 footerdiv = document.createElement("div"); 161 $(footerdiv).attr("class", "privacy_consent_footer"); 162 footer = document.createElement("p"); 163 $(footer).attr("class", "privacy_consent_footer_p"); 164 footer.innerHTML = options["footer"]; 165 title.innerHTML = options["title"]; 166 titlediv.appendChild(title); 167 questiondiv.appendChild(question); 168 consent_box.appendChild(titlediv); 169 consent_box.appendChild(questiondiv); 170 consent_box.appendChild(right_aligned); 171 footerdiv.appendChild(footer); 172 consent_div.appendChild(consent_box); 173 consent_div.appendChild(footerdiv); 174 ref1 = options["links_left"]; 175 for (k = 0, len1 = ref1.length; k < len1; k++) { 176 link = ref1[k]; 177 178 //loop through links for more info on the left 179 each_link(link, consent_box, options); 180 } 181 margin = $('body').css('margin'); 182 this.body_margin = margin; 183 // margin_top = (parseInt(margin)+parseInt(options['height'])) 184 // padding = $('body').css('padding') 185 // $('body').css({height:'100%', margin:'0px', padding:'0px'}) 186 wrapper = document.createElement("div"); 187 $(wrapper).attr("class", "privacy_consent_wrapper"); 188 $(wrapper).attr("id", "privacy_consent_wrapper"); 189 // $(wrapper).css({position:'relative', height:'100%', margin:margin, 'margin-top':"#{margin_top}px", padding:padding}) 190 wrapper.appendChild(consent_div); 191 return $('body').prepend(wrapper); 192 }; 193 194 each_link = function(linkinfo, attachedElement, options) { 195 var div, link; 196 div = document.createElement("div"); 197 $(div).attr("class", "privacy_consent_more_info"); 198 link = document.createElement("a"); 199 $(link).attr("class", "privacy_consent_more_info_link"); 200 $(link).css({ 201 'color': options['link_color'], 202 'font-size': options['links_size'] 203 }); 204 $(link).attr("href", linkinfo[1]); 205 $(link).attr("target", "_blank"); 206 link.innerHTML = linkinfo[0]; 207 div.appendChild(link); 208 return attachedElement.appendChild(div); 209 }; 210 211 get_website = function() { 212 return window.location.hostname; 213 }; 214 215 click_agree = function(post_domain, use_ssl) { 216 var d, expires; 217 //ajax call and hide div 218 219 // set cookie 220 d = new Date(); 221 d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000)); 222 expires = "expires=" + d.toUTCString(); 223 document.cookie = `${COOKIENAME}=true;SameSite=none;Secure;` + expires + ";path=/"; 224 $('#privacy_consent_wrapper').remove(); 225 // $("#privacy_consent_wrapper").css({'margin':"#{@body_margin}"}) 226 return submit_response(true, post_domain, use_ssl); 227 }; 228
229 click_deny = function(post_domain, use_ssl) { 230 document.cookie.split(";").forEach(function(c) { 231 return document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;SameSite=none;Secure;expires=" + new Date().toUTCString() + ";path=/"); // need to leave this comment for clearing color coded quotes" 232 }); 233 console.log("removed cookies"); 234 return submit_response(false, post_domain, use_ssl); 235 }; 236 237 getCookie = function(cname) { 238 var c, ca, i, j, len, name, value; 239 name = cname + "="; 240 ca = document.cookie.split(';'); 241 for (i = j = 0, len = ca.length; j < len; i = ++j) { 242 value = ca[i]; 243 c = value; 244 while (c.charAt(0) === ' ') { 245 c = c.substring(1); 246 } 247 if (c.indexOf(name) === 0) { 248 return c.substring(name.length, c.length); 249 } 250 } 251 return false; 252 }; 253 254 submit_response = function(confirmed, post_domain, use_ssl) { 255 var http_var; 256 if (use_ssl) { 257 http_var = "https://"; 258 } else { 259 http_var = "http://"; 260 } 261 return $.ajax(http_var + post_domain + '/record_response', { 262 type: 'POST', 263 dataType: 'text', 264 data: { 265 cookie_check: { 266 confirmed: confirmed, 267 website: get_website() 268 } 269 }, 270 success: function(data, textStatus, jqXHR) { 271 console.log("OK"); 272 return true; 273 }, 274 error: function(data, textStatus, jqXHR) { 275 console.log("OK"); 276 return false; 277 } 278 }); 279 }; 280 281 282 // code below is an example usage 283// $(document).ready -> 284// # pc_options = { 285// # question: "Do we have your consent?", 286// # links_left: [["More Info", "/more_info"],["Privacy Policy", "/more_info"],["GDPR Info", "/more_info"]], 287// # links_right: [["More Info", "/more_info"],["Privacy Policy", "/more_info"],["GDPR Info", "/more_info"]], 288// # agree_text: "I Agree", 289// # disagree_text: "no thanks", 290// # disagree_link: "/no_cookies", 291// # background_color: "red", 292// # text_color: "white", 293// # link_color:'white' 294// # } 295// pc_options = { 296// #privacy_domain: "privacy.digimedia.com", 297// privacy_domain: "localhost:3001", 298// ssl: false, 299// title: 'This site uses cookies.', 300// question: "This site uses cookies to track user logins and for 3rd party ad tracking.", 301// links_left: [["This is a Digimedia.com LP website.", "http://www.digimedia.com"],["Privacy Policy", "/more_info"]] 302// } 303// privacy_consent(pc_options) 304 305}).call(this);
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.