Page MenuHomePhabricator

foojs.html

Authored By
bzimport
Nov 22 2014, 2:34 AM
Size
2 KB
Referenced Files
None
Subscribers
None

foojs.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IE 6 CSS Character Equivalence Checker</title>
<style>s { display: none; }</style>
</head>
<body>
<label>
HTML template: <input type="text" id="txtHtml" value="<s style=&quot;top:expression(1)&quot;></s>" size="80">
</label><br>
<label>
CSS property (lowerCamelCase): <input type="text" id="txtPropName" value="top">
</label><br>
<label>
Bad word: <input type="text" id="txtBadWord" value="expression">
</label><br>
<button onclick="startit()">Start</button><br>
<pre id="preResult"></pre>
<div id="sandbox"></div>
<script>
var txtHtml = document.getElementById('txtHtml'),
txtPropName = document.getElementById('txtPropName'),
txtBadWord = document.getElementById('txtBadWord'),
preResult = document.getElementById('preResult'),
sandbox = document.getElementById('sandbox'),
htmlPrefix, htmlSuffix, propName, badWord,
badChar, fullHtmlPrefix, fullHtmlSuffix, i, cp;
function startit() {
badWord = txtBadWord.value;
propName = txtPropName.value;
var htmlParts = txtHtml.value.split(badWord);
htmlPrefix = htmlParts[0];
htmlSuffix = htmlParts[1];
preResult.innerHTML = '';
i = 0;
cp = 0;
loopit();
}
function loopit() {
if (cp === 0) {
badChar = badWord.charAt(i);
logtext(badChar + ':');
fullHtmlPrefix = htmlPrefix + badWord.slice(0, i) + '&#';
fullHtmlSuffix = ';' + badWord.slice(i + 1) + htmlSuffix;
}
window.status = '(' + i + ', ' + cp + ')';
// Try every code point in range, though only a couple hundred at a time.
for (var minor = 0; cp < 65536 && minor < 256; ++cp, ++minor) {
var html = fullHtmlPrefix + cp;
html += fullHtmlSuffix;
sandbox.innerHTML = html;
if (sandbox.firstChild && sandbox.firstChild.style[propName] !== '') {
logtext(' U+' + ('0000' + cp.toString(16)).slice(-4).toUpperCase());
}
}
// After U+FFFF of this letter, check U+0000 of the next.
if (cp > 65535) {
logtext('.', true);
cp = 0;
i++;
}
// If more code points to check, resume after timeout.
if (i < badWord.length) {
setTimeout(loopit);
}
}
function logtext(s, endLine) {
preResult.appendChild(document.createTextNode(s));
if (endLine) {
preResult.appendChild(document.createElement('br'));
}
}
</script>
</body>
</html>

File Metadata

Mime Type
text/html
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
12015
Default Alt Text
foojs.html (2 KB)

Event Timeline