diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-02-07 23:40:46 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-02-07 23:40:46 -0500 |
| commit | 2b040e6b7ce737e3f0eab8a25996fc2f71540713 (patch) | |
| tree | b667330fea12c079cdf8e0feefa34d06e0e6a227 /js/clipboard.js | |
| parent | ebe49c97523205a7764182c45fa213aae79e844e (diff) | |
load in color codes from sally HTML
Diffstat (limited to 'js/clipboard.js')
| -rw-r--r-- | js/clipboard.js | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/js/clipboard.js b/js/clipboard.js index 6169b56..af368a5 100644 --- a/js/clipboard.js +++ b/js/clipboard.js @@ -87,13 +87,51 @@ var clipboard = (function () { }, import_html: function () { + var alphabet = {} + toArray("ABCDEFGHIJKLMNOP").forEach(function(c,i){ alphabet[c] = i }) + var rapper = document.createElement("div") rapper.innerHTML = import_textarea.value var lines = rapper.innerText.split("\n") var width = lines.reduce(function(a,b){ return Math.max(a, b.length) }) var height = lines.length zz = rapper.children - rapper + var y = 0; + toArray(rapper.children).forEach(function(span){ + if (span.nodeName !== "SPAN") { return } + var x = 0; + var row = canvas.aa[y++] + if (! row) return + toArray(span.childNodes).forEach(function(el){ + console.log(el) + if (x >= row.length) return; + var line, colorcode = el.nodeName; + if (colorcode === "SPAN") { + colorcode = "F" + css_lookup[el.style.color] + line = el.innerText + } + else if (colorcode === "#text") { + colorcode = "FA" + line = el.nodeValue + } + else { + line = el.innerText + } + if (colorcode[0] !== "F") { return } + if (colorcode.length == 2) { colorcode += "BB" } + + console.log(x, line) + for (var i = 0; i < line.length; i++, x++) { + var lex = row[x] + if (! lex) return + lex.char = line[i] + lex.fg = alphabet[ colorcode[1] ] + lex.bg = alphabet[ colorcode[3] ] + lex.opacity = 1 + lex.build() + } + }) + }) }, import_text: function () { |
