XOROR

by Conor O'Brien

HTML

<h1>XOROR</h1>
<input type="number" value=20 id=r title="rows">
<input title="string" id=i class="clear" value="Hello, World!">
<input title="cell width" id=w type="number" min=5 value="20">
<button id=b>Toggle chars</button><pre>function modify(A, B, C) {</pre>
<textarea id=k>return A ^ B | C;</textarea>
<pre>}</pre>
<br><span id=c>This should not be blank!</span>

CSS

* {
  font-family: Consolas, monospace;
  white-space: pre;
}

span {
  display: inline-block;
  line-height: 0px;
}

input {
  float: right;
}

#c {
  margin-top: 25px;
}

h1,
input,
pre,
textarea {
  margin: 0;
}

textarea {
  margin-left: 4ch;
  width: 500px;
  border: 1px solid #adadad;
  padding: 5px;
  border-radius: 5px;
}

.dup {
  box-shadow: 0px 0px 5px black;
}

JavaScript

function spect(r) {
  var n = 0,
    e = 0,
    a = 0;
  return r >= 400 && 410 > r ? (t = (r - 400) / 10, n = +(.33 * t) - .2 * t * t) : r >= 410 && 475 > r ? (t = (r - 410) / 65, n = .14 - .13 * t * t) : r >= 545 && 595 > r ? (t = (r - 545) / 50, n = +(1.98 * t) - t * t) : r >= 595 && 650 > r ? (t = (r - 595) / 55, n = .98 + .06 * t - .4 * t * t) : r >= 650 && 700 > r && (t = (r - 650) / 50, n = .65 - .84 * t + .2 * t * t), r >= 415 && 475 > r ? (t = (r - 415) / 60, e = +(.8 * t * t)) : r >= 475 && 590 > r ? (t = (r - 475) / 115, e = .8 + .76 * t - .8 * t * t) : r >= 585 && 639 > r && (t = (r - 585) / 54, e = .84 - .84 * t), r >= 400 && 475 > r ? (t = (r - 400) / 75, a = +(2.2 * t) - 1.5 * t * t) : r >= 475 && 560 > r && (t = (r - 475) / 85, a = .7 - t + .3 * t * t), [255 * n | 0, 255 * e | 0, 255 * a | 0]
}

function chars(t) {
  return t.split("").map(function(t) {
    var r = r = 250 / 94,
      n = spect(r * t.charCodeAt() - 32 * r + 420);
    return "<span title='" + (" " === t ? "(space)" : t) + "' style='position:relative;width:" + w.value + "px;height:" + w.value + "px;background:rgb(" + n + ");'></span>"
  }).join("")
}

function next(t, r) {
  r = r || 0;
  for (var n = "", e = 0; e < t.length; e++) {
    for (var a = String.fromCharCode(modify((t[e - 1] || " ").charCodeAt(), (t[e] || " ").charCodeAt(), (t[e + 1] || " ").charCodeAt())); a > "~" || " " > a;) a = String.fromCharCode(a.charCodeAt() % 127 + 32);
    n += a
  }
  return --r >= 0 ? next(n, r) : n
}

function firstN(t, r) {
  for (var n = [], e = r; e-- > 0;) {
    var a = chars(next(t, r - e - 1));
    n.indexOf(a) >= 0 && (a = a.replace(/style/g, "class='dup' $&")), n.push(a)
  }
  return n
}

function update() {
  var t = i.value,
    n = +r.value;
  newModify = new Function("A", "B", "C", k.value);
  try {
    var e = newModify(43, 43, 43);
    if ("undefined" == typeof e) throw new Error;
    modify = newModify
  } catch (a) {
    alert("Error: bad function passed.")
  }
 ...