1/*! 2 * jQuery Cookie Plugin v1.3.1 3 * https://github.com/carhartl/jquery-cookie 4 * 5 * Copyright 2013 Klaus Hartl 6 * Released under the MIT license 7 */ 8(function (factory) { 9 if (typeof define === 'function' && define.amd) { 10 // AMD. Register as anonymous module. 11 define(['jquery'], factory); 12 } else { 13 // Browser globals. 14 factory(jQuery); 15 } 16}(function ($) { 17 18 var pluses = /\+/g; 19 20 function decode(s) { 21 if (config.raw) { 22 return s; 23 } 24 try { 25 // If we can't decode the cookie, ignore it, it's unusable. 26 return decodeURIComponent(s.replace(pluses, ' ')); 27 } catch(e) {} 28 } 29 30 function decodeAndParse(s) { 31 if (s.indexOf('"') === 0) { 32 // This is a quoted cookie as according to RFC2068, unescape... 33 s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); 34 } 35 36 s = decode(s); 37 38 try { 39 // If we can't parse the cookie, ignore it, it's unusable. 40 return config.json ? JSON.parse(s) : s; 41 } catch(e) {} 42 } 43 44 var config = $.cookie = function (key, value, options) { 45 46 // Write 47 if (value !== undefined) { 48 options = $.extend({}, config.defaults, options); 49 50 if (typeof options.expires === 'number') { 51 var days = options.expires, t = options.expires = new Date(); 52 t.setDate(t.getDate() + days); 53 } 54 55 value = config.json ? JSON.stringify(value) : String(value); 56 57 return (document.cookie = [ 58 config.raw ? key : encodeURIComponent(key), 59 '=', 60 config.raw ? value : encodeURIComponent(value), 61 options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE 62 options.path ? '; path=' + options.path : '', 63 options.domain ? '; domain=' + options.domain : '', 64 options.secure ? '; secure' : '' 65 ].join('')); 66 } 67 68 // Read 69 70 var result = key ? undefined : {}; 71 72 // To prevent the for loop in the first place assign an empty array 73 // in case there are no cookies at all. Also prevents odd result when 74 // calling $.cookie(). 75 var cookies = document.cookie ? document.cookie.split('; ') : []; 76 77 for (var i = 0, l = cookies.length; i < l; i++) { 78 var parts = cookies[i].split('='); 79 var name = decode(parts.shift()); 80 var cookie = parts.join('='); 81 82 if (key && key === name) { 83 result = decodeAndParse(cookie); 84 break; 85 } 86 87 // Prevent storing a cookie that we couldn't decode. 88 if (!key && (cookie = decodeAndParse(cookie)) !== undefined) { 89 result[name] = cookie; 90 } 91 } 92 93 return result; 94 }; 95 96 config.defaults = {}; 97 98 $.removeCookie = function (key, options) { 99 if ($.cookie(key) !== undefined) { 100 // Must not alter options, thus extending a fresh object... 101 $.cookie(key, '', $.extend({}, options, { expires: -1 })); 102 return true; 103 } 104 return false; 105 }; 106 107})); 108 109/* ====================================================================================== 110 @author Carlos Doral Pérez (http://webartesanal.com) 111 @version 0.19 112 @copyright Copyright © 2013-2014 Carlos Doral Pérez, All Rights Reserved 113 License: GPLv2 or later 114 ====================================================================================== */ 115 116// 117// 118// 119var cdp_cookie = { 120 121 // vars 122 _id_cookie: 'cdp-cookies-plugin-wp', 123 124 // 125 // Compruebo si ya existe la cookie si es visitante nuevo. 126 // 127 // Modif: 08-ene-2014. Compruebo primero si existe la cookie antes del contenido de la misma 128 // 129 ya_existe_cookie: function _ya_existe_cookie() { 130 if( jQuery.cookie( cdp_cookie._id_cookie ) != null ) 131 return jQuery.cookie( cdp_cookie._id_cookie ) == 'cdp'; 132 return false; 133 }, 134 135 // Guardo cookie 136 poner_cookie: function _poner_cookie() { 137 return jQuery.cookie( cdp_cookie._id_cookie, 'cdp', { expires: 365, path: '/' } ); 138 }, 139 140 // Eliminar cookie 141 eliminar: function _eliminar() {
142 return jQuery.removeCookie( cdp_cookie._id_cookie ); 143 }, 144 145 // Muestra aviso 146 mostrar_aviso: function _mostrar_aviso() { 147 if( cdp_cookies_info.layout == 'pagina' && cdp_cookies_info.posicion == 'superior' ) 148 { 149 var aviso = jQuery( '.cdp-cookies-alerta' ).wrap( '<div>' ).parent().html(); 150 jQuery( '.cdp-cookies-alerta' ).parent().detach(); 151 jQuery( 'body' ).prepend( aviso ); 152 } 153 if( jQuery( '.cdp-cookies-boton-cerrar' ).length > 0 ) 154 jQuery( '.cdp-cookies-boton-cerrar' ).click( function() { 155 cdp_cookie.poner_cookie(); 156 jQuery( '.cdp-cookies-alerta' ).hide(); 157 } ); 158 jQuery( '.cdp-cookies-alerta' ).show(); 159 }, 160 161 // 162 comportamiento: function _comportamiento() { 163 return cdp_cookies_info.comportamiento; 164 }, 165 166 // Preparo la query string 167 variables_get: function _variables_get() { 168 var url = window.location.href; 169 var pares = url.slice( url.indexOf( '?' ) + 1 ).split( '&' ); 170 var query = {}; 171 for ( var i = 0 ; i < pares.length ; i++ ) { 172 var par = pares[i].split( '=' ); 173 if( par.length == 1 ) 174 query[par[0]] = null; 175 else 176 if( par.length == 2 ) 177 query[par[0]] = par[1]; 178 } 179 return query; 180 }, 181 182 // Indica si hay vista previa 183 hay_vista_previa: function _hay_vista_previa() { 184 return window.location.href.indexOf( '?cdp_cookies_vista_previa=1' ) >= 0; 185 }, 186 187 // Traigo aviso en vista previa 188 mostrar_aviso_vista_previa: function _mostrar_aviso_vista_previa() { 189 cdp_cookie.mostrar_aviso(); 190 }, 191}; 192 193// 194// 195// 196jQuery( document ).ready( function( $ ) 197{ 198 // Funcionamiento para depuración desde el admin de Wordpress 199 if( cdp_cookie.hay_vista_previa() ) 200 { 201 cdp_cookie.mostrar_aviso_vista_previa(); 202 return; 203 } 204 205 // Si ya hay cookie retorno 206 if( cdp_cookie.ya_existe_cookie() ) 207 return; 208 209 // Comportamiento 'navegar' 210 if( cdp_cookie.comportamiento() == 'navegar' ) 211 cdp_cookie.poner_cookie(); 212 213 // Muestro aviso 214 cdp_cookie.mostrar_aviso(); 215} );
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.