1/*--------------------------------------------------------------------------* 2 * 3 * heightLine JavaScript Library beta4 4 * 5 * MIT-style license. 6 * 7 * 2007 Kazuma Nishihata 8 * http://www.webcreativepark.net 9 * 10 *--------------------------------------------------------------------------*/ 11new function () { 12 13 function heightLine() { 14 15 this.className = "heightLine"; 16 this.parentClassName = "heightLineParent" 17 reg = new RegExp(this.className + "-([a-zA-Z0-9-_]+)", "i"); 18 objCN = new Array(); 19 var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all; 20 for (var i = 0; i < objAll.length; i++) { 21 var eltClass = objAll[i].className.split(/\s+/); 22 for (var j = 0; j < eltClass.length; j++) { 23 if (eltClass[j] == this.className) { 24 if (!objCN["main CN"]) objCN["main CN"] = new Array(); 25 objCN["main CN"].push(objAll[i]); 26 break; 27 } else if (eltClass[j] == this.parentClassName) { 28 if (!objCN["parent CN"]) objCN["parent CN"] = new Array(); 29 objCN["parent CN"].push(objAll[i]); 30 break; 31 } else if (eltClass[j].match(reg)) { 32 var OCN = eltClass[j].match(reg) 33 if (!objCN[OCN]) objCN[OCN] = new Array(); 34 objCN[OCN].push(objAll[i]); 35 break; 36 } 37 } 38 } 39 40 //check font size 41 var e = document.createElement("div"); 42 var s = document.createTextNode("S"); 43 e.appendChild(s); 44 e.style.visibility = "hidden" 45 e.style.position = "absolute" 46 e.style.top = "0" 47 document.body.appendChild(e); 48 var defHeight = e.offsetHeight; 49 50 changeBoxSize = function () { 51 for (var key in objCN) { 52 if (objCN.hasOwnProperty(key)) { 53 //parent type 54 if (key == "parent CN") { 55 for (var i = 0; i < objCN[key].length; i++) { 56 var max_height = 0; 57 var CCN = objCN[key][i].childNodes; 58 for (var j = 0; j < CCN.length; j++) { 59 if (CCN[j] && CCN[j].nodeType == 1) { 60 CCN[j].style.height = "auto"; 61 max_height = max_height > CCN[j].offsetHeight ? max_height : CCN[j].offsetHeight; 62 } 63 } 64 for (var j = 0; j < CCN.length; j++) { 65 if (CCN[j].style) { 66 var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], ''); 67 var newheight = max_height; 68 if (stylea.paddingTop) newheight -= stylea.paddingTop.replace("px", ""); 69 if (stylea.paddingBottom) newheight -= stylea.paddingBottom.replace("px", ""); 70 if (stylea.borderTopWidth && stylea.borderTopWidth != "medium") newheight -= stylea.borderTopWidth.replace("px", ""); 71 if (stylea.borderBottomWidth && stylea.borderBottomWidth != "medium") newheight -= stylea.borderBottomWidth.replace("px", ""); 72 CCN[j].style.height = newheight + "px"; 73 } 74 } 75 } 76 } else { 77 var max_height = 0; 78 for (var i = 0; i < objCN[key].length; i++) { 79 objCN[key][i].style.height = "auto"; 80 max_height = max_height > objCN[key][i].offsetHeight ? max_height : objCN[key][i].offsetHeight; 81 } 82 for (var i = 0; i < objCN[key].length; i++) { 83 if (objCN[key][i].style) { 84 var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], ''); 85 var newheight = max_height; 86 if (stylea.paddingTop) newheight -= stylea.paddingTop.replace("px", ""); 87 if (stylea.paddingBottom) newheight -= stylea.paddingBottom.replace("px", ""); 88 if (stylea.borderTopWidth && stylea.borderTopWidth != "medium") newheight -= stylea.borderTopWidth.replace("px", "") 89 if (stylea.borderBottomWidth && stylea.borderBottomWidth != "medium") newheight -= stylea.borderBottomWidth.replace("px", ""); 90 objCN[key][i].style.height = newheight + "px"; 91 } 92 } 93 } 94 } 95 } 96 } 97 98 checkBoxSize = function () { 99 if (defHeight != e.offsetHeight) { 100 changeBoxSize(); 101 defHeight = e.offsetHeight; 102 } 103 } 104 changeBoxSize(); 105 setInterval(checkBoxSize, 1000) 106 window.onresize = changeBoxSize; 107 } 108 109 function addEvent(elm, listener, fn) { 110 try { 111 elm.addEventListener(listener, fn, false); 112 } catch (e) { 113 elm.attachEvent("on" + listener, fn); 114 } 115 } 116 addEvent(window, "load", heightLine); 117}
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.