1/* global wwsgd_vars */ 2( function () { 3 'use strict'; 4 5 /** 6 * Returns the current value of the wwsgd_visits cookie, or 0 if absent. 7 * 8 * @return {number} Visit count. 9 */ 10 function getWwsgdCookieValue() { 11 var cookie = document.cookie 12 .split( '; ' ) 13 .map( function ( pair ) { return pair.split( '=' ); } ) 14 .find( function ( pair ) { return pair[ 0 ] === 'wwsgd_visits'; } ); 15 16 return ( cookie && parseInt( cookie[ 1 ], 10 ) ) || 0; 17 } 18 19 /** 20 * Writes the wwsgd_visits cookie with a 1-year expiry. 21 * 22 * @param {number} value New visit count. 23 */ 24 function setWwsgdCookieValue( value ) { 25 var d = new Date(); 26 d.setTime( d.getTime() + 365 * 24 * 60 * 60 * 1000 ); 27 document.cookie = 'wwsgd_visits=' + value 28 + ';path=' + wwsgd_vars.cookie_path 29 + ';expires=' + d.toUTCString(); 30 } 31 32 document.addEventListener( 'DOMContentLoaded', function () { 33 var count = getWwsgdCookieValue() + 1; 34 setWwsgdCookieValue( count ); 35 36 if ( count <= wwsgd_vars.repetition ) { 37 Array.from( document.getElementsByClassName( 'wwsgd_new_visitor' ) ) 38 .forEach( function ( el ) { el.style.display = ''; } ); 39 } else { 40 Array.from( document.getElementsByClassName( 'wwsgd_return_visitor' ) ) 41 .forEach( function ( el ) { el.style.display = ''; } ); 42 } 43 } ); 44}() );
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.