1// (C) Netlogic, 2003 2 3function CreateBaloon() { 4 baloon = document.createElement('DIV'); 5 baloon.setAttribute('id', 'baloon'); 6 7 baloonHeader = document.createElement('DIV'); 8 baloonHeader.setAttribute('id', 'baloonHeader'); 9 baloonHeader.setAttribute('class', 'direct'); 10 11 baloonBody = document.createElement('DIV'); 12 baloonBody.setAttribute('id', 'baloonBody'); 13 14 baloonFooter = document.createElement('DIV'); 15 baloonFooter.setAttribute('id', 'baloonFooter'); 16 17 baloonBody.innerText = 'baloon'; 18 19 baloon.appendChild(baloonHeader); 20 baloon.appendChild(baloonBody); 21 baloon.appendChild(baloonFooter); 22 23 baloon.onmouseover = function(e) { this.style.filter = "Alpha(Opacity='100')"; this.style.cursor = 'pointer'; this.style.MozOpacity = '1';} 24 baloon.onmouseout = function(e) { this.style.filter = "Alpha(Opacity='75')"; this.style.cursor = 'auto'; this.style.MozOpacity = '0.75'; } 25 baloon.onselectstart = function(e) { return false; } 26 baloon.onclick = function(e) { this.style.display = 'none'; } 27 28 document.body.appendChild(baloon); 29 30 window.onresize = function(e) { document.getElementById('baloon').style.display = 'none'; } 31} 32 33function ShowBaloon(i) { 34 baloon = document.getElementById('baloon'); 35 36 document.getElementById('baloonBody').innerHTML = i.getAttribute('data-notice') && i.getAttribute('data-notice').length ? i.getAttribute('data-notice') : 'ERROR'; 37 baloon.style.display = 'block'; 38 39 var xleft=0; 40 var xtop=0; 41 o = i; 42 43 do { 44 xleft += o.offsetLeft; 45 xtop += o.offsetTop; 46 47 } while (o=o.offsetParent); 48 49 xwidth = i.offsetWidth ? i.offsetWidth : i.style.pixelWidth; 50 xheight = i.offsetHeight ? i.offsetHeight : i.style.pixelHeight; 51 52 bwidth = baloon.offsetWidth ? baloon.offsetWidth : baloon.style.pixelWidth; 53 54 w = window; 55 56 xbody = document.compatMode=='CSS1Compat' ? w.document.documentElement : w.document.body; 57 dwidth = xbody.clientWidth ? xbody.clientWidth : w.innerWidth; 58 bwidth = baloon.offsetWidth ? baloon.offsetWidth : baloon.style.pixelWidth; 59 60 flip = !(xwidth - 10 + xleft + bwidth < dwidth); 61 62 baloon.style.top = xheight - 10 + xtop + 'px'; 63 baloon.style.left = (xleft + xwidth - (flip ? bwidth : 0) - 25) + 'px'; 64 65 document.getElementById('baloonHeader').className = flip ? 'baloonHeaderFlip' : 'baloonHeaderDirect'; 66 67 i.focus(); 68 return false; 69} 70 71 72// (C) Netlogic, 2003 73 74function ValidateForms() { 75 for (i = 0; i < document.forms.length; i++) { 76 if(document.forms[i].onsubmit) continue; 77 78 document.forms[i].onsubmit = function(e) { 79 var form = e ? e.target : window.event.srcElement; 80 81 for(var i=0; i<form.elements.length; i++) { 82 var value = form.elements[i].value; 83 84 switch(form.elements[i].type) { 85 case 'text': 86 case 'password': 87 case 'textarea': 88 pattern = form.elements[i].getAttribute('data-format'); 89 90 if(pattern) { 91 switch(pattern) { 92 case 'string': 93 if(!value.length) { 94 return ValidateNotice(form.elements[i]); 95 } 96 break; 97 98 case 'number': 99 if(!isNumeric(value)) { 100 return ValidateNotice(form.elements[i]); 101 } 102 break; 103 104 case 'url': 105 if(!isUrl(value)) { 106 return ValidateNotice(form.elements[i]); 107 } 108 break; 109 110 case 'email': 111 if(!isEmail(value)) { 112 return ValidateNotice(form.elements[i]); 113 } 114 break; 115 116 default: 117 if(!isPattern(pattern, value)) { 118 return ValidateNotice(form.elements[i]); 119 } 120 break; 121 } 122 } 123 break; 124 125 case 'radio': 126 case 'checkbox': 127 min = form.elements[i].getAttribute('min') ? form.elements[i].getAttribute('min') : 0; 128 max = form.elements[i].getAttribute('max') ? form.elements[i].getAttribute('max') : document.getElementsByName(form.elements[i].getAttribute('name')).length; 129 130 if(min || max) { 131 var items = document.getElementsByName(form.elements[i].getAttribute('name')); 132 var count = 0; 133 134 for(var l=0; l<items.length; l++){ 135 if(items[l].checked) { 136 count++; 137 } 138 } 139 140 if(count < min || count > max) { 141 return ValidateNotice(form.elements[i]); 142 } 143 } 144 break; 145 146 case 'select-one': 147 case 'select-multiple': 148 selected = form.elements[i].options[form.elements[i].selectedIndex]; 149 if(selected && selected.getAttribute('notselected')) { 150 return ValidateNotice(form.elements[i]); 151 } 152 break; 153 154 break; 155 156 case 'file': 157 break; 158 159 case 'image': 160 case 'button': 161 case 'submit': 162 case 'reset': 163 break; 164 165 default: 166 break; 167 } 168 } 169 170 return true; 171 } 172 } 173 174} 175 176function isUrl(str) { 177 return isPattern("^https?:\\/\\/(?:[a-z0-9_-]{1,32}(?::[a-z0-9_-]{1,32})?@)?(?:(?:[a-z0-9-]{1,128}\\.)+(?:com|net|org|mil|edu|arpa|gov|biz|info|aero|inc|name|[a-z]{2})|(?!0)(?:(?!0[^.]|255)[0-9]{1,3}\\.){3}(?!0|255)[0-9]{1,3})(?:\\/[a-z0-9.,_@%&?+=\\~\\/-]*)?(?:#[^ '\"&<>]*)?$", str.toLowerCase()); 178} 179 180function isNumeric(str) { 181 return isPattern("^[0-9]+$", str); 182} 183 184function isInteger(str) { 185 return isNumeric(str); 186} 187 188function isFloat(str) { 189 return isPattern("^[1-9]?[0-9]+(\\.[0-9]+)?$", str); 190} 191 192function isEmail(str) { 193 return isPattern("^([a-z0-9_-]+)(\\.[a-z0-9_-]+)*@((([a-z0-9-]+\\.)+(com|net|org|mil|edu|gov|arpa|info|biz|inc|name|[a-z]{2}))|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))$", str.toLowerCase()); 194} 195 196function isPattern(pattern, str) { 197 if(str.length && pattern.length) { 198 var re = new RegExp(pattern, "g"); 199 return re.test(str); 200 } 201 202 return false;
203} 204 205function ValidateNotice(input) { 206 ShowBaloon(input); 207 return false; 208} 209 210 211 212function init_balloon() 213{ 214 ValidateForms(); 215 CreateBaloon(); 216} 217 218if (window.attachEvent) { 219 window.attachEvent("onload", init_balloon); 220} else if (window.addEventListener) { 221 window.addEventListener("DOMContentLoaded", init_balloon, false); 222} else { 223 document.addEventListener("DOMContentLoaded", init_balloon, false); 224} 225
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.