1/* global trackGeoLocation, jqueryReady */ 2 3/* exported resourceLoadedSuccessfully */ 4 5function requestGeoPosition() { 6 // console.log('Requesting GeoLocation data from the browser...'); 7 if (navigator.geolocation) { 8 navigator.geolocation.getCurrentPosition(showGeoPosition, logGeoLocationError, 9 {maximumAge: 600000, timeout: 5000, enableHighAccuracy: true}); 10 } else { 11 // console.log('Browser does not support Geo Location'); 12 } 13} 14 15function logGeoLocationError(error) { 16 switch (error.code) { 17 case error.PERMISSION_DENIED: 18 // console.log('User denied the request for GeoLocation.'); 19 break; 20 case error.POSITION_UNAVAILABLE: 21 // console.log('Location information is unavailable.'); 22 break; 23 case error.TIMEOUT: 24 // console.log('The request to get user location timed out.'); 25 break; 26 default: 27 // console.log('An unknown error occurred.'); 28 break; 29 } 30} 31 32function showGeoPosition(position) { 33 $('[name="geolocation"]').val(position.coords.latitude + ',' 34 + position.coords.longitude + ',' + position.coords.accuracy + ',' + position.timestamp); 35} 36 37 38function preserveAnchorTagOnForm() { 39 $('#fm1').submit(function () { 40 var location = self.document.location; 41 var hash = decodeURIComponent(location.hash); 42 43 if (hash != undefined && hash != '' && hash.indexOf('#') === -1) { 44 hash = '#' + hash; 45 } 46 47 var action = $('#fm1').attr('action'); 48 if (action == undefined) { 49 action = location.href; 50 } else { 51 var qidx = location.href.indexOf('?'); 52 if (qidx != -1) { 53 var queryParams = location.href.substring(qidx); 54 action += queryParams; 55 } 56 } 57 action += hash; 58 $('#fm1').attr('action', action); 59 60 }); 61} 62 63function areCookiesEnabled() { 64 if ($.cookie == undefined) { 65 return; 66 } 67 68 $.cookie('cookiesEnabled', 'true'); 69 var value = $.cookie('cookiesEnabled'); 70 $.removeCookie('cookiesEnabled'); 71 return value != undefined; 72 73} 74 75function disableEmptyInputFormSubmission() { 76 var fields = $('#fm1 input[name="username"],[name="password"]'); 77 78 if (fields.length == 2) { 79 fields.on('input', function (event) { 80 var enableSubmission = $('#fm1 input[name="username"]').val().trim() && 81 $('#fm1 input[name="password"]').val().trim(); 82 83 if (enableSubmission) { 84 $('#fm1 input[name=submit]').removeAttr('disabled'); 85 event.stopPropagation(); 86 } else { 87 $('#fm1 input[name=submit]').attr('disabled', 'true'); 88 } 89 }); 90 } 91 92 /** 93 * Handle auto-complete events to the extent possible. 94 */ 95 if ($('#fm1 input[name="username"]').length > 0) { 96 setTimeout(function () { 97 var uid = $('#username').val(); 98 if (uid != null && uid != '') { 99 $('#username').change(); 100 $('#username').focus(); 101 $('#fm1 input[name=submit]').removeAttr('disabled'); 102 } 103 104 }, 100); 105 } 106} 107 108function resourceLoadedSuccessfully() { 109 $(document).ready(function () { 110 111 if (trackGeoLocation) { 112 requestGeoPosition(); 113 } 114 115 if ($(':focus').length === 0) { 116 $('input:visible:enabled:first').focus(); 117 } 118 119 if (areCookiesEnabled()) { 120 $('#cookiesDisabled').hide(); 121 } else { 122 $('#cookiesDisabled').show(); 123 } 124 125 disableEmptyInputFormSubmission(); 126 preserveAnchorTagOnForm(); 127 128 $('#capslock-on').hide(); 129 $('#fm1 input[name="username"],[name="password"]').trigger('input'); 130 $('#fm1 input[name="username"]').focus(); 131 132 $('#password').keypress(function (e) { 133 var s = String.fromCharCode(e.which); 134 if (s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey) { 135 $('#capslock-on').show(); 136 } else { 137 $('#capslock-on').hide(); 138 } 139 }); 140 if (typeof(jqueryReady) == 'function') { 141 jqueryReady(); 142 } 143 }); 144 145}
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.