From 01e181b2b1c93254f887b0ddc8d2cbe7dc864eed Mon Sep 17 00:00:00 2001 From: timb Date: Thu, 16 Jul 2015 17:32:59 -0700 Subject: rm duplicate parse code --- js/clipboard.js | 2 +- js/parse.js | 131 -------------------------------------------------------- 2 files changed, 1 insertion(+), 132 deletions(-) delete mode 100644 js/parse.js (limited to 'js') diff --git a/js/clipboard.js b/js/clipboard.js index 1c858f6..44f9ad2 100644 --- a/js/clipboard.js +++ b/js/clipboard.js @@ -139,7 +139,7 @@ var clipboard = (function () { if (!data.match(/\x03/)) return exports.import_text(); - var json = colorcode_to_json(data) + var json = colorcode.to_json(data, {fg:0, bg:1}) canvas_width_el.innerHTML = json.w canvas_height_el.innerHTML = json.h diff --git a/js/parse.js b/js/parse.js deleted file mode 100644 index 8697afd..0000000 --- a/js/parse.js +++ /dev/null @@ -1,131 +0,0 @@ -(function(){ - -var char_color = '\x03'; -var regexp_color = /(^[\d]{1,2})?(?:,([\d]{1,2}))?/; - -var style_chars = { - '\x02': 'bold', - '\x1d': 'italic', - '\x1f': 'underline', - '\x0f': 'reset', - '\x16': 'inverse' -}; - -var Style = function(style){ - this.b = style.b; - this.i = style.i; - this.u = style.u; - this.fg = style.fg; - this.bg = style.bg; -}; - -var style_fns = {}; - -style_fns.bold = function(style){ style.b = !style.b }; - -style_fns.italic = function(style){ style.i = !style.i }; - -style_fns.underline = function(style){ style.u = !style.u }; - -style_fns.inverse = function(style){ - var tmp = style.fg; - style.fg = style.bg; - style.bg = tmp; -}; - -style_fns.reset = function(style, base_style){ - style.b = base_style.b; - style.i = base_style.i; - style.u = base_style.u; - style.fg = base_style.fg; - style.bg = base_style.bg; -}; - -var colorcode_to_json = function(string, opts){ - opts = opts || {}; - var d = colorcode_to_json.defaults; - - var base_style = { - b: "b" in opts ? opts.b : d.b, - i: "i" in opts ? opts.i : d.i, - u: "u" in opts ? opts.u : d.u, - fg: "fg" in opts ? opts.fg : d.fg, - bg: "bg" in opts ? opts.bg : d.bg - }; - - var lines_in = string.split(/\r?\n/); - var lines_out = []; - var w = 0, h = 0; - - for (var i=0; i