1/////////////////////////////////////// 2// Author: Donatas Stonys // 3// WWW: http://www.BlueWhaleSEO.com // 4// Date: 26 July 2012 // 5// Version: 0.9 // 6/////////////////////////////////////// 7 8// Asign current date to variable // 9var currentDate = new Date(); 10 11// Create some DOM elements 12var newCookiesWarningDiv = document.createElement("div"); 13 14// Retrieving cookie's information 15function checkCookie(cookieName) { 16 "use strict"; 17 var cookieValue, cookieStartsAt, cookieEndsAt; 18 19 // Get all coookies in one string 20 cookieValue = document.cookie; 21 // Check if cookie's name is within that string 22 cookieStartsAt = cookieValue.indexOf(" " + cookieName + "="); 23 if (cookieStartsAt === -1) { 24 cookieStartsAt = cookieValue.indexOf(cookieName + "="); 25 } 26 if (cookieStartsAt === -1) { 27 cookieValue = null; 28 } else { 29 cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1; 30 cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt); 31 32 if (cookieEndsAt === -1) { 33 cookieEndsAt = cookieValue.length; 34 } 35 36 // Get and return cookie's value 37 cookieValue = unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt)); 38 return cookieValue; 39 } 40} 41 42// Cookie setup function 43function setCookie(cookieName, cookieValue, cookiePath, cookieExpires) { 44 "use strict"; 45 46 // Convert characters that are not text or numbers into hexadecimal equivalent of their value in the Latin-1 character set 47 cookieValue = escape(cookieValue); 48 49 // If cookie's expire date is not set 50 if (cookieExpires === "") { 51 // Default expire date is set to 6 after the current date 52 currentDate.setMonth(currentDate.getMonth() + 6); 53 // Convert a date to a string, according to universal time (same as GMT) 54 cookieExpires = currentDate.toUTCString(); 55 } 56 57 // If cookie's path value has been passed 58 if (cookiePath !== "") { 59 cookiePath = ";path = " + cookiePath; 60 } 61 62 // Add cookie to visitors computer 63 document.cookie = cookieName + "=" + cookieValue + ";expires = " + cookieExpires + cookiePath; 64 65 // Call function to get cookie's information 66 checkCookie(cookieName); 67} 68 69// Check if cookies are allowed by browser // 70function checkCookiesEnabled() { 71 "use strict"; 72 // Try to set temporary cookie 73 setCookie("TestCookieExist", "Exist", "", ""); 74 // If temporary cookie has been set, delete it and return true 75 if (checkCookie("TestCookieExist") === "Exist") { 76 setCookie("TestCookieExist", "Exist", "", "1 Jan 2000 00:00:00"); 77 return true; 78 // If temporary cookie hasn't been set, return false 79 } 80 if (checkCookie("TestCookieExist") !== "Exist") { 81 return false; 82 } 83} 84 85// Add HTML form to the website 86function acceptCookies() { 87 "use strict"; 88 89 document.getElementById("cookiesWarning").appendChild(newCookiesWarningDiv).setAttribute("id", "cookiesWarningActive"); 90 document.getElementById("cookiesWarningActive").innerHTML = "<strong id='text'>Nos gustaría añadir cookies en su ordenador para mejorar el sitio. </strong><span id='readMoreURL'></span><form name='cookieAgreement'><input type='checkbox' name='agreed' value='Agreed' class='checkbox'><span class='acceptance'>Acepto las cookies de este sitio.</span><input type='submit' value='Continuar' onclick='getAgreementValue(); return false;' class='button'></form>"; 91 // Change the URL of "Read more..." here 92 document.getElementById("readMoreURL").innerHTML = "<a href='http://www.ico.gov.uk/for_organisations/privacy_and_electronic_communications/the_guide/cookies.aspx' title='ICO - New EU cookie law (e-Privacy Directive)' target='_blank' rel='nofollow'>Leer más...</a>"; 93} 94 95function acceptCookiesTickBoxWarning() { 96 "use strict"; 97 98 setCookie("TestCookie", "Yes", "", "1 Jan 2000 00:00:00"); 99 document.getElementById("cookiesWarning").appendChild(newCookiesWarningDiv).setAttribute("id", "cookiesWarningActive"); 100 document.getElementById("cookiesWarningActive").innerHTML = "<strong id='text'>Nos gustaría añadir cookies en su ordenador para mejorar el sitio. </strong><span id='readMoreURL'></span><form name='cookieAgreement'><p id='warning'><small>Usted debe marcar la casilla 'Acepto las cookies de este sitio'. Si continúa sin cambiar su configuración, asumiremos que desea recibir todas las cookies de este sitio..</small></p><input type='checkbox' name='agreed' value='Agreed' class='checkbox'><span class='acceptance'>Acepto las cookies de este sitio.</span>
100<input type='submit' value='Continuar' onclick='getAgreementValue()' class='button'></form>"; 101 // Change the URL of "Read more..." here 102 document.getElementById("readMoreURL").innerHTML = "<a href='http://www.ico.gov.uk/for_organisations/privacy_and_electronic_communications/the_guide/cookies.aspx' title='ICO - New EU cookie law (e-Privacy Directive)' target='_blank' rel='nofollow'>Leer más...</a>"; 103} 104 105// Check if cookie has been set before // 106function checkCookieExist() { 107 "use strict"; 108 // Call function to check if cookies are enabled in browser 109 if (checkCookiesEnabled()) { 110 // If cookies enabled, check if our cookie has been set before and if yes, leave HTML block empty 111 if (checkCookie("TestCookie") === "Yes") { 112 document.getElementById("cookiesWarning").innerHTML = ""; 113 // If our cookie hasn't been set before, call cookies' agreement form to HTML block 114 } else { 115 acceptCookies(); 116 } 117 } else { 118 // Display warning if cookies are disabled on browser 119 document.getElementById("cookiesWarning").appendChild(newCookiesWarningDiv).setAttribute("id", "cookiesWarningActive"); 120 document.getElementById("cookiesWarningActive").innerHTML = "<span id='cookiesDisabled'><strong>Cookies are disabled. We use cookies to give you the best online experience.</strong><br /> Your browser currently not accepting cookies.</span>"; 121 } 122} 123 124// Get agreement results 125function getAgreementValue() { 126 "use strict"; 127 128 // If agreement box has been checked, set permanent cookie on visitors computer 129 if (document.cookieAgreement.agreed.checked) { 130 // Hide agreement form 131 document.getElementById("cookiesWarning").innerHTML = ""; 132 setCookie("TestCookie", "Yes", "", ""); 133 } else { 134 // If agreement box hasn't been checked, delete cookie (if exist) and add extra warning to HTML form 135 acceptCookiesTickBoxWarning(); 136 } 137}
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.