Last active
September 15, 2023 11:30
-
-
Save fabiorochafg/5554350 to your computer and use it in GitHub Desktop.
High contrast example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body.highContrast { | |
background: #000000; | |
color: #ffffff; | |
} | |
body.highContrast label, | |
body.highContrast li, | |
body.highContrast p, | |
body.highContrast td, | |
body.highContrast th, | |
body.highContrast span { | |
color: #ffffff; | |
} | |
body.highContrast a, | |
body.highContrast abbr, | |
body.highContrast acronym, | |
body.highContrast code, | |
body.highContrast h2, | |
body.highContrast h3, | |
body.highContrast h4, | |
body.highContrast h5, | |
body.highContrast h6, | |
body.highContrast input, | |
body.highContrast select { | |
color: #99ff00; | |
} | |
body.highContrast code, | |
body.highContrast h1, | |
body.highContrast fieldset, | |
body.highContrast input, | |
body.highContrast pre, | |
body.highContrast select, | |
body.highContrast td, | |
body.highContrast th { | |
background: #000000 none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="#" class="highContrast" title="High constrast">High constrast</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read cookie | |
function getCookie(strCookie){ | |
var strName = strCookie + "="; | |
var arrCookies = document.cookie.split(';'); | |
for (var i = 0; i < arrCookies.length; i++) { | |
var strValorCookie = arrCookies[i]; | |
while (strValorCookie.charAt(0) == ' ') { | |
strValorCookie = strValorCookie.substring(1, strValorCookie.length); | |
} | |
if (strValorCookie.indexOf(strName) == 0) { | |
return strValorCookie.substring(strName.length, strValorCookie.length); | |
} | |
} | |
return ''; | |
} | |
// Set cookie | |
function setCookie(name, value, expires, path, domain, secure) { | |
// set time, it's in milliseconds | |
var today = new Date(); | |
today.setTime( today.getTime() ); | |
/* if the expires variable is set, make the correct expires time, the current script below will set | |
it for x number of days, to make it for hours, delete * 24, for minutes, delete * 60 * 24 */ | |
path = '/'; | |
if ( expires ) { | |
expires = expires * 1000 * 60 * 60 * 24; | |
} | |
var expires_date = new Date( today.getTime() + (expires) ); | |
document.cookie = name + "=" +escape( value ) + | |
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + | |
( ( path ) ? ";path=" + path : "" ) + | |
( ( domain ) ? ";domain=" + domain : "" ) + | |
( ( secure ) ? ";secure" : "" ); | |
} | |
// Erase cookie | |
function eraseCookie(name) { | |
setCookie(name, '', -1); | |
} | |
$(document).ready(function() { | |
var cookieContrast = getCookie("highContrast"); | |
if (cookieContrast == "highContrast"){ | |
$("body").addClass("highContrast"); | |
} | |
$("a.highContrast").on('click', function(){ | |
var x = getCookie("highContrast"); | |
if (x == "highContrast") { | |
$("body").removeClass("highContrast"); | |
eraseCookie("highContrast"); | |
} else { | |
$("body").addClass("highContrast"); | |
setCookie("highContrast", "highContrast"); | |
} | |
return (false); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment