1/* 2 * Chris Rodriguez 3 * [email protected] 4 */ 5 6// Cookie handler, non-$ style 7function createCookie(name, value, days) { 8 if (days) { 9 var date = new Date(); 10 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 11 var expires = "; expires=" + date.toGMTString(); 12 } else { 13 var expires = ''; 14 } 15 16 document.cookie = name + "=" + value + expires + "; path=/; SameSite=Strict;"; 17} 18 19function readCookie(name) { 20 var nameEQ = name + "="; 21 var ca = document.cookie.split(';'); 22 for (var i = 0; i < ca.length; i++) { 23 var c = ca[i]; 24 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 25 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 26 } 27 28 return null; 29} 30 31function eraseCookie(name) { 32 createCookie(name, ""); 33} 34 35( function( $ ) { 36 // Saturation handler 37 if (readCookie('a11y-desaturated')) { 38 $('body').addClass('desaturated'); 39 $('#is_normal_color').attr('id', 'is_grayscale').attr('aria-pressed', true).addClass('active'); 40 } 41 42 $( '.a11y-toggle' ).on( 'focus', function(e) { 43 $( this ).removeClass( 'tooltip-dismissed' ); 44 }); 45 46 $( '.a11y-toggle' ).on( 'keyup', function(e) { 47 if ( e.keyCode == 27 ) { 48 $( this ).addClass( 'tooltip-dismissed' ); 49 } 50 }); 51 52 53 if (readCookie('a11y-high-contrast')) { 54 $('body').addClass('contrast'); 55 $('head').append($("<link href='" + wpa11y.path + "' id='highContrastStylesheet' rel='stylesheet' type='text/css' />")); 56 $('#is_normal_contrast').attr('id', 'is_high_contrast').attr('aria-pressed', true).addClass('active'); 57 $('.a11y-toolbar ul li a i').addClass('icon-white'); 58 } 59 60 if (readCookie('a11y-larger-fontsize')) { 61 $('html').addClass('fontsize'); 62 $('#is_normal_fontsize').attr('id', 'is_large_fontsize').attr('aria-pressed', true).addClass('active'); 63 } 64 65 $('.toggle-grayscale').on('click', function (e) { 66 if ($(this).attr('id') == "is_normal_color") { 67 $('body').addClass('desaturated'); 68 $(this).attr('id', 'is_grayscale').attr('aria-pressed', true).addClass('active'); 69 createCookie('a11y-desaturated', '1'); 70 } else { 71 $('body').removeClass('desaturated'); 72 $(this).attr('id', 'is_normal_color').attr('aria-pressed', false).removeClass('active'); 73 eraseCookie('a11y-desaturated'); 74 } 75 76 return false; 77 }); 78 79 $('.toggle-contrast').on('click', function (e) { 80 if ($(this).attr('id') == "is_normal_contrast") { 81 $('head').append($("<link href='" + wpa11y.path + "' id='highContrastStylesheet' rel='stylesheet' type='text/css' />")); 82 $('body').addClass('contrast'); 83 $(this).attr('id', 'is_high_contrast').attr('aria-pressed', true).addClass('active'); 84 createCookie('a11y-high-contrast', '1'); 85 } else { 86 $('#highContrastStylesheet').remove(); 87 $('body').removeClass('contrast'); 88 $(this).attr('id', 'is_normal_contrast').attr('aria-pressed', false).removeClass('active'); 89 eraseCookie('a11y-high-contrast'); 90 } 91 92 return false; 93 }); 94 95 $('.toggle-fontsize').on('click', function (e) { 96 if ($(this).attr('id') == "is_normal_fontsize") { 97 $('html').addClass('fontsize'); 98 $(this).attr('id', 'is_large_fontsize').attr('aria-pressed', true).addClass('active'); 99 createCookie('a11y-larger-fontsize', '1'); 100 } else { 101 $('html').removeClass('fontsize'); 102 $(this).attr('id', 'is_normal_fontsize').attr('aria-pressed', false).removeClass('active'); 103 eraseCookie('a11y-larger-fontsize'); 104 } 105 106 return false; 107 }); 108 109} )( jQuery );
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.