| <script> |
| function run(n,cut){ |
| var out = "", str = "abcdefghijklmnopqrstuvwxyz 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ,./:;'\"()*!?-_@[]{}#%`+=|\\>"; |
| n.innerHTML = 'aa'; |
| |
| var base = n.scrollWidth; |
| for(var i=0;i<str.length;i++) { |
| n.innerHTML = 'a'+str.charAt(i)+'a'; |
| out += str.charAt(i) + (n.scrollWidth-base) +";"; |
| |
| if(cut && !i && (n.scrollWidth-base == cut)) { |
| return '\x02'+"0;"; |
| } |
| } |
| // extra cases for literals |
| n.innerHTML = 'a<a'; |
| out += '<' + (n.scrollWidth-base) +";"; |
| n.innerHTML = 'a&a'; |
| out += '&' + (n.scrollWidth-base) +";"; |
| |
| var base_height = n.scrollHeight; |
| n.innerHTML += '<br>a'; |
| out += '\x01' + (n.scrollHeight-base_height) +";"; |
| |
| return out; |
| } |
| |
| function TEST_WIDTH() { |
| var n = document.getElementById('test'); |
| var out = run(n[$~CUT~$]); |
| if (out.length>4){ |
| n.style.fontWeight='bold'; |
| out += run(n); |
| } |
| n.outerHTML = ""; |
| (new Image()).src="[$~SETWIDTH~$]?src=[COMPONENT]&data="+escape(out).replace(/\+/g,"%2B"); |
| } |
| </script> |