mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2026-01-11 03:32:20 -08:00
45 lines
926 B
JavaScript
45 lines
926 B
JavaScript
/*\
|
|
title: js/BitmapParser.js
|
|
|
|
Compiles bitmap images into JavaScript functions that render them in HTML
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true */
|
|
"use strict";
|
|
|
|
var utils = require("./Utils.js");
|
|
|
|
var BitmapRenderer = function(handlerCode) {
|
|
/*jslint evil: true */
|
|
this.handler = eval(handlerCode);
|
|
};
|
|
|
|
BitmapRenderer.prototype.render = function(tiddler,store) {
|
|
return this.handler(tiddler,store,utils);
|
|
};
|
|
|
|
// The parse tree is degenerate
|
|
var BitmapParseTree = function() {
|
|
this.dependencies = [];
|
|
};
|
|
|
|
BitmapParseTree.prototype.compile = function(type) {
|
|
if(type === "text/html") {
|
|
return new BitmapRenderer("(function (tiddler,store,utils) {return '<img src=\"data:' + tiddler.type + ';base64,' + tiddler.text + '\">';})");
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
|
|
var BitmapParser = function() {
|
|
};
|
|
|
|
BitmapParser.prototype.parse = function() {
|
|
return new BitmapParseTree();
|
|
};
|
|
|
|
exports.BitmapParser = BitmapParser;
|
|
|
|
})();
|