1/** 2 * dropboxwrapper.js 3 * wrap input elements with drop boxes 4 * 5 * search page, looking for INPUT elements of class taxondrop, namedrop or placedrop 6 * where found, add dropbox packaging 7 * 8 * @author Tom Humphrey <[email protected]> 9 * @copyright Tom Humphrey 2008 10 * @version forked from atHome.005w.js 11 * @package docform 12 */ 13 14 function DropBoxWrapper() { 15 /** 16 * refs for all dropboxes, for purposes of cleanup on unload 17 * 18 * @var array 19 */ 20 this.dropboxList=[]; 21 this.windowUnloadHandle=register_event_handler(window,'beforeunload',this,'onunload_handler',''); 22 } 23 24 /** 25 * handler for window onload event 26 * 27 * Wrappers must be registered once the page is fully loaded. 28 */ 29 DropBoxWrapper.prototype.onload_handler = function () 30 { 31 this.wrap('taxondropbox',TaxonBox); 32 this.wrap('persondropbox',NameBox); 33 this.wrap('placedropbox',StandalonePlaceName); 34 }; 35 36 /** 37 * handler for window unload event 38 * 39 * Dispose of all registered wrappers 40 */ 41DropBoxWrapper.prototype.onunload_handler = function () 42{ 43 window.onbeforeunload=null; 44 window.onerror=null; 45 46 this.destroy(); 47 }; 48 49DropBoxWrapper.prototype.wrap = function (className, object) 50{ 51 var inputElements=document.getElementsByTagName('input'); 52 53 var classMatch=new RegExp('\\b'+className+'\\b'); 54 55 for (var i=0, l=inputElements.length; i<l; i++) { 56 if (inputElements[i].className.search(classMatch)!==-1) { 57 var obj=new object(); 58 var inputName=inputElements[i].name; 59 var inputId=inputElements[i].id; 60 var inputValue=inputElements[i].value; 61 var inputWidth=inputElements[i].style.width; 62 var inputTitle=inputElements[i].title; 63 var inputClass=inputElements[i].className; 64 65 // look for any additional input element which contains an external id 66 // will have id of the form dropboxedelementid_id 67 // strip any square-bracket component first 68 //var idContainerElement=document.getElementById((inputId.search(/\[/)!=-1)?inputId.replace(/\[/,'id['):inputId+'id'); 69 //if (idContainerElement) { 70 // obj.set_id_container_element(idContainerElement); 71 //} 72 obj.wrapper_link_related_elements(inputId); 73 74 inputElements[i].parentNode.replaceChild(obj.container,inputElements[i]); 75 76 obj.input.setAttribute('name',inputName); 77 obj.input.value=inputValue; 78 obj.input.style.width=inputWidth; 79 obj.input.title=inputTitle; 80 obj.input.className=inputClass; 81 82 this.dropboxList.push(obj); 83 } 84 } 85}; 86 87DropBoxWrapper.prototype.destroy = function () 88{ 89 for (var n in this.dropboxList) { 90 if (this.dropboxList.hasOwnProperty(n)) { 91 this.dropboxList[n].destroy(); // destruction may need to leave input boxes intact??? 92 } 93 } 94 this.dropboxList = null; 95 96 this.windowUnloadHandle=remove_event_handler(this.windowUnloadHandle); 97}; 98 99var wrapper=new DropBoxWrapper(); 100wrapper.onload_handler();
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.