ansilove.js

A script to display ANSi and artscene related file formats on web pages
Log | Files | Refs | README | LICENSE

commit 2080fe5304db2ba83316fbc08b7f9963a4fd4f2c
parent 30ce95493f8bcd9c01f9d3bd642ecd58b25a074f
Author: Andy Herbert <andy.herbert@gmail.com>
Date:   Sat,  2 Nov 2013 17:34:37 +0000

Added Web Worker hooks.

Diffstat:
Mansilove.js | 29+++++++++++++++++++++++++++++
Mjslint.json | 6+++++-
2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/ansilove.js b/ansilove.js @@ -1752,4 +1752,33 @@ var AnsiLove = (function () { "displayDataToCanvas": displayDataToCanvas, "sauce": sauce }; +}()); + +(function () { + "use strict"; + if (self.WorkerLocation) { + self.onmessage = function (evt) { + if (evt.data.bytes) { + if (evt.data.split > 0) { + AnsiLove.splitRenderBytes(evt.data.bytes, function (imagedata, sauce) { + self.postMessage({"splitimagedata": imagedata, "sauce": sauce}); + }, evt.data.split, {"imagedata": 1, "font": evt.data.font, "bits": evt.data.bits, "icecolors": evt.data.icecolors, "columns": evt.data.columns, "thumbnail": evt.data.thumbnail, "filetype": evt.data.filetype}); + } else { + AnsiLove.renderBytes(evt.data.bytes, function (imagedata, sauce) { + self.postMessage({"imagedata": imagedata, "sauce": sauce}); + }, {"imagedata": 1, "font": evt.data.font, "bits": evt.data.bits, "icecolors": evt.data.icecolors, "columns": evt.data.columns, "thumbnail": evt.data.thumbnail, "filetype": evt.data.filetype}); + } + } else { + if (evt.data.split > 0) { + AnsiLove.splitRender(evt.data.url, function (imagedata, sauce) { + self.postMessage({"splitimagedata": imagedata, "sauce": sauce}); + }, evt.data.split, {"imagedata": 1, "font": evt.data.font, "bits": evt.data.bits, "icecolors": evt.data.icecolors, "columns": evt.data.columns, "thumbnail": evt.data.thumbnail, "filetype": evt.data.filetype}); + } else { + AnsiLove.render(evt.data.url, function (imagedata, sauce) { + self.postMessage({"imagedata": imagedata, "sauce": sauce}); + }, {"imagedata": 1, "font": evt.data.font, "bits": evt.data.bits, "icecolors": evt.data.icecolors, "columns": evt.data.columns, "thumbnail": evt.data.thumbnail, "filetype": evt.data.filetype}); + } + } + }; + } }()); \ No newline at end of file diff --git a/jslint.json b/jslint.json @@ -7,6 +7,10 @@ "AnsiLove", "Uint8Array", "Uint32Array", - "FileReader" + "FileReader", + "self", + "onmessage", + "postMessage", + "Worker" ] } \ No newline at end of file