From dc6858ee1ce36bff2766af8825032d10c7d75ae7 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 15 Jul 2015 20:28:20 -0400 Subject: adding vendor dir.. --- js/vendor/colorcode.js | 528 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 528 insertions(+) create mode 100644 js/vendor/colorcode.js (limited to 'js/vendor/colorcode.js') diff --git a/js/vendor/colorcode.js b/js/vendor/colorcode.js new file mode 100644 index 0000000..c401b84 --- /dev/null +++ b/js/vendor/colorcode.js @@ -0,0 +1,528 @@ +!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.colorcode=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o cp437 function by sheetjs +// edited from https://github.com/SheetJS/js-codepage/blob/master/bits/437.js +var cp437 = (function(){ var d = "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\b\t\n\u000b\f\r\u000e\u000f\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ", D = [], e = {}; for(var i=0;i!=d.length;++i) { if(d.charCodeAt(i) !== 0xFFFD) e[d[i]] = i; D[i] = d.charAt(i); } return {"enc": e, "dec": D }; })(); + +var render_char = function(font, char_value, ctx, ctx_x, ctx_y){ + char_value = cp437.enc[String.fromCharCode(char_value)] | 0; + var sheet_x = (char_value % font.sheet_w_in_chars) * font.char_w + var sheet_y = ((char_value / font.sheet_w_in_chars) |0) * font.char_h + ctx.drawImage(font.sheet, + sheet_x|0, sheet_y|0, font.char_w, font.char_h, + ctx_x|0, ctx_y|0, font.char_w, font.char_h) + +} + +for (var i=0, wh; wh=cp437s[i]; i++){ + var font = {}; + font.is_char_blank = require('../fontutil').is_char_blank; + font.render_char = render_char; + font.name = 'cp437_' + wh[0] + 'x' + wh[1]; + font.sheet_url = './img/' + font.name + '.png' + font.sheet_w_in_chars = 16; + font.char_w = wh[0] + font.char_h = wh[1] + fonts[font.name] = font; +} + + + +// window.cp437 = cp437; + +},{"../fontutil":7}],6:[function(require,module,exports){ +var font = {}; +module.exports = font; +font.name = 'fixedsys' +font.sheet_url = './img/fsex-simple.png' +font.sheet_w_in_chars = 128 +//url_sheet = 'http://i.imgur.com/vSzBNwZ.png' +font.char_w = 8 +font.char_h = 16; +font.is_char_blank = require('../fontutil').is_char_blank; + +font.render_char = function(font, char_value, ctx, ctx_x, ctx_y, char){ + var sheet_x = 0, sheet_y = 3; + if (char_value >= 0x20 && char_value <= 0x7e){ // ascii + sheet_x = (char_value - 0x20) * font.char_w + if (char.i){ // italic + sheet_y = 1 * font.char_h + 3 + } + } else if (char_value >= 0x2500 && char_value <= 0x25ff){ // geom + sheet_x = (char_value - 0x2500) * font.char_w; + sheet_y = 2 * font.char_h + 3 + } else if (char_value >= 0x2600 && char_value <= 0x26ff){ // emoji + sheet_x = (char_value - 0x2600) * font.char_w; + sheet_y = 3 * font.char_h + 3 + } + + // var sheet_x = (char_value % font.sheet_w_in_chars) * font.char_w + // var sheet_y = ((char_value / font.sheet_w_in_chars) |0) * font.char_h + 3 + ctx.drawImage(font.sheet, + sheet_x|0, sheet_y|0, font.char_w, font.char_h, + ctx_x|0, ctx_y|0, font.char_w, font.char_h) + +} + +},{"../fontutil":7}],7:[function(require,module,exports){ +var util = {}; +module.exports = util; + +util.is_char_blank = function(char_value){ + if (char_value === 32) return true; +} + +util.render_char = function(font, char_value, ctx, ctx_x, ctx_y){ + var sheet_x = (char_value % font.sheet_w_in_chars) * font.char_w + var sheet_y = ((char_value / font.sheet_w_in_chars) |0) * font.char_h + ctx.drawImage(font.sheet, + sheet_x|0, sheet_y|0, font.char_w, font.char_h, + ctx_x|0, ctx_y|0, font.char_w, font.char_h) + +} + + +},{}],8:[function(require,module,exports){ +var char_color = '\x03'; + +var make_colorcode_fgbg = function(fg, bg){ + // pad numbers: this prevents irc parsing confusion + // when the character after the colorcode is a number + if (fg < 10) fg = "0" + fg; + if (bg < 10) bg = "0" + bg; + return char_color + fg + "," + bg +} + +var colorcode_from_json = function(json, opts){ + var out = ""; + for (var li=0, line; line=json.lines[li]; li++){ + for (var ci=0, char; char=line[ci]; ci++){ + out += make_colorcode_fgbg(char.fg, char.bg) + out += String.fromCharCode(char.value) + } + out += "\n"; + } + return out; +} + + +module.exports = colorcode_from_json; + +},{}],9:[function(require,module,exports){ +// default settings for fonts, colors, etc +var style = {}; +module.exports = style; + +},{}],10:[function(require,module,exports){ +var default_style = require('./style'); + +default_style.b = false; +default_style.i = false; +default_style.u = false; +default_style.fg = 1; +default_style.bg = 99; + +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 to_json = function(string, opts){ + opts = opts || {}; + + var base_style = { + "b": ("b" in opts) ? opts.b : default_style.b, + "i": ("i" in opts) ? opts.i : default_style.i, + "u": ("u" in opts) ? opts.u : default_style.u, + "fg": ("fg" in opts) ? opts.fg : default_style.fg, + "bg": ("bg" in opts) ? opts.bg : default_style.bg + }; + + var lines_in = string.split(/\r?\n/); + var data = []; + var w = 0, h = 0; + + for (var i=0; i