1function Cookiemanager() { 2 this.name = 'cookieManager'; 3 this.defaultExpiration = this.getExpiration(); 4 this.defaultDomain = window.location.host.replace(/((^\w+:\/\/[\w-]+\.)|\/)/, ''); 5 this.defaultPath = '/'; 6 this.cookies = new Object(); 7 this.expiration = new Object(); 8 this.domain = new Object(); 9 this.path = new Object(); 10 this.getDocumentCookies(); 11} 12 13Cookiemanager.prototype.getExpiration = function() { 14 var date = new Date(); 15 date.setTime(date.getTime()+(7*24*60*60*1000)); 16 return date.toGMTString(); 17} 18 19Cookiemanager.prototype.getDocumentCookies = function() { 20 var cookie,pair; 21 var cookies = document.cookie.split(';'); 22 var len = cookies.length; 23 for(var i=0;i < len;i++) { 24 cookie = cookies[i]; 25 while (cookie.charAt(0)==' ') cookie = cookie.substring(1,cookie.length); 26 pair = cookie.split('='); 27 this.cookies[pair[0]] = pair[1]; 28 } 29} 30 31Cookiemanager.prototype.setDocumentCookies = function() { 32 var expires = ''; 33 var cookies = ''; 34 var domain = ''; 35 var path = ''; 36 for(var name in this.cookies) { 37 expires = (this.expiration[name])?this.expiration[name]:this.defaultExpiration; 38 path = this.defaultPath; 39 domain = this.defaultDomain; 40 if(name) { 41 var cookies = name + '=' + this.cookies[name] + '; expires=' + expires + '; path=' + path + '; domain=' + domain; 42 if(cookies != '') { 43 document.cookie = cookies; 44 } 45 } 46 } 47 return true; 48} 49 50Cookiemanager.prototype.getCookie = function() { 51 return (this.cookies['fontSize'])?this.cookies['fontSize']:false; 52} 53 54Cookiemanager.prototype.setCookie = function(cookieValue) { 55 if(!isNaN(cookieValue)) { 56 this.cookies['fontSize'] = parseInt(cookieValue); 57 this.expiration['fontSize'] = this.getExpiration(); 58 this.domain['fontSize'] = window.location.host.replace(/^[\w-]+\./, ''); 59 this.path['fontSize'] = this.defaultPath; 60 this.setDocumentCookies(); 61 return true; 62 } 63} 64 65var cookieManager = new Cookiemanager();
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.