1// JavaScript Document 2 3$(function(){ 4//Initialize to hide caps-lock-warning 5$('.caps-lock-warning').hide(); 6 7//Sniff for Caps-Lock state 8$("#password").keypress(function(e) { 9var s = String.fromCharCode( e.which ); 10if((s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey)|| 11(s.toUpperCase() !== s && s.toLowerCase() === s && e.shiftKey)) { 12this.caps = true; // Enables to do something on Caps-Lock keypress 13$(this).next('.caps-lock-warning').show(); 14} else if((s.toLowerCase() === s && s.toUpperCase() !== s && !e.shiftKey)|| 15(s.toLowerCase() !== s && s.toUpperCase() === s && e.shiftKey)) { 16this.caps = false; // Enables to do something on Caps-Lock keypress 17$(this).next('.caps-lock-warning').hide(); 18 19}//else else do nothing if not a letter we can use to differentiate 20}); 21 22//Toggle warning message on Caps-Lock toggle (with some limitation) 23$(document).keydown(function(e){ 24if(e.which==20){ // Caps-Lock keypress 25var pass = document.getElementById("password"); 26if(pass !== null && typeof(pass.caps) === 'boolean'){ 27//State has been set to a known value by keypress 28pass.caps = !pass.caps; 29$(pass).next('.caps-lock-warning').toggle(pass.caps); 30 31//if(document.getElementById("password").value == document.getElementById("password").value.toUpperCase()) 32// document.getElementById("password").value="" 33 34} 35} 36}); 37 38//Disable on window lost focus (because we loose track of state) 39$(window).blur(function(e){ 40// If window is inactive, we have no control on the caps lock toggling 41// so better to re-set state 42var pass = document.getElementById("password"); 43if(pass !== null && typeof(pass.caps) === 'boolean'){ 44pass.caps = null; 45$(pass).next('.caps-lock-warning').hide(); 46 47} 48}); 49}); 50
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.