2012-01-07 17:33:42 +00:00
|
|
|
/*\
|
|
|
|
title: js/macros/info.js
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true */
|
|
|
|
"use strict";
|
|
|
|
|
2012-02-06 10:57:28 +00:00
|
|
|
var HTML = require("../HTML.js").HTML,
|
|
|
|
utils = require("../Utils.js");
|
2012-01-07 17:33:42 +00:00
|
|
|
|
|
|
|
exports.macro = {
|
|
|
|
name: "info",
|
|
|
|
types: ["text/html","text/plain"],
|
|
|
|
params: {
|
2012-01-19 11:56:06 +00:00
|
|
|
info: {byName: "default", type: "text", optional: false}
|
2012-01-07 17:33:42 +00:00
|
|
|
},
|
2012-02-02 18:15:59 +00:00
|
|
|
events: {
|
|
|
|
click: function(event,node,tiddler,store,params) {
|
|
|
|
var el = node.firstChild.firstChild.nextSibling;
|
|
|
|
el.style.display = el.style.display === "block" ? "none" : "block";
|
|
|
|
event.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2012-01-30 20:04:47 +00:00
|
|
|
render: function(type,tiddler,store,params) {
|
2012-01-07 17:33:42 +00:00
|
|
|
var encoder = type === "text/html" ? utils.htmlEncode : function(x) {return x;},
|
2012-01-25 15:35:52 +00:00
|
|
|
info = params.info || "parsetree";
|
2012-01-23 16:41:49 +00:00
|
|
|
if(tiddler) {
|
|
|
|
var parseTree = store.parseTiddler(tiddler.title);
|
|
|
|
switch(info) {
|
|
|
|
case "parsetree":
|
2012-02-06 11:31:23 +00:00
|
|
|
return HTML(HTML.slider("parsetree",
|
2012-02-02 18:15:59 +00:00
|
|
|
"Parse tree",
|
|
|
|
"The parse tree for this tiddler",
|
2012-02-06 11:31:23 +00:00
|
|
|
HTML.raw(parseTree.toString(type))),type);
|
2012-01-23 16:41:49 +00:00
|
|
|
//break;
|
2012-01-23 19:04:11 +00:00
|
|
|
case "compiled":
|
2012-02-06 11:31:23 +00:00
|
|
|
return HTML(HTML.slider("compiled",
|
2012-02-02 18:15:59 +00:00
|
|
|
"Render functions",
|
|
|
|
"The render functions for this tiddler",
|
2012-02-06 11:31:23 +00:00
|
|
|
HTML.raw(parseTree.compile(type).toString(type))),type);
|
2012-01-23 19:04:11 +00:00
|
|
|
//break;
|
2012-01-23 16:41:49 +00:00
|
|
|
case "dependencies":
|
2012-02-06 11:31:23 +00:00
|
|
|
return HTML(HTML.slider("dependencies",
|
2012-02-02 18:15:59 +00:00
|
|
|
"Dependencies",
|
|
|
|
"The dependencies for this tiddler",
|
2012-02-06 11:31:23 +00:00
|
|
|
HTML.raw((parseTree.dependencies === null) ? "*" : encoder(parseTree.dependencies.join(", ")))),type);
|
2012-02-02 18:15:59 +00:00
|
|
|
//break;
|
2012-01-23 16:41:49 +00:00
|
|
|
}
|
2012-01-07 17:33:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|