1/** 2 * autofocus.js 3 * Copyright (c) 2006 Unoh Inc. (http://unoh.net) 4 * --- 5 * USES: 6 * <script type="text/javascript" src="/js/prototype.js"></script> 7 * <script type="text/javascript" src="/js/autofocus.js"></script> 8 * --- 9 */ 10 11var AutoFocus = { 12 Version: '1.0.0', 13 checkCanFocus: function () { 14 frms = AutoFocus._getTags('form'); 15 for (var i = 0; i < frms.length; i++) { 16 var frm = frms[i]; 17 if (!frm.childNodes) continue; 18 AutoFocus._checkCanFocus(frm); 19 } 20 }, 21 _getTags: function (tagName) { 22 var o; 23 o = document.getElementsByTagName(tagName); 24 return o; 25 }, 26 _checkCanFocus: function (obj) { 27 // check childNodes 28 if (obj.childNodes) { 29 var ns = obj.childNodes; 30 for (var i = 0; i < ns.length; i++) { 31 var cn = ns[i]; 32 if (AutoFocus._checkCanFocus(cn)) return true; 33 } 34 } 35 // check this node 36 if (!obj.nodeName) return false; 37 if (obj.nodeName == "INPUT") { 38 if (obj.type == "text" || obj.type == "search" || obj.type == "radio" || obj.type == "checkbox" || obj.type == "email" || obj.type == "password") { 39 obj.focus(); 40 return true; 41 } 42 } 43 if (obj.nodeName == "TEXTAREA") { 44 obj.focus(); 45 return true; 46 } 47 return false; 48 } 49}; 50 51// add onLoad event 52Event.observe(window, 'load', AutoFocus.checkCanFocus, false); 53
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.